Fix the errors/warnings reported by Php Code_Sniffer

Created on 7 July 2023, over 1 year ago
Updated 21 August 2024, 3 months ago

Problem/Motivation

C:\xampp\htdocs\backendassignment\web\modules\contrib\protect_form_flood_control>phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig protect_form_flood_control

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\protect_form_flood_control\protect_form_flood_control\css\admin.css
-------------------------------------------------------------------------------------------------------------------------------
FOUND 9 ERRORS AFFECTING 9 LINES
-------------------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
5 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
7 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
9 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
11 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
19 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
20 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
27 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
28 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
-------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 9 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\protect_form_flood_control\protect_form_flood_control\protect_form_flood_control.links.menu.yml
-----------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------------------------
6 | ERROR | [x] Expected 1 newline at end of file; 2 found
-----------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\protect_form_flood_control\protect_form_flood_control\protect_form_flood_control.module
---------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
---------------------------------------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
38 | ERROR | [x] There must be exactly one blank line before the tags in a doc comment
---------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\protect_form_flood_control\protect_form_flood_control\README.txt
----------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------------
66 | WARNING | Line exceeds 80 characters; contains 82 characters
----------------------------------------------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\protect_form_flood_control\protect_form_flood_control\src\Form\ProtectFormFloodControlSettings.php
--------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 17 ERRORS AND 2 WARNINGS AFFECTING 17 LINES
--------------------------------------------------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
14 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
142 | ERROR | [ ] The array declaration extends to column 82 (the limit is 80). The array content should be split up over multiple lines
153 | ERROR | [ ] The array declaration extends to column 82 (the limit is 80). The array content should be split up over multiple lines
170 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
224 | ERROR | [ ] Missing parameter comment
224 | ERROR | [ ] Missing parameter type
244 | ERROR | [ ] Missing parameter comment
244 | ERROR | [ ] Missing parameter type
245 | ERROR | [ ] Missing parameter comment
246 | ERROR | [ ] Missing parameter comment
248 | ERROR | [ ] Description for the @return value is missing
287 | ERROR | [ ] Missing parameter comment
288 | ERROR | [ ] Missing parameter comment
290 | ERROR | [x] Additional blank lines found at end of doc comment
312 | ERROR | [ ] Missing parameter comment
313 | ERROR | [ ] Missing parameter comment
315 | ERROR | [ ] Description for the @return value is missing
344 | ERROR | [ ] Description for the @return value is missing
--------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\protect_form_flood_control\protect_form_flood_control\src\Manager.php
---------------------------------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AND 2 WARNINGS AFFECTING 7 LINES
---------------------------------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
20 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
118 | ERROR | [x] Expected 1 blank line before function; 2 found
188 | WARNING | [ ] Line exceeds 80 characters; contains 81 characters
266 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 3
280 | ERROR | [ ] Public method name "Manager::displayFormID" is not in lowerCamel format
287 | ERROR | [ ] The array declaration extends to column 135 (the limit is 80). The array content should be split up over multiple lines
---------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\protect_form_flood_control\protect_form_flood_control\src\ManagerInterface.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AND 1 WARNING AFFECTING 7 LINES
------------------------------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
9 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
153 | ERROR | [x] Separate the @param and @return sections by a blank line.
163 | ERROR | [ ] Missing parameter type
166 | ERROR | [ ] Public method name "ManagerInterface::displayFormID" is not in lowerCamel format
269 | ERROR | [x] Expected 1 blank line after function; 0 found
270 | ERROR | [x] The closing brace for the interface must have an empty line before it
------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\protect_form_flood_control\protect_form_flood_control\tests\src\Functional\ProtectFormFloodControlFormTest.php
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
55 | ERROR | [ ] The array declaration extends to column 90 (the limit is 80). The array content should be split up over multiple lines
186 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 0
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Time: 2.54 secs; Memory: 6MB

Steps to reproduce

Run the phpcs command on the module.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

šŸ“Œ Task
Status

Needs work

Version

1.0

Component

Code

Created by

šŸ‡®šŸ‡³India sidharth_soman Bangalore

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 @sidharth_soman
  • Open in Jenkins ā†’ Open on Drupal.org ā†’
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    Composer require failure
  • @sidharth_soman opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • šŸ‡®šŸ‡³India sidharth_soman Bangalore

    I've solved mostly all the issues, but there are a few remaining to do with the 'line exceeds 80 characters' error and naming conventions for the functions. Leaving those as it is for the maintainer to decide what standard suits them.

    Please review the MR

  • Status changed to Needs work 3 months ago
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi @sidhart_soman,

    I applied MR!2, it was not applied smoothly but 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:

    āžœ  protect_form_flood_control git:(1.0.x) curl https://git.drupalcode.org/project/protect_form_flood_control/-/merge_requests/2.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  7967    0  7967    0     0  20437      0 --:--:-- --:--:-- --:--:-- 20428
    patching file css/admin.css
    patching file protect_form_flood_control.links.menu.yml
    patching file protect_form_flood_control.module
    patching file src/Form/ProtectFormFloodControlSettings.php
    patching file src/Manager.php
    Hunk #3 FAILED at 262.
    1 out of 3 hunks FAILED -- saving rejects to file src/Manager.php.rej
    patching file src/ManagerInterface.php
    patching file tests/src/Functional/ProtectFormFloodControlFormTest.php
    āžœ  protect_form_flood_control git:(1.0.x) āœ— ..
    āžœ  contrib phpcs --standard="Drupal,DrupalPractice" --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml,css,js protect_form_flood_control
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/protect_form_flood_control/tests/src/Functional/ProtectFormFloodControlFormTest.php
    --------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------------------------------------------------------
     6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\comment\Plugin\Field\FieldType\CommentItemInterface.
    --------------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/protect_form_flood_control/README.txt
    ----------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------------
     66 | WARNING | Line exceeds 80 characters; contains 82 characters
    ----------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/protect_form_flood_control/src/Form/ProtectFormFloodControlSettings.php
    --------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------------------------------------------
     249 | ERROR | Missing parameter comment
    --------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/protect_form_flood_control/src/ManagerInterface.php
    ------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------
     167 | ERROR | Public method name "ManagerInterface::displayFormID" is not in lowerCamel format
    ------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/protect_form_flood_control/src/Manager.php
    ----------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 4 ERRORS AND 1 WARNING AFFECTING 5 LINES
    ----------------------------------------------------------------------------------------------------------------------------------------------
       7 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Config\ConfigFactoryInterface.
     187 | WARNING | [ ] Line exceeds 80 characters; contains 81 characters
     268 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 3
     282 | ERROR   | [ ] Public method name "Manager::displayFormID" is not in lowerCamel format
     289 | ERROR   | [ ] The array declaration extends to column 135 (the limit is 120). The array content should be split up over multiple lines
    ----------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 347ms; Memory: 12MB
    
    āžœ  contrib

    Thank you.

Production build 0.71.5 2024