Fix the issues reported by phpcs

Created on 11 May 2023, about 1 year ago
Updated 18 March 2024, 3 months ago

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

FILE: ./README.md
----------------------------------------------------------------------
FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
----------------------------------------------------------------------
 1 | WARNING | Line exceeds 80 characters; contains 83 characters
 3 | WARNING | Line exceeds 80 characters; contains 97 characters
 5 | WARNING | Line exceeds 80 characters; contains 116 characters
 8 | WARNING | Line exceeds 80 characters; contains 116 characters
----------------------------------------------------------------------


FILE: ./config/install/core.entity_form_mode.media.asset_edit.yml
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 9 | ERROR | [x] Expected 1 newline at end of file; 0 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./config/install/core.entity_view_mode.media.asset_format.yml
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 9 | ERROR | [x] Expected 1 newline at end of file; 0 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./multi_image_formatter.info.yml
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 8 | ERROR | [x] Expected 1 newline at end of file; 0 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./multi_image_formatter.module
----------------------------------------------------------------------
FOUND 15 ERRORS AND 6 WARNINGS AFFECTING 20 LINES
----------------------------------------------------------------------
   1 | ERROR   | [x] Missing file doc comment
   7 | ERROR   | [x] Opening brace should be on the same line as the
     |         |     declaration
  12 | WARNING | [x] A comma should follow the last multiline array
     |         |     item. Found: ]
  13 | WARNING | [x] A comma should follow the last multiline array
     |         |     item. Found: ]
  21 | ERROR   | [x] Opening brace should be on the same line as the
     |         |     declaration
  23 | ERROR   | [x] Namespaced classes/interfaces/traits should be
     |         |     referenced with use statements
  37 | ERROR   | [x] Opening brace should be on the same line as the
     |         |     declaration
  39 | ERROR   | [x] Namespaced classes/interfaces/traits should be
     |         |     referenced with use statements
  43 | WARNING | [x] A comma should follow the last multiline array
     |         |     item. Found: FALSE
  48 | WARNING | [x] A comma should follow the last multiline array
     |         |     item. Found: FALSE
  57 | ERROR   | [x] Namespaced classes/interfaces/traits should be
     |         |     referenced with use statements
  58 | ERROR   | [x] Opening brace should be on the same line as the
     |         |     declaration
  60 | ERROR   | [x] Namespaced classes/interfaces/traits should be
     |         |     referenced with use statements
  61 | ERROR   | [x] Namespaced classes/interfaces/traits should be
     |         |     referenced with use statements
  64 | WARNING | [x] A comma should follow the last multiline array
     |         |     item. Found: 'container'
  79 | ERROR   | [x] Namespaced classes/interfaces/traits should be
     |         |     referenced with use statements
  79 | ERROR   | [x] Namespaced classes/interfaces/traits should be
     |         |     referenced with use statements
  80 | ERROR   | [x] Namespaced classes/interfaces/traits should be
     |         |     referenced with use statements
  88 | WARNING | [x] A comma should follow the last multiline array
     |         |     item. Found: )
  99 | ERROR   | [x] Namespaced classes/interfaces/traits should be
     |         |     referenced with use statements
 100 | ERROR   | [x] Opening brace should be on the same line as the
     |         |     declaration
----------------------------------------------------------------------
PHPCBF CAN FIX THE 21 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Controller/AssetFormatController.php
----------------------------------------------------------------------
FOUND 27 ERRORS AND 3 WARNINGS AFFECTING 22 LINES
----------------------------------------------------------------------
 16 | ERROR   | [x] Missing class doc comment
 18 | ERROR   | [ ] Missing short description in doc comment
 19 | ERROR   | [x] Data types in @var tags need to be fully
    |         |     namespaced
 23 | ERROR   | [ ] Missing short description in doc comment
 24 | ERROR   | [ ] Missing parameter comment
 24 | ERROR   | [x] Data types in @param tags need to be fully
    |         |     namespaced
 30 | ERROR   | [x] Line indented incorrectly; expected 2 spaces,
    |         |     found 4
 39 | ERROR   | [x] Line indented incorrectly; expected 2 spaces,
    |         |     found 4
 40 | ERROR   | [x] Doc comment short description must end with a
    |         |     full stop
 42 | ERROR   | [x] Doc comment long description must start with a
    |         |     capital letter
 42 | ERROR   | [x] Doc comment long description must end with a full
    |         |     stop
 44 | ERROR   | [ ] Missing parameter comment
 44 | ERROR   | [x] Data types in @param tags need to be fully
    |         |     namespaced
 45 | ERROR   | [ ] Missing parameter comment
 46 | ERROR   | [x] Separate the @param and @return sections by a
    |         |     blank line.
 51 | WARNING | [x] A comma should follow the last multiline array
    |         |     item. Found: )
 56 | ERROR   | [x] Doc comment short description must start with a
    |         |     capital letter
 56 | ERROR   | [x] Doc comment short description must end with a
    |         |     full stop
 58 | ERROR   | [ ] Missing parameter comment
 58 | ERROR   | [x] Data types in @param tags need to be fully
    |         |     namespaced
 59 | ERROR   | [x] Separate the @param and @return sections by a
    |         |     blank line.
 59 | ERROR   | [ ] Description for the @return value is missing
 59 | ERROR   | [x] Data types in @return tags need to be fully
    |         |     namespaced
 63 | WARNING | [ ] MediaType::load calls should be avoided in
    |         |     classes, use dependency injection instead
 74 | ERROR   | [x] Short array syntax must be used to define arrays
 76 | ERROR   | [x] Concat operator must be surrounded by a single
    |         |     space
 76 | ERROR   | [x] Concat operator must be surrounded by a single
    |         |     space
 78 | WARNING | [x] A comma should follow the last multiline array
    |         |     item. Found: 'Download'
 84 | ERROR   | [x] Expected 1 blank line after function; 0 found
 85 | ERROR   | [x] The closing brace for the class must have an
    |         |     empty line before it
----------------------------------------------------------------------
PHPCBF CAN FIX THE 22 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Plugin/Field/FieldFormatter/MultiImageFormatter.php
----------------------------------------------------------------------
FOUND 42 ERRORS AND 5 WARNINGS AFFECTING 40 LINES
----------------------------------------------------------------------
  31 | ERROR   | [ ] Missing short description in doc comment
  32 | ERROR   | [x] Data types in @var tags need to be fully
     |         |     namespaced
  36 | ERROR   | [ ] Missing short description in doc comment
  37 | ERROR   | [x] Data types in @var tags need to be fully
     |         |     namespaced
  41 | ERROR   | [ ] Missing short description in doc comment
  42 | ERROR   | [ ] Missing parameter comment
  42 | ERROR   | [ ] Missing parameter type
  43 | ERROR   | [ ] Missing parameter comment
  43 | ERROR   | [ ] Missing parameter type
  44 | ERROR   | [ ] Missing parameter comment
  44 | ERROR   | [x] Data types in @param tags need to be fully
     |         |     namespaced
  45 | ERROR   | [ ] Missing parameter comment
  46 | ERROR   | [ ] Missing parameter comment
  46 | ERROR   | [ ] Missing parameter type
  47 | ERROR   | [ ] Missing parameter comment
  47 | ERROR   | [ ] Missing parameter type
  48 | ERROR   | [ ] Missing parameter comment
  49 | ERROR   | [ ] Missing parameter comment
  49 | ERROR   | [x] Data types in @param tags need to be fully
     |         |     namespaced
  50 | ERROR   | [ ] Missing parameter comment
  50 | ERROR   | [x] Data types in @param tags need to be fully
     |         |     namespaced
  53 | ERROR   | [x] Opening brace should be on the same line as the
     |         |     declaration
  63 | ERROR   | [x] Opening brace should be on the same line as the
     |         |     declaration
  81 | ERROR   | [x] Opening brace should be on the same line as the
     |         |     declaration
  83 | ERROR   | [x] Array indentation error, expected 6 spaces but
     |         |     found 8
  84 | ERROR   | [x] Array indentation error, expected 6 spaces but
     |         |     found 8
  85 | ERROR   | [x] Array indentation error, expected 6 spaces but
     |         |     found 8
  86 | ERROR   | [x] Array closing indentation error, expected 4
     |         |     spaces but found 6
  93 | ERROR   | [x] Opening brace should be on the same line as the
     |         |     declaration
 114 | WARNING | [x] A comma should follow the last multiline array
     |         |     item. Found: )
 120 | WARNING | [x] A comma should follow the last multiline array
     |         |     item. Found: )
 130 | ERROR   | [x] Opening brace should be on the same line as the
     |         |     declaration
 139 | ERROR   | [x] Inline control structures are not allowed
 141 | ERROR   | [x] Line indented incorrectly; expected 6 spaces,
     |         |     found 8
 143 | ERROR   | [x] Line indented incorrectly; expected 6 spaces,
     |         |     found 4
 144 | ERROR   | [x] Line indented incorrectly; expected 8 spaces,
     |         |     found 6
 145 | ERROR   | [x] Line indented incorrectly; expected 6 spaces,
     |         |     found 4
 146 | ERROR   | [x] Line indented incorrectly; expected 6 spaces,
     |         |     found 4
 147 | ERROR   | [x] Line indented incorrectly; expected 8 spaces,
     |         |     found 6
 148 | ERROR   | [x] Line indented incorrectly; expected 6 spaces,
     |         |     found 4
 150 | ERROR   | [x] Line indented incorrectly; expected 6 spaces,
     |         |     found 4
 157 | ERROR   | [x] Opening brace should be on the same line as the
     |         |     declaration
 189 | WARNING | [x] A comma should follow the last multiline array
     |         |     item. Found: ]
 203 | WARNING | [x] A comma should follow the last multiline array
     |         |     item. Found: ]
 209 | WARNING | [x] A comma should follow the last multiline array
     |         |     item. Found: $formats
 213 | ERROR   | [x] Expected 1 blank line after function; 0 found
 214 | ERROR   | [x] The closing brace for the class must have an
     |         |     empty line before it
----------------------------------------------------------------------
PHPCBF CAN FIX THE 31 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Routing/RouteSubscriber.php
----------------------------------------------------------------------
FOUND 18 ERRORS AFFECTING 12 LINES
----------------------------------------------------------------------
  12 | ERROR | [x] Missing class doc comment
  45 | ERROR | [x] Opening brace should be on the same line as the
     |       |     declaration
  62 | ERROR | [x] Doc comment short description must start with a
     |       |     capital letter
  62 | ERROR | [x] Doc comment short description must end with a full
     |       |     stop
  76 | ERROR | [x] Concat operator must be surrounded by a single
     |       |     space
  77 | ERROR | [x] Array closing indentation error, expected 8 spaces
     |       |     but found 6
  88 | ERROR | [x] Doc comment short description must start with a
     |       |     capital letter
  88 | ERROR | [x] Doc comment short description must end with a full
     |       |     stop
 101 | ERROR | [x] Concat operator must be surrounded by a single
     |       |     space
 113 | ERROR | [x] Doc comment short description must start with a
     |       |     capital letter
 113 | ERROR | [x] Doc comment short description must end with a full
     |       |     stop
 115 | ERROR | [ ] Missing parameter comment
 115 | ERROR | [x] Data types in @param tags need to be fully
     |       |     namespaced
 116 | ERROR | [x] Separate the @param and @return sections by a
     |       |     blank line.
 116 | ERROR | [ ] Description for the @return value is missing
 116 | ERROR | [x] Data types in @return tags need to be fully
     |       |     namespaced
 128 | ERROR | [x] Expected 1 blank line after function; 0 found
 129 | ERROR | [x] The closing brace for the class must have an empty
     |       |     line before it
----------------------------------------------------------------------
PHPCBF CAN FIX THE 16 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 76ms; Memory: 10MB
šŸ“Œ Task
Status

Needs review

Version

1.0

Component

Code

Created by

šŸ‡®šŸ‡³India Shanu Chouhan

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.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @Shanu Chouhan
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • šŸ‡®šŸ‡³India Shanu Chouhan

    I have Created a patch to fix this issue.

  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • Status changed to Needs work 4 months ago
  • šŸ‡®šŸ‡³India Ashutosh Ahirwal India

    Hi, Provided patch in #2 is not getting apply and throwing error.
    Moving to need work.

  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • Status changed to Needs review 4 months ago
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • Status changed to Needs work 4 months ago
  • šŸ‡®šŸ‡³India Preethy_ray

    Hi ,
    Applied MR1 found few more errors and warnings that need to be resolved.

    FILE: .../multi_image_formatter/src/Controller/AssetFormatController.php
    ----------------------------------------------------------------------------
    FOUND 1 ERROR AND 3 WARNINGS AFFECTING 4 LINES
    ----------------------------------------------------------------------------
     29 | WARNING | [ ] Line exceeds 80 characters; contains 92 characters
     60 | WARNING | [x] A comma should follow the last multiline array item.
        |         |     Found: )
     76 | ERROR   | [x] Additional blank lines found at end of doc comment
     79 | WARNING | [ ] MediaType::load calls should be avoided in classes, use
        |         |     dependency injection instead
    ----------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------
    
    
    FILE: ../multi_image_formatter/src/Routing/RouteSubscriber.php
    ----------------------------------------------------------------------------
    FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
    ----------------------------------------------------------------------------
     32 | WARNING | [ ] Line exceeds 80 characters; contains 83 characters
     78 | ERROR   | [x] Concat operator must be surrounded by a single space
    ----------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------
    
    
    FILE: ...mage_formatter/src/Plugin/Field/FieldFormatter/MultiImageFormatter.php
    ----------------------------------------------------------------------------
    FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES
    ----------------------------------------------------------------------------
      46 | WARNING | [ ] Line exceeds 80 characters; contains 106 characters
     221 | ERROR   | [x] Expected 1 blank line after function; 0 found
     222 | ERROR   | [x] The closing brace for the class must have an empty
         |         |     line before it
    ----------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------
    
    
    FILE: .../multi_image_formatter/multi_image_formatter.module
    ----------------------------------------------------------------------------
    FOUND 2 ERRORS AND 4 WARNINGS AFFECTING 6 LINES
    ----------------------------------------------------------------------------
     14 | ERROR   | [x] Use statements should be sorted alphabetically. The
        |         |     first wrong one is Drupal\media\Entity\MediaType.
     24 | WARNING | [x] A comma should follow the last multiline array item.
        |         |     Found: ]
     25 | WARNING | [x] A comma should follow the last multiline array item.
        |         |     Found: ]
     53 | WARNING | [x] A comma should follow the last multiline array item.
        |         |     Found: FALSE
     58 | WARNING | [x] A comma should follow the last multiline array item.
        |         |     Found: FALSE
     89 | ERROR   | [x] Namespaced classes/interfaces/traits should be
        |         |     referenced with use statements
    ----------------------------------------------------------------------------
    PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------
    
  • šŸ‡®šŸ‡³India Preethy_ray

    Hi,
    fixed few errors and warnings.
    Remaining errors that need to be addressed are

    FILE: .../multi_image_formatter/src/Controller/AssetFormatController.php
    ----------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    ----------------------------------------------------------------------------
     29 | WARNING | Line exceeds 80 characters; contains 92 characters
     78 | WARNING | MediaType::load calls should be avoided in classes, use
        |         | dependency injection instead
    ----------------------------------------------------------------------------
    
    
    FILE: ...multi_image_formatter/src/Routing/RouteSubscriber.php
    ----------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------------
     32 | WARNING | Line exceeds 80 characters; contains 83 characters
    ----------------------------------------------------------------------------
    
    
    FILE: ...mage_formatter/src/Plugin/Field/FieldFormatter/MultiImageFormatter.php
    ----------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------------
     46 | WARNING | Line exceeds 80 characters; contains 106 characters
    ----------------------------------------------------------------------------
    
  • Status changed to Needs review 4 months ago
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • šŸ‡µšŸ‡­Philippines clarkssquared

    Hi

    I applied MR !1 and I confirmed that it fixes most of the PHPCS issues of hte module, however there are PHPCS issues regarding line exceeds 80 characters, hence I will retain the status to needs review so that others can review if these remaining PHPCS issues should be fixed or not.

    āžœ  multi_image_formatter git:(1.0.x) curl https://git.drupalcode.org/project/multi_image_formatter/-/merge_requests/1.diff | patch -p1                                      
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 24368    0 24368    0     0  27217      0 --:--:-- --:--:-- --:--:-- 27472
    patching file README.md
    patching file 'config/install/core.entity_form_mode.media.asset_edit.yml'
    patching file 'config/install/core.entity_view_mode.media.asset_format.yml'
    patching file multi_image_formatter.info.yml
    patching file multi_image_formatter.module
    patching file 'src/Controller/AssetFormatController.php'
    patching file 'src/Plugin/Field/FieldFormatter/MultiImageFormatter.php'
    patching file 'src/Routing/RouteSubscriber.php'
    āžœ  multi_image_formatter git:(1.0.x) āœ— ..
    āžœ  contrib git:(master) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml multi_image_formatter
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/multi_image_formatter/src/Plugin/Field/FieldFormatter/MultiImageFormatter.php
    ------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------------------------------------
     46 | WARNING | Line exceeds 80 characters; contains 106 characters
    ------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/multi_image_formatter/src/Controller/AssetFormatController.php
    ---------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    ---------------------------------------------------------------------------------------------------------------------------------------
     11 | WARNING | [x] Unused use statement
     38 | WARNING | [ ] Line exceeds 80 characters; contains 92 characters
    ---------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/multi_image_formatter/src/Routing/RouteSubscriber.php
    ------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------------
     32 | WARNING | Line exceeds 80 characters; contains 83 characters
    ------------------------------------------------------------------------------------------------------------------------------
    
    Time: 350ms; Memory: 10MB
    
    āžœ  contrib git:(master) āœ— 
    
    
  • Pipeline finished with Success
    3 months ago
    Total: 138s
    #120330
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹

    GitLab CI shows the following errors/warnings.

    FILE: ...dules/custom/multi_image_formatter-3359633/src/Routing/RouteSubscriber.php
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     32 | WARNING | Line exceeds 80 characters; contains 83 characters
        |         | (Drupal.Files.LineLength.TooLong)
    --------------------------------------------------------------------------------
    FILE: ..._formatter-3359633/src/Plugin/Field/FieldFormatter/MultiImageFormatter.php
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     46 | WARNING | Line exceeds 80 characters; contains 106 characters
        |         | (Drupal.Files.LineLength.TooLong)
    --------------------------------------------------------------------------------
    FILE: ...tom/multi_image_formatter-3359633/src/Controller/AssetFormatController.php
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    --------------------------------------------------------------------------------
     11 | WARNING | [x] Unused use statement
        |         |     (Drupal.Classes.UnusedUseStatement.UnusedUse)
     38 | WARNING | [ ] Line exceeds 80 characters; contains 92 characters
        |         |     (Drupal.Files.LineLength.TooLong)
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    Time: 171ms; Memory: 6MB
    

     
     

  • Pipeline finished with Success
    3 months ago
    Total: 139s
    #120333
  • šŸ‡®šŸ‡³India Yashaswi18

    On running the command "phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml,css", found no phpcs errors or warnings remaining.

Production build 0.69.0 2024