Drupal Coding Standards Issues | phpcs

Created on 17 February 2023, about 2 years ago
Updated 30 July 2024, 8 months ago

Problem/Motivation

Getting following error/warnings.

FILE: /var/www/html/modules/contrib/add_content_modal/add_content_modal.module
---------------------------------------------------------------------------------------------------------------------------------------------
FOUND 18 ERRORS AND 3 WARNINGS AFFECTING 16 LINES
---------------------------------------------------------------------------------------------------------------------------------------------
63 | WARNING | [ ] Line exceeds 80 characters; contains 83 characters
65 | WARNING | [ ] Line exceeds 80 characters; contains 112 characters
65 | ERROR | [ ] Comment indentation error, expected only 1 spaces
72 | ERROR | [ ] Missing parameter comment
73 | ERROR | [ ] Missing parameter comment
75 | ERROR | [ ] Description for the @return value is missing
77 | ERROR | [x] Namespaced classes/interfaces/traits should be referenced with use statements
81 | ERROR | [x] Space found before square bracket; expected "][" but found "] ["
155 | WARNING | [x] A comma should follow the last multiline array item. Found: 'entity.node.canonical'
236 | ERROR | [x] Each PHP statement must be on a line by itself
244 | ERROR | [ ] Missing parameter comment
244 | ERROR | [ ] Missing parameter type
246 | ERROR | [ ] @return doc comment specified, but function has no return statement
246 | ERROR | [ ] Description for the @return value is missing
263 | ERROR | [x] Array indentation error, expected 8 spaces but found 9
312 | ERROR | [ ] Missing parameter comment
312 | ERROR | [ ] Missing parameter type
313 | ERROR | [ ] Missing parameter comment
313 | ERROR | [ ] Missing parameter type
315 | ERROR | [ ] Description for the @return value is missing
317 | ERROR | [ ] Invalid function name, expected _add_content_modal_process_node_x_form but found _add_content_modal_process_node_X_form
---------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/add_content_modal/src/Form/SettingsForm.php
-----------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 15 ERRORS AND 3 WARNINGS AFFECTING 12 LINES
-----------------------------------------------------------------------------------------------------------------------------------------------------------
74 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 0
74 | ERROR | [x] 4 spaces found before inline comment; expected "// $form['allowed_operations'] = [" but found "// $form['allowed_operations'] = ["
75 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 0
75 | ERROR | [ ] Comment indentation error, expected only 4 spaces
76 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 0
77 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 0
78 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 0
78 | ERROR | [ ] Comment indentation error, expected only 6 spaces
79 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 0
80 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 0
81 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 0
82 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 0
83 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 0
84 | WARNING | [x] There must be no blank line following an inline comment
84 | WARNING | [ ] There must be no blank line following an inline comment
84 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 0
134 | WARNING | [ ] Line exceeds 80 characters; contains 95 characters
134 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 3
-----------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 14 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/add_content_modal/src/Controller/ModalController.php
----------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
----------------------------------------------------------------------------------------
7 | ERROR | [x] Doc comment short description must end with a full stop
10 | ERROR | [x] PHP keywords must be lowercase; expected "use" but found "Use"
14 | ERROR | [x] Missing class doc comment
19 | ERROR | [ ] Description for the @return value is missing
21 | ERROR | [x] Expected 1 space before opening brace; found 0
----------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/add_content_modal/src/Controller/DialogController.php
-----------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
-----------------------------------------------------------------------------------------
7 | ERROR | [x] Doc comment short description must end with a full stop
16 | ERROR | [x] Missing class doc comment
21 | ERROR | [ ] Description for the @return value is missing
-----------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------

Time: 1.21 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/add_content_modal/

Proposed resolution

Above error/warnings need to be fixed.

๐Ÿ“Œ Task
Status

Needs work

Version

1.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

  • Issue created by @samit.310@gmail.com
  • Issue was unassigned.
  • Status changed to Needs review about 2 years ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia samit.310@gmail.com

    Above error/warnings are fixed.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Charchil Khandelwal

    Charchil Khandelwal โ†’ made their first commit to this issueโ€™s fork.

  • Assigned to Charchil Khandelwal
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Charchil Khandelwal

    I will review this patch.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Charchil Khandelwal

    Thanks samit.310@gmail.com,
    Patch #2 tested and applied clearly, all the errors and warnings fixed now.

  • Issue was unassigned.
  • @charchil-khandelwal opened merge request.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Charchil Khandelwal

    Created MR !14 for easy preview and commenting.
    RTBC +1.

    Thanks.

  • Status changed to Needs work 8 months ago
  • Hi @samit.310,

    Applied the patch you provided, it was applied successfully but errors were still reported. Please see below:

    add_content_modal git:(1.0.x) curl https://www.drupal.org/files/issues/2023-02-17/3342538-2.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  8747  100  8747    0     0  12756      0 --:--:-- --:--:-- --:--:-- 12939
    patching file add_content_modal.module
    patching file src/Controller/DialogController.php
    patching file src/Controller/ModalController.php
    patching file src/Form/SettingsForm.php
    โžœ  add_content_modal git:(1.0.x) โœ— cd ..
    โžœ  contrib git:(master) โœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig add_content_modal
    
    FILE: ...orgissue-v9/web/modules/contrib/add_content_modal/add_content_modal.module
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     9 | ERROR | [x] Use statements should be sorted alphabetically. The first
       |       |     wrong one is Drupal\add_content_modal\Form\SettingsForm.
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    
    FILE: ...rgissue-v9/web/modules/contrib/add_content_modal/src/Form/SettingsForm.php
    --------------------------------------------------------------------------------
    FOUND 4 ERRORS AFFECTING 2 LINES
    --------------------------------------------------------------------------------
     33 | ERROR | [x] The first parameter of a multi-line function declaration must
        |       |     be on the line after the opening bracket
     34 | ERROR | [x] Multi-line function declaration not indented correctly;
        |       |     expected 4 spaces but found 30
     34 | ERROR | [x] Multi-line function declarations must have a trailing comma
        |       |     after the last parameter
     34 | ERROR | [x] The closing parenthesis of a multi-line function declaration
        |       |     must be on a new line
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    
    FILE: ...9/web/modules/contrib/add_content_modal/src/Controller/ModalController.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     12 | ERROR | [x] Use statements should be sorted alphabetically. The first
        |       |     wrong one is Drupal\Core\Ajax\AjaxResponse.
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    
    FILE: .../web/modules/contrib/add_content_modal/src/Controller/DialogController.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     14 | ERROR | [x] Use statements should be sorted alphabetically. The first
        |       |     wrong one is Drupal\Core\Ajax\AjaxResponse.
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    Time: 247ms; Memory: 12MB

    Kindly check

    Thanks,
    Jake

Production build 0.71.5 2024