Drupal Coding Standards Issues | phpcs

Created on 23 January 2023, about 2 years ago
Updated 23 June 2023, almost 2 years ago

Problem/Motivation

Getting following error/warnings.

FILE: /var/www/html/modules/contrib/block_inactive_users/block_inactive_users.install
------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 1 WARNING AFFECTING 4 LINES
------------------------------------------------------------------------------------------------------------------------
17 | ERROR | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
28 | ERROR | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
38 | WARNING | [x] A comma should follow the last multiline array item. Found: "block_inactive_users_exclude_roles"
47 | ERROR | [x] Expected 1 newline at end of file; 0 found
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/block_inactive_users/block_inactive_users.links.task.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: /var/www/html/modules/contrib/block_inactive_users/block_inactive_users.module
-------------------------------------------------------------------------------------------------------------------------------
FOUND 13 ERRORS AND 1 WARNING AFFECTING 10 LINES
-------------------------------------------------------------------------------------------------------------------------------
58 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
102 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
103 | ERROR | [x] Expected 1 space between comma and "'1'"; 0 found
103 | ERROR | [x] Expected one space after the comma, 0 found
137 | ERROR | [x] There should be no white space after an opening "("
137 | ERROR | [x] There should be no white space before a closing ")"
138 | ERROR | [ ] sizeof() is a function name alias, use count() instead
139 | ERROR | [x] Expected newline after closing brace
139 | ERROR | [x] There should be no white space after an opening "("
139 | ERROR | [x] There should be no white space before a closing ")"
149 | ERROR | [x] There should be no white space after an opening "("
154 | WARNING | [ ] Line exceeds 80 characters; contains 81 characters
159 | ERROR | [x] There should be no white space after an opening "("
165 | ERROR | [x] There should be no white space after an opening "("
-------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 12 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/block_inactive_users/config/schema/block_inactive_users.schema.yml
------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------
59 | ERROR | [x] Expected 1 newline at end of file; 0 found
------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/block_inactive_users/tests/src/Kernel/BlockUsersTest.php
--------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------------------
39 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
--------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/block_inactive_users/README.md
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
40 | WARNING | Line exceeds 80 characters; contains 82 characters
44 | WARNING | Line exceeds 80 characters; contains 81 characters
----------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/block_inactive_users/src/Form/SettingsForm.php
-------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 1 WARNING AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------------------------------------
15 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
128 | ERROR | [x] Inline comments must start with a capital letter
128 | 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: /var/www/html/modules/contrib/block_inactive_users/src/Form/ConfirmCancelUsersForm.php
--------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES
--------------------------------------------------------------------------------------------
7 | ERROR | [x] There must be one blank line after the last USE statement; 2 found;
51 | WARNING | [ ] Only string literals should be passed to t() where possible
59 | ERROR | [x] Expected 1 blank line after function; 2 found
--------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/block_inactive_users/src/Form/SettingsCancelUsersForm.php
----------------------------------------------------------------------------------------------------------------------
FOUND 8 ERRORS AND 1 WARNING AFFECTING 9 LINES
----------------------------------------------------------------------------------------------------------------------
16 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
105 | ERROR | [ ] sizeof() is a function name alias, use count() instead
138 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 5
139 | ERROR | [x] Array indentation error, expected 7 spaces but found 6
140 | ERROR | [x] Array indentation error, expected 7 spaces but found 6
141 | ERROR | [x] Array indentation error, expected 7 spaces but found 6
142 | ERROR | [x] Array indentation error, expected 7 spaces but found 6
148 | ERROR | [x] Array indentation error, expected 7 spaces but found 6
149 | ERROR | [x] Array closing indentation error, expected 5 spaces but found 4
----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/block_inactive_users/src/InactiveUsersHandler.php
---------------------------------------------------------------------------------------------------------------------------------------------
FOUND 10 ERRORS AND 1 WARNING AFFECTING 10 LINES
---------------------------------------------------------------------------------------------------------------------------------------------
19 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
210 | ERROR | [x] Use null coalesce operator instead of ternary operator.
211 | ERROR | [ ] The array declaration extends to column 101 (the limit is 80). The array content should be split up over multiple lines
220 | ERROR | [ ] Parameter $disable_account_method is not described in comment
227 | ERROR | [x] Parameter comment indentation must be 3 spaces, found 1 spaces
232 | ERROR | [x] Expected 0 spaces after opening parenthesis; 1 found
232 | ERROR | [x] There should be no white space after an opening "("
233 | ERROR | [x] Opening brace should be on the same line as the declaration
234 | ERROR | [x] Short array syntax must be used to define arrays
238 | ERROR | [x] Expected 1 blank line after function; 0 found
239 | ERROR | [x] The closing brace for the class must have an empty line before it
---------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/block_inactive_users/src/Controller/ReactivateUserController.php
-----------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------
20 | WARNING | The class short comment should describe what the class does and not simply repeat the class name
-----------------------------------------------------------------------------------------------------------------

Time: 1.72 secs; Memory: 6MB

Steps to reproduce

Run following command

phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml modules/contrib/block_inactive_users/

Proposed resolution

Above error/warnings need to be fixed.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇮🇳India samit.310@gmail.com

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

Comments & Activities

Production build 0.71.5 2024