Fix the errors/warnings reported by Php_CodeSniffer

Created on 5 July 2023, over 1 year ago

Problem/Motivation

PHPCS gives the following errors:

C:\xampp\htdocs\backendassignment\web\modules\contrib>phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig smartmenus
FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\smartmenus\smartmenus.install
------------------------------------------------------------------------------------------
FOUND 5 ERRORS AND 2 WARNINGS AFFECTING 5 LINES
------------------------------------------------------------------------------------------
  1 | ERROR   | [x] Missing file doc comment
  1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
  4 | ERROR   | [x] Doc comment short description must start with a capital letter
  4 | ERROR   | [x] Doc comment short description must end with a full stop
 19 | WARNING | [x] A comma should follow the last multiline array item. Found: $severity
 20 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
 23 | ERROR   | [x] Expected 1 newline at end of file; 2 found
------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\smartmenus\smartmenus.module
----------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 6 WARNINGS AFFECTING 9 LINES
----------------------------------------------------------------------------------------
  1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
 24 | ERROR   | [x] Expected 1 blank line after function; 2 found
 35 | WARNING | [x] A comma should follow the last multiline array item. Found: NULL
 36 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
 44 | WARNING | [x] A comma should follow the last multiline array item. Found: NULL
 45 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
 48 | ERROR   | [x] Empty array declaration must have no space between the parentheses
 50 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
 51 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
----------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 9 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\smartmenus\src\Form\SmartmenusSettingsForm.php
---------------------------------------------------------------------------------------------------------------------
FOUND 14 ERRORS AND 2 WARNINGS AFFECTING 13 LINES
---------------------------------------------------------------------------------------------------------------------
  1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
 13 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
 16 | ERROR   | [ ] Missing short description in doc comment
 17 | ERROR   | [x] Data types in @var tags need to be fully namespaced
 21 | ERROR   | [ ] Parameter $smartmenusUtil is not described in comment
 23 | ERROR   | [x] There must be exactly one blank line before the tags in a doc comment
 23 | ERROR   | [ ] Missing parameter comment
 23 | ERROR   | [x] Data types in @param tags need to be fully namespaced
 26 | ERROR   | [x] Opening brace should be on the same line as the declaration
 57 | ERROR   | [x] Expected 1 blank line after function; 2 found
 60 | ERROR   | [ ] Missing short description in doc comment
 61 | ERROR   | [ ] Description for the @return value is missing
 72 | ERROR   | [x] Short array syntax must be used to define arrays
 77 | ERROR   | [x] Short array syntax must be used to define arrays
 82 | WARNING | [x] A comma should follow the last multiline array item. Found: true
 82 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
---------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 10 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\smartmenus\src\Plugin\Block\SmartMenusBlock.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 43 ERRORS AND 6 WARNINGS AFFECTING 39 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
   1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
  50 | ERROR   | [x] There must be exactly one blank line before the tags in a doc comment
  50 | ERROR   | [x] Data types in @var tags need to be fully namespaced
  56 | ERROR   | [x] There must be exactly one blank line before the tags in a doc comment
  56 | ERROR   | [ ] Missing parameter comment
  57 | ERROR   | [ ] Missing parameter comment
  57 | ERROR   | [ ] Missing parameter type
  58 | ERROR   | [ ] Missing parameter comment
  58 | ERROR   | [ ] Missing parameter type
  59 | ERROR   | [ ] Missing parameter comment
  59 | ERROR   | [x] Data types in @param tags need to be fully namespaced
  60 | ERROR   | [ ] Missing parameter comment
  60 | ERROR   | [x] Data types in @param tags need to be fully namespaced
  61 | ERROR   | [ ] Missing parameter comment
  61 | ERROR   | [x] Data types in @param tags need to be fully namespaced
  75 | ERROR   | [x] Inline comments must start with a capital letter
  75 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
  97 | ERROR   | [x] Empty array declaration must have no space between the parentheses
 109 | ERROR   | [x] Short array syntax must be used to define arrays
 113 | ERROR   | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
 115 | ERROR   | [x] Short array syntax must be used to define arrays
 119 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 121 | WARNING | [x] A comma should follow the last multiline array item. Found: TRUE
 124 | ERROR   | [x] Short array syntax must be used to define arrays
 130 | ERROR   | [x] Short array syntax must be used to define arrays
 133 | ERROR   | [x] Short array syntax must be used to define arrays
 140 | ERROR   | [x] Short array syntax must be used to define arrays
 145 | WARNING | [x] A comma should follow the last multiline array item. Found: true
 145 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
 162 | ERROR   | [ ] Missing short description in doc comment
 163 | ERROR   | [ ] Description for the @return value is missing
 173 | ERROR   | [x] You must use "/**" style comments for a function comment
 177 | ERROR   | [ ] Missing short description in doc comment
 179 | ERROR   | [x] Return comment indentation must be 3 spaces, found 1 spaces
 185 | ERROR   | [ ] Missing short description in doc comment
 187 | ERROR   | [x] Return comment indentation must be 3 spaces, found 1 spaces
 193 | ERROR   | [ ] Missing short description in doc comment
 195 | ERROR   | [x] Return comment indentation must be 3 spaces, found 1 spaces
 201 | ERROR   | [ ] Missing short description in doc comment
 203 | ERROR   | [x] Return comment indentation must be 3 spaces, found 1 spaces
 206 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 208 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
 208 | ERROR   | [x] Expected 1 space after "?"; 2 found
 227 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 236 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
 239 | WARNING | [x] A comma should follow the last multiline array item. Found: 'smartmenus_toggle'
 249 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
 262 | ERROR   | [x] Expected 1 blank line after function; 0 found
 263 | ERROR   | [x] The closing brace for the class must have an empty line before it
----------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 33 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\smartmenus\src\SmartmenusUtil.php
---------------------------------------------------------------------------------------------------------------------
FOUND 15 ERRORS AND 1 WARNING AFFECTING 14 LINES
---------------------------------------------------------------------------------------------------------------------
  1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
  8 | ERROR   | [x] Doc comment short description must end with a full stop
  9 | ERROR   | [x] There must be exactly one blank line before the tags in a doc comment
 10 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
 13 | ERROR   | [ ] Missing short description in doc comment
 14 | ERROR   | [x] Data types in @var tags need to be fully namespaced
 20 | ERROR   | [x] There must be exactly one blank line before the tags in a doc comment
 20 | ERROR   | [ ] Missing parameter comment
 20 | ERROR   | [x] Data types in @param tags need to be fully namespaced
 23 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 6
 26 | ERROR   | [ ] Missing short description in doc comment
 28 | ERROR   | [x] Return comment indentation must be 3 spaces, found 1 spaces
 40 | ERROR   | [ ] Missing short description in doc comment
 41 | ERROR   | [ ] Description for the @return value is missing
 45 | ERROR   | [x] Expected 1 blank line after function; 0 found
 46 | ERROR   | [x] The closing brace for the class must have an empty line before it
---------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 10 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Needs work

Version

2.0

Component

Code

Created by

🇮🇳India sidharth_soman Bangalore

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

Comments & Activities

  • Issue created by @sidharth_soman
  • @sidharth_soman opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India sidharth_soman Bangalore

    I have fixed the issues, but left out the ones related to filling out/editing documentation. Those should ideally be resolved by the maintainers themselves.

    Please review the MR

  • Status changed to Needs work 25 days ago
  • 🇮🇳India supriyak

    Hi,

    After patch application still there are so many errors/warnings. So, moving this to 'Needs Work'.

    Thanks!

Production build 0.71.5 2024