Fix the errors/warnings reported by PHP_CodeSniffer

Created on 25 January 2024, 10 months ago
Updated 26 January 2024, 10 months ago

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

I avoided to check the .css files since they are dynamically generated from https://git.drupalcode.org/issue/y_donate-3373804/-/blob/3373804-fix-the....

FILE: ./README.md
----------------------------------------------------------------------
FOUND 0 ERRORS AND 6 WARNINGS AFFECTING 6 LINES
----------------------------------------------------------------------
  3 | WARNING | Line exceeds 80 characters; contains 127 characters
 11 | WARNING | Line exceeds 80 characters; contains 179 characters
 21 | WARNING | Line exceeds 80 characters; contains 97 characters
 26 | WARNING | Line exceeds 80 characters; contains 188 characters
 32 | WARNING | Line exceeds 80 characters; contains 129 characters
 38 | WARNING | Line exceeds 80 characters; contains 114 characters
----------------------------------------------------------------------


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


FILE: ./modules/lb_donate/lb_donate.install
----------------------------------------------------------------------
FOUND 9 ERRORS AND 4 WARNINGS AFFECTING 13 LINES
----------------------------------------------------------------------
   5 | ERROR   | [x] Function comment short description must start
     |         |     with exactly one space
   9 | ERROR   | [x] There must be one blank line after the last USE
     |         |     statement; 2 found;
  15 | ERROR   | [x] Expected 1 blank line before function; 2 found
  75 | WARNING | [ ] Line exceeds 80 characters; contains 83
     |         |     characters
  86 | WARNING | [x] A comma should follow the last multiline array
     |         |     item. Found: ]
  95 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected
     |         |     "TRUE" but found "true"
 102 | ERROR   | [x] Inline comments must end in full-stops,
     |         |     exclamation marks, question marks, colons, or
     |         |     closing parentheses
 126 | ERROR   | [x] Doc comment short description must end with a
     |         |     full stop
 160 | WARNING | [x] A comma should follow the last multiline array
     |         |     item. Found: 'field_giving_amount'
 161 | WARNING | [x] A comma should follow the last multiline array
     |         |     item. Found: ]
 164 | ERROR   | [x] Inline comments must end in full-stops,
     |         |     exclamation marks, question marks, colons, or
     |         |     closing parentheses
 176 | ERROR   | [x] Doc comment short description must end with a
     |         |     full stop
 186 | ERROR   | [x] Expected 1 newline at end of file; 2 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 12 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./modules/lb_donate/lb_donate.module
----------------------------------------------------------------------
FOUND 5 ERRORS AND 1 WARNING AFFECTING 6 LINES
----------------------------------------------------------------------
  21 | WARNING | [x] A comma should follow the last multiline array
     |         |     item. Found: ]
  28 | ERROR   | [x] Expected 1 space before opening brace; found 0
  32 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected
     |         |     "NULL" but found "null"
  39 | ERROR   | [x] PHP keywords must be lowercase; expected
     |         |     "instanceof" but found "instanceOf"
  45 | ERROR   | [x] PHP keywords must be lowercase; expected
     |         |     "instanceof" but found "instanceOf"
 118 | ERROR   | [x] Expected 1 newline at end of file; 2 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Plugin/Block/DonateFormBlock.php
----------------------------------------------------------------------
FOUND 5 ERRORS AND 2 WARNINGS AFFECTING 7 LINES
----------------------------------------------------------------------
  5 | ERROR   | [x] Non-namespaced classes/interfaces/traits should
    |         |     not be referenced with use statements
 42 | WARNING | [ ] \Drupal calls should be avoided in classes, use
    |         |     dependency injection instead
 43 | WARNING | [x] A comma should follow the last multiline array
    |         |     item. Found: ]
 91 | ERROR   | [ ] Doc comment short description must be on a single
    |         |     line, further text should be a separate paragraph
 93 | ERROR   | [ ] Description for the @return value is missing
 96 | ERROR   | [x] Opening brace should be on the same line as the
    |         |     declaration
 97 | ERROR   | [x] Short array syntax must be used to define arrays
----------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./y_donate.module
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 20 | WARNING | [x] A comma should follow the last multiline array
    |         |     item. Found: ''
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 111ms; Memory: 6MB
šŸ“Œ Task
Status

Needs review

Version

2.0

Component

Code

Created by

šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @apaderno
  • Status changed to Needs review 10 months ago
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹

    I fixed almost all the warnings/errors.

  • Status changed to Needs work 10 months ago
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹

    (Actually, the status must be Needs work, since there should be a couple of warnings/errors to fix.)

  • First commit to issue fork.
  • šŸ‡®šŸ‡³India sakthi_dev

    FIxed everything except Drupal Call.

  • Status changed to Needs review 10 months ago
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • Status changed to Needs work 10 months ago
  • šŸ‡µšŸ‡­Philippines clarkssquared

    Hi

    I applied the MR !10 in my local and I noticed that there are still many PHPCS issues being reported

    āžœ  y_donate git:(2.0.x) curl https://git.drupalcode.org/project/y_donate/-/merge_requests/10.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 13769    0 13769    0     0  25553      0 --:--:-- --:--:-- --:--:-- 25833
    patching file README.md
    patching file 'modules/lb_donate/lb_donate.info.yml'
    patching file 'modules/lb_donate/lb_donate.install'
    patching file 'modules/lb_donate/lb_donate.module'
    patching file 'src/Plugin/Block/DonateFormBlock.php'
    patching file y_donate.module
    āžœ  y_donate git:(2.0.x) āœ— ..
    āžœ  contrib git:(master) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml y_donate 
    
    FILE: .../d9-local/web/modules/contrib/y_donate/modules/lb_donate/lb_donate.install
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     74 | WARNING | Line exceeds 80 characters; contains 83 characters
    --------------------------------------------------------------------------------
    
    
    FILE: ...al/web/modules/contrib/y_donate/modules/lb_donate/assets/css/lb-donate.css
    --------------------------------------------------------------------------------
    FOUND 125 ERRORS AFFECTING 99 LINES
    --------------------------------------------------------------------------------
       2 | ERROR | [x] CSS colours must be defined in lowercase; expected #4f4f4f
         |       |     but found #4F4F4F
       3 | ERROR | [x] Closing brace of class definition must be on new line
      12 | ERROR | [x] CSS colours must be defined in lowercase; expected #4f4f4f
         |       |     but found #4F4F4F
      13 | ERROR | [x] Closing brace of class definition must be on new line
      14 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 2
      15 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
      15 | ERROR | [x] Closing brace of class definition must be on new line
      16 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 4
      17 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
      18 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
      19 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
      20 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
      21 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
      22 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
      23 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
      24 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
      25 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
      25 | ERROR | [x] Closing brace of class definition must be on new line
      26 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 2
      27 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
      28 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
      29 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
      30 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
      31 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
      32 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
      33 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
      33 | ERROR | [x] Closing brace of class definition must be on new line
      34 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 4
      35 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
      36 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
      37 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
      37 | ERROR | [x] Closing brace of class definition must be on new line
      38 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 4
      39 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
      40 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
      41 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
      42 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
      43 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
      44 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
      44 | ERROR | [x] Closing brace of class definition must be on new line
      45 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 6
      46 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
      47 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 10
      48 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 10
      49 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 10
      49 | ERROR | [x] Closing brace of class definition must be on new line
      50 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 2
      51 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
      52 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
      52 | ERROR | [x] Closing brace of class definition must be on new line
      53 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 2
      54 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
      55 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
      56 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
      57 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
      58 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
      58 | ERROR | [x] Closing brace of class definition must be on new line
      59 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 4
      60 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
      61 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
      62 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
      63 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
      64 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
      64 | ERROR | [x] Closing brace of class definition must be on new line
      65 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 2
      66 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
      66 | ERROR | [x] Closing brace of class definition must be on new line
      67 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 4
      68 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
      69 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
      69 | ERROR | [x] Closing brace of class definition must be on new line
      70 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 6
      71 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
      72 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 10
      73 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 10
      73 | ERROR | [x] Closing brace of class definition must be on new line
      74 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 4
      75 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
      76 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
      76 | ERROR | [x] Closing brace of class definition must be on new line
      77 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 2
      78 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
      79 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
      80 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
      81 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
      81 | ERROR | [x] Closing brace of class definition must be on new line
      82 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 2
      83 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
      84 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
      85 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
      86 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
      87 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
      88 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
      88 | ERROR | [x] Closing brace of class definition must be on new line
      89 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 4
      90 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
      91 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
      92 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
      93 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
      93 | ERROR | [x] Closing brace of class definition must be on new line
      94 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 4
      95 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
      95 | ERROR | [x] CSS colours must be defined in lowercase; expected #4f4f4f
         |       |     but found #4F4F4F
      96 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
      97 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
      97 | ERROR | [x] CSS colours must be defined in lowercase; expected #4f4f4f
         |       |     but found #4F4F4F
      97 | ERROR | [x] Closing brace of class definition must be on new line
      98 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 6
      99 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
     100 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
     100 | ERROR | [x] CSS colours must be defined in lowercase; expected #4f4f4f
         |       |     but found #4F4F4F
     100 | ERROR | [x] Closing brace of class definition must be on new line
     101 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 2
     102 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
     103 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
     103 | ERROR | [x] CSS colours must be defined in lowercase; expected #4f4f4f
         |       |     but found #4F4F4F
     104 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
     104 | ERROR | [x] CSS colours must be defined in lowercase; expected #4f4f4f
         |       |     but found #4F4F4F
     104 | ERROR | [x] Closing brace of class definition must be on new line
     105 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 4
     106 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
     106 | ERROR | [x] CSS colours must be defined in lowercase; expected #4f4f4f
         |       |     but found #4F4F4F
     107 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
     107 | ERROR | [x] Closing brace of class definition must be on new line
     109 | ERROR | [x] Expected 1 newline at end of file; 0 found
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 125 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    
    FILE: ...d9-local/web/modules/contrib/y_donate/src/Plugin/Block/DonateFormBlock.php
    --------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     31 | ERROR | Parameter $module_handler is not described in comment
     31 | ERROR | Parameter $route_match is not described in comment
    --------------------------------------------------------------------------------
    
    Time: 306ms; Memory: 10MB
    
    āžœ  contrib git:(master) āœ— 
    
  • šŸ‡µšŸ‡­Philippines clarkssquared

    the css errors can be ignored since it was mentioned in the issue's description?

  • Status changed to Needs review 10 months ago
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹

    The issue summary explains why the .css files are ignored: They are automatically generated. One of the project maintainers already made clear they will not correct them.

    I avoided to check the .css files since they are dynamically generated from https://git.drupalcode.org/issue/y_donate-3373804/-/blob/3373804-fix-the....

    I did not change the short description of the update hook because it is not possible to short Migrate content from 'lb_donate_giving_amount' paragraph to 'donate_item' block. which must still be written on a single line (since it is a short description).

Production build 0.71.5 2024