Fix the issues reported by phpcs

Created on 3 February 2023, over 1 year ago
Updated 18 December 2023, 6 months ago

Running phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml shows the following warnings/errors, which should be fixed.

FILE: ./src/Controller/VirtualEventsEventEndedController.php
----------------------------------------------------------------------
FOUND 3 ERRORS AND 1 WARNING AFFECTING 3 LINES
----------------------------------------------------------------------
  6 | ERROR   | [x] Use statements should be sorted alphabetically.
    |         |     The first wrong one is
    |         |     Drupal\Component\Utility\UrlHelper.
 25 | ERROR   | [x] Expected 1 space after IF keyword; 0 found
 25 | ERROR   | [x] Expected 1 space after closing parenthesis; found
    |         |     0
 30 | WARNING | [x] A comma should follow the last multiline array
    |         |     item. Found: $url
----------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Entity/VirtualEventsConfigEntity.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 95 | ERROR | [x] Use null coalesce operator instead of ternary
    |       |     operator.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Entity/VirtualEventsEventEntity.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 190 | WARNING | Unused variable $sources.
----------------------------------------------------------------------


FILE: ./src/Form/VirtualEventsConfigEntityForm.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 12 WARNINGS AFFECTING 11 LINES
----------------------------------------------------------------------
 18 | WARNING | \Drupal calls should be avoided in classes, use
    |         | dependency injection instead
 19 | WARNING | \Drupal calls should be avoided in classes, use
    |         | dependency injection instead
 20 | WARNING | \Drupal calls should be avoided in classes, use
    |         | dependency injection instead
 24 | WARNING | Unused variable $formBuilder.
 24 | WARNING | \Drupal calls should be avoided in classes, use
    |         | dependency injection instead
 26 | WARNING | Unused variable $pluginConfigForms.
 33 | WARNING | \Drupal calls should be avoided in classes, use
    |         | dependency injection instead
 62 | WARNING | t() calls should be avoided in classes, use
    |         | \Drupal\Core\StringTranslation\StringTranslationTrait
    |         | and $this->t() instead
 64 | WARNING | t() calls should be avoided in classes, use
    |         | \Drupal\Core\StringTranslation\StringTranslationTrait
    |         | and $this->t() instead
 83 | WARNING | t() calls should be avoided in classes, use
    |         | \Drupal\Core\StringTranslation\StringTranslationTrait
    |         | and $this->t() instead
 89 | WARNING | t() calls should be avoided in classes, use
    |         | \Drupal\Core\StringTranslation\StringTranslationTrait
    |         | and $this->t() instead
 97 | WARNING | t() calls should be avoided in classes, use
    |         | \Drupal\Core\StringTranslation\StringTranslationTrait
    |         | and $this->t() instead
----------------------------------------------------------------------


FILE: ./src/Form/VirtualEventsFormatterEntityForm.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 14 WARNINGS AFFECTING 12 LINES
----------------------------------------------------------------------
 38 | WARNING | Unused variable $virtual_events_config_id.
 39 | WARNING | Unused variable $config.
 40 | WARNING | Unused variable $virtualEventsCommon.
 40 | WARNING | \Drupal calls should be avoided in classes, use
    |         | dependency injection instead
 41 | WARNING | \Drupal calls should be avoided in classes, use
    |         | dependency injection instead
 42 | WARNING | \Drupal calls should be avoided in classes, use
    |         | dependency injection instead
 43 | WARNING | Unused variable $allBundles.
 43 | WARNING | \Drupal calls should be avoided in classes, use
    |         | dependency injection instead
 45 | WARNING | Unused variable $sources.
 46 | WARNING | \Drupal calls should be avoided in classes, use
    |         | dependency injection instead
 50 | WARNING | t() calls should be avoided in classes, use
    |         | \Drupal\Core\StringTranslation\StringTranslationTrait
    |         | and $this->t() instead
 52 | WARNING | t() calls should be avoided in classes, use
    |         | \Drupal\Core\StringTranslation\StringTranslationTrait
    |         | and $this->t() instead
 69 | WARNING | t() calls should be avoided in classes, use
    |         | \Drupal\Core\StringTranslation\StringTranslationTrait
    |         | and $this->t() instead
 72 | WARNING | t() calls should be avoided in classes, use
    |         | \Drupal\Core\StringTranslation\StringTranslationTrait
    |         | and $this->t() instead
----------------------------------------------------------------------


FILE: ./src/Plugin/VirtualEventFormatterPluginBase.php
----------------------------------------------------------------------
FOUND 2 ERRORS AND 1 WARNING AFFECTING 2 LINES
----------------------------------------------------------------------
  7 | ERROR   | [x] Use statements should be sorted alphabetically.
    |         |     The first wrong one is
    |         |     Drupal\Core\Entity\Display\EntityViewDisplayInterface.
 15 | WARNING | [x] Unused use statement
 15 | ERROR   | [x] There must be one blank line after the last USE
    |         |     statement; 2 found;
----------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Plugin/VirtualEventFormatterPluginManager.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\Core\Cache\CacheBackendInterface.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Plugin/VirtualEventPostHandlePluginBase.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\Component\Plugin\PluginBase.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Plugin/VirtualEventPostHandlePluginManager.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\Core\Cache\CacheBackendInterface.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Plugin/VirtualEventPreHandlePluginBase.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\Component\Plugin\PluginBase.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Plugin/VirtualEventPreHandlePluginManager.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\Core\Cache\CacheBackendInterface.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Plugin/VirtualEventSourcePluginBase.php
----------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
----------------------------------------------------------------------
   6 | ERROR | [x] Use statements should be sorted alphabetically.
     |       |     The first wrong one is
     |       |     Drupal\Component\Plugin\PluginBase.
 109 | ERROR | [x] Expected 1 space before opening brace; found 0
 110 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected
     |       |     "TRUE" but found "true"
----------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Plugin/VirtualEventSourcePluginManager.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\Core\Cache\CacheBackendInterface.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Services/VirtualEventsCommonService.php
----------------------------------------------------------------------
FOUND 2 ERRORS AND 2 WARNINGS AFFECTING 4 LINES
----------------------------------------------------------------------
  46 | WARNING | [ ] \Drupal calls should be avoided in classes, use
     |         |     dependency injection instead
  69 | WARNING | [ ] Unused variable $key.
 102 | ERROR   | [x] Inline comments must end in full-stops,
     |         |     exclamation marks, question marks, colons, or
     |         |     closing parentheses
 104 | ERROR   | [x] Inline comments must end in full-stops,
     |         |     exclamation marks, question marks, colons, or
     |         |     closing parentheses
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/VirtualEventsUninstallValidator.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 10 | ERROR | [x] Use statements should be sorted alphabetically. The
    |       |     first wrong one is
    |       |     Drupal\virtual_events\Entity\VirtualEventsConfigEntity.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./virtual_events.module
----------------------------------------------------------------------
FOUND 3 ERRORS AND 5 WARNINGS AFFECTING 7 LINES
----------------------------------------------------------------------
  10 | ERROR   | [x] Use statements should be sorted alphabetically.
     |         |     The first wrong one is
     |         |     Drupal\Core\Entity\EntityFormInterface.
  42 | WARNING | [x] A comma should follow the last multiline array
     |         |     item. Found: NULL
 106 | WARNING | [ ] Unused variable $sourceOpt.
 231 | ERROR   | [x] Expected 1 space after IF keyword; 0 found
 231 | ERROR   | [x] Expected 1 space after closing parenthesis;
     |         |     found 0
 239 | WARNING | [ ] Unused variable $sourcesResults.
 292 | WARNING | [ ] Unused variable
     |         |     $virtualEventsSourcePluginManager.
 368 | WARNING | [ ] Unused variable $plugin.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./virtual_events.routing.yml
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 7 | WARNING | The administration page callback should probably use
   |         | "administer site configuration" - which implies the
   |         | user can change something - rather than "access
   |         | administration pages" which is about viewing but not
   |         | changing configurations.
----------------------------------------------------------------------

Time: 473ms; Memory: 14MB
๐Ÿ“Œ Task
Status

Needs review

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia Jay Jangid

Live updates comments and jobs are added and updated live.
  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

  • Needs reroll

    The patch will have to be re-rolled with new suggestions/changes described in the comments in the issue.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @Jay Jangid
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Jay Jangid

    Created MR , please review.

    Thank you.

  • Issue was unassigned.
  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    -    // Be pesimistic about getting a type
    +    // Be pesimistic about getting a type.

    pesimistic is misspelled.

    Out of curiosity: Why was not the DrupalPractice standard used?

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia zkhan.aamir

    zkhan.aamir โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia zkhan.aamir

    I have used command
    phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig virtual_events/

  • First commit to issue fork.
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    The warnings/errors are for 17 files, but the MR changes 13 files. It seems there are still four files to change.

  • First commit to issue fork.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sakthi_dev

    Fixed some PHPCS issues, still there are \Drupal calls error that needs to be fixed.

    FILE: .../contribution/virtual_events/src/Form/VirtualEventsFormatterEntityForm.php
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 6 WARNINGS AFFECTING 5 LINES
    --------------------------------------------------------------------------------
     38 | WARNING | \Drupal calls should be avoided in classes, use dependency
        |         | injection instead
     39 | WARNING | \Drupal calls should be avoided in classes, use dependency
        |         | injection instead
     40 | WARNING | Unused variable $allBundles.
     40 | WARNING | \Drupal calls should be avoided in classes, use dependency
        |         | injection instead
     42 | WARNING | Unused variable $sources.
     43 | WARNING | \Drupal calls should be avoided in classes, use dependency
        |         | injection instead
    --------------------------------------------------------------------------------
    
    
    FILE: ...cts/contribution/virtual_events/src/Form/VirtualEventsConfigEntityForm.php
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 7 WARNINGS AFFECTING 6 LINES
    --------------------------------------------------------------------------------
     18 | WARNING | \Drupal calls should be avoided in classes, use dependency
        |         | injection instead
     19 | WARNING | \Drupal calls should be avoided in classes, use dependency
        |         | injection instead
     20 | WARNING | \Drupal calls should be avoided in classes, use dependency
        |         | injection instead
     24 | WARNING | Unused variable $formBuilder.
     24 | WARNING | \Drupal calls should be avoided in classes, use dependency
        |         | injection instead
     26 | WARNING | Unused variable $pluginConfigForms.
     33 | WARNING | \Drupal calls should be avoided in classes, use dependency
        |         | injection instead
    --------------------------------------------------------------------------------
    
    
    FILE: ...ts/contribution/virtual_events/src/Services/VirtualEventsCommonService.php
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     46 | WARNING | \Drupal calls should be avoided in classes, use dependency
        |         | injection instead
    --------------------------------------------------------------------------------
    
  • Assigned to Neha-Verma
  • Issue was unassigned.
  • Status changed to Needs review 6 months ago
Production build 0.69.0 2024