Fix the errors/warnings reported by PHP_CodeSniffer

Created on 30 June 2021, almost 3 years ago
Updated 12 March 2024, 3 months ago

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

FILE: ./advanced_settings_options.info.yml
----------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
----------------------------------------------------------------------
 1 | WARNING | [ ] "Description" property is missing in the info.yml
   |         |     file
 4 | ERROR   | [x] Expected 1 newline at end of file; 0 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./advanced_settings_options.install
----------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
----------------------------------------------------------------------
  1 | ERROR | [x] End of line character is invalid; expected "\n" but
    |       |     found "\r\n"
  3 | ERROR | [ ] Missing short description in doc comment
 15 | ERROR | [x] Expected 1 newline at end of file; 0 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


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


FILE: ./advanced_settings_options.module
----------------------------------------------------------------------
FOUND 52 ERRORS AND 8 WARNINGS AFFECTING 35 LINES
----------------------------------------------------------------------
  1 | ERROR   | [x] End of line character is invalid; expected "\n"
    |         |     but found "\r\n"
  3 | ERROR   | [ ] Missing short description in doc comment
  5 | ERROR   | [x] There must be exactly one blank line after the
    |         |     file comment
  9 | WARNING | [ ] Doc comment indicates hook_form_alter() but
    |         |     function signature is
    |         |     "advanced_settings_options_form_entity_form_display_edit_form_alter"
    |         |     instead of
    |         |     "advanced_settings_options_form_alter". Did you
    |         |     mean hook_form_FORM_ID_alter()?
 15 | ERROR   | [x] Whitespace found at end of line
 18 | ERROR   | [x] Whitespace found at end of line
 21 | ERROR   | [x] Spaces must be used to indent lines; tabs are not
    |         |     allowed
 21 | ERROR   | [x] Line indented incorrectly; expected at least 2
    |         |     spaces, found 1
 22 | WARNING | [x] A comma should follow the last multiline array
    |         |     item. Found: false
 22 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected
    |         |     "FALSE" but found "false"
 26 | ERROR   | [x] Spaces must be used to indent lines; tabs are not
    |         |     allowed
 26 | ERROR   | [x] Line indented incorrectly; expected at least 2
    |         |     spaces, found 1
 27 | ERROR   | [x] Spaces must be used to indent lines; tabs are not
    |         |     allowed
 27 | ERROR   | [x] Line indented incorrectly; expected at least 2
    |         |     spaces, found 1
 27 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected
    |         |     "FALSE" but found "false"
 27 | WARNING | [x] A comma should follow the last multiline array
    |         |     item. Found: )
 29 | ERROR   | [x] Whitespace found at end of line
 45 | WARNING | [ ] Doc comment indicates hook_form_alter() but
    |         |     function signature is
    |         |     "advanced_settings_options_form_node_form_alter"
    |         |     instead of
    |         |     "advanced_settings_options_form_alter". Did you
    |         |     mean hook_form_FORM_ID_alter()?
 51 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected
    |         |     "FALSE" but found "false"
 54 | ERROR   | [x] Spaces must be used to indent lines; tabs are not
    |         |     allowed
 54 | ERROR   | [x] Whitespace found at end of line
 57 | ERROR   | [x] Spaces must be used to indent lines; tabs are not
    |         |     allowed
 57 | ERROR   | [x] Line indented incorrectly; expected at least 2
    |         |     spaces, found 1
 57 | WARNING | [x] A comma should follow the last multiline array
    |         |     item. Found: 200
 59 | ERROR   | [x] Whitespace found at end of line
 63 | ERROR   | [x] Spaces must be used to indent lines; tabs are not
    |         |     allowed
 63 | ERROR   | [x] Line indented incorrectly; expected 6 spaces,
    |         |     found 3
 64 | ERROR   | [x] Spaces must be used to indent lines; tabs are not
    |         |     allowed
 64 | ERROR   | [x] Line indented incorrectly; expected 6 spaces,
    |         |     found 3
 65 | ERROR   | [x] Spaces must be used to indent lines; tabs are not
    |         |     allowed
 65 | ERROR   | [x] Line indented incorrectly; expected 6 spaces,
    |         |     found 3
 66 | ERROR   | [x] Spaces must be used to indent lines; tabs are not
    |         |     allowed
 66 | ERROR   | [x] Line indented incorrectly; expected 4 spaces,
    |         |     found 1
 66 | ERROR   | [x] Closing brace indented incorrectly; expected 4
    |         |     spaces, found 1
 68 | ERROR   | [x] Whitespace found at end of line
 72 | WARNING | [x] A comma should follow the last multiline array
    |         |     item. Found: $group_key
 75 | ERROR   | [x] Whitespace found at end of line
 78 | ERROR   | [x] Spaces must be used to indent lines; tabs are not
    |         |     allowed
 78 | ERROR   | [x] Line indented incorrectly; expected at least 2
    |         |     spaces, found 1
 78 | WARNING | [x] A comma should follow the last multiline array
    |         |     item. Found: true
 78 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected
    |         |     "TRUE" but found "true"
 81 | ERROR   | [x] Spaces must be used to indent lines; tabs are not
    |         |     allowed
 81 | ERROR   | [x] Line indented incorrectly; expected 4 spaces,
    |         |     found 1
 82 | ERROR   | [x] Spaces must be used to indent lines; tabs are not
    |         |     allowed
 82 | ERROR   | [x] Line indented incorrectly; expected 6 spaces,
    |         |     found 3
 83 | ERROR   | [x] Spaces must be used to indent lines; tabs are not
    |         |     allowed
 83 | ERROR   | [x] Line indented incorrectly; expected 4 spaces,
    |         |     found 1
 86 | ERROR   | [x] Whitespace found at end of line
 88 | WARNING | [x] A comma should follow the last multiline array
    |         |     item. Found: 'container'
 91 | ERROR   | [x] Spaces must be used to indent lines; tabs are not
    |         |     allowed
 91 | ERROR   | [x] Line indented incorrectly; expected 4 spaces,
    |         |     found 1
 92 | ERROR   | [x] Spaces must be used to indent lines; tabs are not
    |         |     allowed
 92 | ERROR   | [x] Line indented incorrectly; expected 6 spaces,
    |         |     found 3
 93 | ERROR   | [x] Spaces must be used to indent lines; tabs are not
    |         |     allowed
 93 | ERROR   | [x] Whitespace found at end of line
 94 | ERROR   | [x] Spaces must be used to indent lines; tabs are not
    |         |     allowed
 94 | ERROR   | [x] Line indented incorrectly; expected 4 spaces,
    |         |     found 1
 94 | ERROR   | [x] Whitespace found at end of line
 97 | ERROR   | [x] Whitespace found at end of line
 99 | ERROR   | [x] Expected 1 newline at end of file; 0 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 57 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./css/default.css
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but
   |       |     found "\r\n"
 6 | ERROR | [x] Expected 1 newline at end of file; 0 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 133ms; Memory: 6MB
๐Ÿ“Œ Task
Status

RTBC

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia vipin.mittal18 Greater Noida

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

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ท๐Ÿ‡บRussia zniki.ru
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Status changed to Needs work 5 months ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines clarkssquared

    Hi

    I applied patch #2 and I confirmed that it fixes most of the PHPCS issues, but there is one PHPCS issues in the module

    โžœ  advanced_settings_options git:(1.0.x) curl https://www.drupal.org/files/issues/2021-06-30/drupal8_coding_practices-3221492-2.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  8572  100  8572    0     0   9163      0 --:--:-- --:--:-- --:--:--  9237
    patching file advanced_settings_options.info.yml
    patching file advanced_settings_options.install
    patching file advanced_settings_options.libraries.yml
    patching file advanced_settings_options.module
    patching file 'css/default.css'
    โžœ  advanced_settings_options git:(1.0.x) โœ— ..
    โžœ  contrib git:(master) โœ— 
    phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml advanced_settings_options
    
    FILE: ...rksubing-subing/Projects/d9/d9-local/web/modules/contrib/advanced_settings_options/advanced_settings_options.info.yml
    ---------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------------
     1 | WARNING | "Description" property is missing in the info.yml file
    ---------------------------------------------------------------------------------------------------------------------------
    
    Time: 198ms; Memory: 10MB
    
    โžœ  contrib git:(master) โœ— 

    hence I will move this to needs work

  • Assigned to nitin_lama
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama

    Providing updated patch.

  • Status changed to Needs review 5 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama

    Please review.

  • Issue was unassigned.
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    What reported in comment #8 has been already fixed from MR !2 before that comment was posted.

  • Status changed to Needs work 5 months ago
  • ๐Ÿ‡ท๐Ÿ‡บRussia zniki.ru

    Thanks everyone, let's continue with MR workflow.
    I see there are tons of violations in MR 2, please run phpcs and fix all the violations.

  • Shruu_rao โ†’ made their first commit to this issueโ€™s fork.

  • Pipeline finished with Success
    3 months ago
    Total: 143s
    #117453
  • Status changed to RTBC 3 months ago
Production build 0.69.0 2024