Fixing the coding standard issues | phpcs

Created on 3 April 2023, over 1 year ago
Updated 15 August 2024, 4 months ago

Problem/Motivation

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\menu_attributes-3351820\CHANGELOG.txt
-------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 13 WARNINGS AFFECTING 13 LINES
-------------------------------------------------------------------------------------------------
6 | WARNING | Line exceeds 80 characters; contains 90 characters
7 | WARNING | Line exceeds 80 characters; contains 109 characters
8 | WARNING | Line exceeds 80 characters; contains 81 characters
10 | WARNING | Line exceeds 80 characters; contains 109 characters
12 | WARNING | Line exceeds 80 characters; contains 108 characters
16 | WARNING | Line exceeds 80 characters; contains 96 characters
21 | WARNING | Line exceeds 80 characters; contains 89 characters
22 | WARNING | Line exceeds 80 characters; contains 161 characters
23 | WARNING | Line exceeds 80 characters; contains 82 characters
27 | WARNING | Line exceeds 80 characters; contains 102 characters
28 | WARNING | Line exceeds 80 characters; contains 124 characters
31 | WARNING | Line exceeds 80 characters; contains 124 characters
37 | WARNING | Line exceeds 80 characters; contains 157 characters
-------------------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\menu_attributes-3351820\menu_attributes.api.php
-----------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
-----------------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
11 | ERROR | [ ] Return type missing for @return tag in function comment
46 | ERROR | [ ] Missing parameter type
-----------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\menu_attributes-3351820\menu_attributes.install
------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
------------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
63 | ERROR | [ ] unserialize() is insecure unless allowed classes are limited. Use a safe format like JSON or use the
| | allowed_classes option.
89 | ERROR | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\menu_attributes-3351820\menu_attributes.module
-----------------------------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AFFECTING 5 LINES
-----------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
6 | ERROR | [ ] Doc comment short description must end with a full stop
6 | ERROR | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
126 | ERROR | [x] Use null coalesce operator instead of ternary operator.
166 | ERROR | [ ] Missing parameter type
168 | ERROR | [ ] Missing parameter type
-----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\menu_attributes-3351820\menu_attributes.test
-----------------------------------------------------------------------------------------------------------
FOUND 37 ERRORS AND 4 WARNINGS AFFECTING 29 LINES
-----------------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
14 | ERROR | [ ] Missing member variable doc comment
14 | ERROR | [ ] Class property $admin_user should use lowerCamel naming without underscores
15 | ERROR | [ ] Missing member variable doc comment
15 | ERROR | [ ] Class property $menu_attributes_new should use lowerCamel naming without underscores
16 | ERROR | [ ] Missing member variable doc comment
16 | ERROR | [ ] Class property $menu_attributes_edit should use lowerCamel naming without underscores
18 | ERROR | [x] Missing function doc comment
18 | ERROR | [x] Visibility must be declared on method "setUp"
57 | ERROR | [ ] Parameter $mlid is not described in comment
60 | ERROR | [x] Expected "int" but found "integer" for parameter type
60 | ERROR | [x] Parameter comment must be on the next line
61 | ERROR | [x] Parameter comment must be on the next line
62 | ERROR | [x] Parameter comment must be on the next line
64 | ERROR | [ ] Description for the @return value must be on the next line
66 | ERROR | [x] Visibility must be declared on method "crudMenuLink"
82 | ERROR | [x] Comments may not appear after statements
83 | WARNING | [ ] Line exceeds 80 characters; contains 109 characters
83 | ERROR | [x] Comments may not appear after statements
84 | ERROR | [x] Expected 1 space after "=>"; 2 found
104 | ERROR | [x] Missing function doc comment
104 | ERROR | [x] Visibility must be declared on method "assertMenuAttributes"
107 | WARNING | [ ] Only string literals should be passed to t() where possible
112 | WARNING | [ ] Only string literals should be passed to t() where possible
115 | ERROR | [x] Expected 1 blank line after function; 0 found
116 | ERROR | [x] The closing brace for the class must have an empty line before it
122 | ERROR | [x] Missing function doc comment
122 | ERROR | [x] Expected 1 blank line before function; 0 found
130 | WARNING | [ ] Possible useless method overriding detected
130 | ERROR | [x] Missing function doc comment
130 | ERROR | [x] Visibility must be declared on method "setUp"
137 | ERROR | [x] Visibility must be declared on method "testMenuAttributes"
157 | ERROR | [x] Expected 1 blank line after function; 0 found
158 | ERROR | [x] The closing brace for the class must have an empty line before it
164 | ERROR | [x] Missing function doc comment
164 | ERROR | [x] Expected 1 blank line before function; 0 found
172 | ERROR | [x] Missing function doc comment
172 | ERROR | [x] Visibility must be declared on method "setUp"
180 | ERROR | [x] Visibility must be declared on method "testMenuNodeFormWidget"
266 | ERROR | [x] Expected 1 blank line after function; 0 found
267 | ERROR | [x] The closing brace for the class must have an empty line before it
-----------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 29 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------

Time: 1.42 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.
Sign in to follow issues

Comments & Activities

  • Issue created by @sidharth_soman
  • šŸ‡®šŸ‡³India sidharth_soman Bangalore

    Finding the issues as indicated in the summary upon running phpcs. Will work on fixing them.

  • Status changed to Needs work over 1 year ago
  • šŸ‡®šŸ‡³India sidharth_soman Bangalore
  • @sidharth_soman opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • šŸ‡®šŸ‡³India sidharth_soman Bangalore

    I have solved about 60-70% of the issues. The rest are documentation gaps which would ideally be filled in by the maintainers.
    Please review the above MR.
    Thanks.

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

    Hi @sidharth_soman,

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

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

    āžœ  menu_attributes git:(7.x-1.x) curl https://git.drupalcode.org/project/menu_attributes/-/merge_requests/1.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 12737    0 12737    0     0  27862      0 --:--:-- --:--:-- --:--:-- 27870
    patching file menu_attributes.api.php
    patching file menu_attributes.install
    patching file menu_attributes.module
    patching file menu_attributes.test
    āžœ  menu_attributes git:(7.x-1.x) āœ— ..
    āžœ  contrib phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml menu_attributes
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/menu_attributes/menu_attributes.install
    ------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------
     89 | ERROR | Doc comment short description must be on a single line, further text should be a separate paragraph
    ------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/menu_attributes/menu_attributes.module
    -----------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------
     5 | WARNING | Line exceeds 80 characters; contains 107 characters
    -----------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/menu_attributes/menu_attributes.test
    ---------------------------------------------------------------------------------------------------------
    FOUND 9 ERRORS AND 4 WARNINGS AFFECTING 13 LINES
    ---------------------------------------------------------------------------------------------------------
      14 | ERROR   | Missing member variable doc comment
      15 | ERROR   | Missing member variable doc comment
      16 | ERROR   | Missing member variable doc comment
      18 | ERROR   | Doc comment is empty
      93 | WARNING | Line exceeds 80 characters; contains 87 characters
     115 | ERROR   | Doc comment is empty
     121 | WARNING | Only string literals should be passed to t() where possible
     126 | WARNING | Only string literals should be passed to t() where possible
     138 | ERROR   | Doc comment is empty
     149 | ERROR   | Doc comment is empty
     152 | WARNING | Possible useless method overriding detected
     188 | ERROR   | Doc comment is empty
     199 | ERROR   | Doc comment is empty
    ---------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/menu_attributes/CHANGELOG.txt
    --------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 13 WARNINGS AFFECTING 13 LINES
    --------------------------------------------------------------------------------------------------
      6 | WARNING | Line exceeds 80 characters; contains 90 characters
      7 | WARNING | Line exceeds 80 characters; contains 109 characters
      8 | WARNING | Line exceeds 80 characters; contains 81 characters
     10 | WARNING | Line exceeds 80 characters; contains 109 characters
     12 | WARNING | Line exceeds 80 characters; contains 108 characters
     16 | WARNING | Line exceeds 80 characters; contains 96 characters
     21 | WARNING | Line exceeds 80 characters; contains 89 characters
     22 | WARNING | Line exceeds 80 characters; contains 161 characters
     23 | WARNING | Line exceeds 80 characters; contains 82 characters
     27 | WARNING | Line exceeds 80 characters; contains 102 characters
     28 | WARNING | Line exceeds 80 characters; contains 124 characters
     31 | WARNING | Line exceeds 80 characters; contains 124 characters
     37 | WARNING | Line exceeds 80 characters; contains 157 characters
    --------------------------------------------------------------------------------------------------
    
    Time: 257ms; Memory: 12MB
    
    āžœ  contrib

    Thank you.

Production build 0.71.5 2024