Fix the warnings/errors reported by PHP_CodeSniffer

Created on 7 July 2023, about 1 year ago
Updated 21 August 2024, about 1 month ago

Problem/Motivation

FILE: /home/lenovo/druapl7to9/web/modules/contrib/keyboard_shortcuts/src/Form/KeyboardShortcutsSettingsForm.php
-------------------------------------------------------------------------------------------------------------------------------
FOUND 42 ERRORS AND 13 WARNINGS AFFECTING 45 LINES
-------------------------------------------------------------------------------------------------------------------------------
   9 | ERROR   | [x] Missing class doc comment
  30 | ERROR   | [ ] Description for the @return value is missing
  62 | WARNING | [ ] Role::loadMultiple calls should be avoided in classes, use dependency injection instead
  63 | ERROR   | [x] Expected 1 space after FUNCTION keyword; 0 found
  68 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
  89 | ERROR   | [x] Short array syntax must be used to define arrays
  93 | WARNING | [x] A comma should follow the last multiline array item. Found: )
  96 | ERROR   | [x] Short array syntax must be used to define arrays
 101 | WARNING | [x] A comma should follow the last multiline array item. Found: true
 101 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
 104 | ERROR   | [x] Short array syntax must be used to define arrays
 109 | WARNING | [x] A comma should follow the last multiline array item. Found: true
 109 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
 112 | ERROR   | [x] Short array syntax must be used to define arrays
 121 | ERROR   | [x] Short array syntax must be used to define arrays
 129 | ERROR   | [x] Short array syntax must be used to define arrays
 136 | ERROR   | [x] Short array syntax must be used to define arrays
 143 | ERROR   | [x] Short array syntax must be used to define arrays
 149 | WARNING | [x] A comma should follow the last multiline array item. Found: true
 149 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
 152 | ERROR   | [x] Short array syntax must be used to define arrays
 156 | WARNING | [x] A comma should follow the last multiline array item. Found: )
 161 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 162 | ERROR   | [x] Short array syntax must be used to define arrays
 166 | ERROR   | [x] Short array syntax must be used to define arrays
 167 | WARNING | [ ] #options values usually have to run through t() for translation
 168 | WARNING | [ ] #options values usually have to run through t() for translation
 169 | WARNING | [ ] #options values usually have to run through t() for translation
 173 | ERROR   | [x] Concat operator must be surrounded by a single space
 173 | ERROR   | [x] Concat operator must be surrounded by a single space
 177 | ERROR   | [x] Short array syntax must be used to define arrays
 184 | ERROR   | [x] Concat operator must be surrounded by a single space
 184 | ERROR   | [x] Concat operator must be surrounded by a single space
 190 | ERROR   | [x] Short array syntax must be used to define arrays
 197 | ERROR   | [x] Concat operator must be surrounded by a single space
 197 | ERROR   | [x] Concat operator must be surrounded by a single space
 199 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
 206 | ERROR   | [x] Short array syntax must be used to define arrays
 213 | ERROR   | [x] Concat operator must be surrounded by a single space
 213 | ERROR   | [x] Concat operator must be surrounded by a single space
 226 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
 244 | WARNING | [ ] Only string literals should be passed to t() where possible
 244 | WARNING | [x] A comma should follow the last multiline array item. Found: )
 259 | ERROR   | [x] There should be no white space before a closing ")"
 259 | ERROR   | [x] Expected 0 spaces before closing parenthesis; 1 found
 267 | ERROR   | [x] Expected 1 space after FUNCTION keyword; 0 found
 275 | ERROR   | [x] Expected 1 space after FOREACH keyword; 0 found
 282 | ERROR   | [x] Expected 1 space after comma in argument list; 2 found
 282 | ERROR   | [x] Expected one space after the comma, 2 found
 298 | ERROR   | [x] Missing function doc comment
 306 | ERROR   | [x] Missing function doc comment
 310 | ERROR   | [x] Missing function doc comment
 320 | ERROR   | [x] Missing function doc comment
 335 | ERROR   | [x] Expected 1 blank line after function; 0 found
 336 | ERROR   | [x] The closing brace for the class must have an empty line before it
-------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 49 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------


FILE: /home/lenovo/druapl7to9/web/modules/contrib/keyboard_shortcuts/README.md
------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
------------------------------------------------------------------------------
  3 | WARNING | Line exceeds 80 characters; contains 107 characters
 17 | WARNING | Line exceeds 80 characters; contains 94 characters
------------------------------------------------------------------------------


FILE: /home/lenovo/druapl7to9/web/modules/contrib/keyboard_shortcuts/keyboard_shortcuts.module
----------------------------------------------------------------------------------------------------------------------------------
FOUND 8 ERRORS AND 3 WARNINGS AFFECTING 8 LINES
----------------------------------------------------------------------------------------------------------------------------------
  4 | ERROR   | [x] The second line in the file doc comment must be "@file"
 20 | ERROR   | [x] Expected 1 space before "="; 0 found
 20 | ERROR   | [x] Expected 1 space after "="; 0 found
 44 | WARNING | [ ] Only string literals should be passed to t() where possible
 46 | WARNING | [x] A comma should follow the last multiline array item. Found: '/admin/config/user-interface/keyboard-shortcuts'
 54 | WARNING | [ ] Hook implementations should not duplicate @param documentation
 54 | ERROR   | [ ] Missing parameter comment
 54 | ERROR   | [ ] Missing parameter type
 66 | ERROR   | [x] There should be no white space after an opening "("
 75 | ERROR   | [x] Expected 1 space after FUNCTION keyword; 0 found
 77 | ERROR   | [x] Expected 1 space after FUNCTION keyword; 0 found
----------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------

Time: 105ms; Memory: 12MB

Steps to reproduce

Execute the command: phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig keyboard_shortcuts/

Proposed resolution

Remaining tasks

FILE: ...enovo/d7to9/web/modules/contrib/keyboard_shortcuts-3373061/src/Form/KeyboardShortcutsSettingsForm.php
-----------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
-----------------------------------------------------------------------------------------------------------
  65 | ERROR   | Description for the @return value is missing
 280 | WARNING | Only string literals should be passed to t() where possible
-----------------------------------------------------------------------------------------------------------


FILE: /home/lenovo/d7to9/web/modules/contrib/keyboard_shortcuts-3373061/README.md
---------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
---------------------------------------------------------------------------------
  3 | WARNING | Line exceeds 80 characters; contains 107 characters
 17 | WARNING | Line exceeds 80 characters; contains 94 characters
---------------------------------------------------------------------------------


FILE: /home/lenovo/d7to9/web/modules/contrib/keyboard_shortcuts-3373061/keyboard_shortcuts.module
-------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------
  7 | ERROR   | Parameter tags must be defined first in a doc comment
 45 | WARNING | Only string literals should be passed to t() where possible
-------------------------------------------------------------------------------------------------

Time: 103ms; Memory: 12MB

User interface changes

API changes

Data model changes

šŸ“Œ Task
Status

Needs work

Version

1.1

Component

Code

Created by

šŸ‡®šŸ‡³India roshni27

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

  • Issue created by @roshni27
  • @roshni27 opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • šŸ‡®šŸ‡³India roshni27

    Some issues which are better know to maintainer are pending, for reading purpose character limits issues remain and all remaining issues solve by me. Please review the MR.

  • Status changed to Needs work about 1 month ago
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi @roshni27,

    I applied MR!3, it was applied smoothly and fixed most of the phpcs issues.

    These are the remaining issues after I ran phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml:

    āžœ  keyboard_shortcuts git:(1.1.0) curl https://git.drupalcode.org/project/keyboard_shortcuts/-/merge_requests/3.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 13956    0 13956    0     0  32694      0 --:--:-- --:--:-- --:--:-- 32760
    patching file keyboard_shortcuts.module
    patching file keyboard_shortcuts.services.yml
    patching file src/Form/KeyboardShortcutsSettingsForm.php
    āžœ  keyboard_shortcuts git:(1.1.0) āœ— ..
    āžœ  contrib phpcs --standard="Drupal,DrupalPractice" --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml,css,js keyboard_shortcuts
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/keyboard_shortcuts/keyboard_shortcuts.info.yml
    -------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------
     8 | WARNING | All dependencies must be prefixed with the project name, for example "drupal:"
    -------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/keyboard_shortcuts/js/keyboard_shortcuts.js
    ----------------------------------------------------------------------------------------------------------------
    FOUND 13 ERRORS AFFECTING 10 LINES
    ----------------------------------------------------------------------------------------------------------------
      1 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
     16 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
     27 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
     46 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
     57 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
     57 | ERROR | [x] Expected 1 space before opening brace; found 0
     59 | ERROR | [x] Expected 1 space after "&" operator; 0 found
     59 | ERROR | [x] Expected 1 space before "="; 0 found
     69 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
     72 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
     79 | ERROR | [x] Expected 1 space before "==="; 0 found
     79 | ERROR | [x] Expected 1 space after "==="; 0 found
     80 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
    ----------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 13 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/keyboard_shortcuts/README.md
    -------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    -------------------------------------------------------------------------------------------------
      3 | WARNING | Line exceeds 80 characters; contains 107 characters
     17 | WARNING | Line exceeds 80 characters; contains 94 characters
    -------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/keyboard_shortcuts/keyboard_shortcuts.module
    -----------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
    -----------------------------------------------------------------------------------------------------------------
      7 | ERROR   | Parameter tags must be defined first in a doc comment
     45 | WARNING | Only string literals should be passed to t() where possible
    -----------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/keyboard_shortcuts/src/Form/KeyboardShortcutsSettingsForm.php
    ----------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
    ----------------------------------------------------------------------------------------------------------------------------------
      65 | ERROR   | Description for the @return value is missing
     280 | WARNING | Only string literals should be passed to t() where possible
    ----------------------------------------------------------------------------------------------------------------------------------
    
    Time: 182ms; Memory: 12MB
    
    āžœ  contrib

    Thank you.

Production build 0.71.5 2024