Drupal Coding Standards Issues | phpcs

Created on 1 February 2023, almost 2 years ago
Updated 21 February 2023, almost 2 years ago

Problem/Motivation

Getting Following errors/warnings

$ phpcs --standard=Drupal msqrole

FILE: C:\Users\Admin\Desktop\task\msqrole\css\masquerade-role.css
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found
   |       |     "\r\n"
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: C:\Users\Admin\Desktop\task\msqrole\js\masquerade-role.js
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found
   |       |     "\r\n"
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: C:\Users\Admin\Desktop\task\msqrole\src\Controller\MasqueradeRoleReset.php
--------------------------------------------------------------------------------
FOUND 7 ERRORS AND 1 WARNING AFFECTING 7 LINES
--------------------------------------------------------------------------------
  1 | ERROR   | [x] End of line character is invalid; expected "\n" but found
    |         |     "\r\n"
 16 | ERROR   | [x] Doc comment short description must end with a full stop
 19 | WARNING | [ ] The class short comment should describe what the class does
    |         |     and not simply repeat the class name
 63 | ERROR   | [x] There must be exactly one blank line before the tags in a
    |         |     doc comment
 69 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks,
    |         |     question marks, colons, or closing parentheses
 72 | ERROR   | [x] Expected newline after closing brace
 80 | ERROR   | [x] Expected newline after closing brace
 80 | ERROR   | [x] Expected 1 space after CATCH keyword; 0 found
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: C:\Users\Admin\Desktop\task\msqrole\src\DynamicRolePermissions.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AND 2 WARNINGS AFFECTING 3 LINES
--------------------------------------------------------------------------------
  1 | ERROR   | [x] End of line character is invalid; expected "\n" but found
    |         |     "\r\n"
  5 | WARNING | [x] Unused use statement
 11 | WARNING | [ ] The class short comment should describe what the class does
    |         |     and not simply repeat the class name
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: C:\Users\Admin\Desktop\task\msqrole\src\Form\MasqueradeRoleForm.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"
  14 | ERROR   | [x] Doc comment short description must end with a full stop
  17 | WARNING | [ ] The class short comment should describe what the class
     |         |     does and not simply repeat the class name
  94 | ERROR   | [x] Array indentation error, expected 6 spaces but found 0
 135 | ERROR   | [x] Expected newline after closing brace
 159 | ERROR   | [x] Expected newline after closing brace
 166 | ERROR   | [x] Expected newline after closing brace
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: C:\Users\Admin\Desktop\task\msqrole\src\Form\MasqueradeRoleSettings.php
--------------------------------------------------------------------------------
FOUND 4 ERRORS AND 2 WARNINGS AFFECTING 6 LINES
--------------------------------------------------------------------------------
  1 | ERROR   | [x] End of line character is invalid; expected "\n" but found
    |         |     "\r\n"
 10 | ERROR   | [x] Doc comment short description must end with a full stop
 13 | WARNING | [ ] The class short comment should describe what the class does
    |         |     and not simply repeat the class name
 46 | WARNING | [x] A comma should follow the last multiline array item. Found:
    |         |     )
 49 | ERROR   | [x] Functions must not contain multiple empty lines in a row;
    |         |     found 2 empty lines
 84 | ERROR   | [x] Expected 1 newline at end of file; 2 found
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: C:\Users\Admin\Desktop\task\msqrole\src\MasqueradeAccountProxy.php
--------------------------------------------------------------------------------
FOUND 3 ERRORS AND 1 WARNING AFFECTING 4 LINES
--------------------------------------------------------------------------------
  1 | ERROR   | [x] End of line character is invalid; expected "\n" but found
    |         |     "\r\n"
 13 | ERROR   | [x] Doc comment short description must end with a full stop
 16 | WARNING | [ ] The class short comment should describe what the class does
    |         |     and not simply repeat the class name
 73 | ERROR   | [x] Expected newline after closing brace
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: C:\Users\Admin\Desktop\task\msqrole\src\RoleManager.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 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
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: C:\Users\Admin\Desktop\task\msqrole\src\RoleManagerInterface.php
--------------------------------------------------------------------------------
FOUND 9 ERRORS AND 1 WARNING AFFECTING 10 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
  27 | ERROR   | [ ] Missing parameter type
  72 | ERROR   | [ ] Description for the @return value is missing
  89 | ERROR   | [x] Expected 1 spaces after parameter type; 2 found
  92 | ERROR   | [ ] Description for the @return value is missing
  99 | ERROR   | [x] Expected 1 spaces after parameter type; 2 found
 112 | ERROR   | [x] Expected 1 spaces after parameter type; 2 found
 116 | ERROR   | [x] Expected 1 spaces after parameter type; 2 found
 127 | ERROR   | [x] Expected 1 spaces after parameter type; 2 found
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

Time: 541ms; Memory: 8MB

Proposed resolution

Fix the errors and warnings.

📌 Task
Status

Closed: won't fix

Version

1.0

Component

Code

Created by

🇮🇳India jay jangid Jaipur

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @jay jangid
  • @jay-jangid opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review almost 2 years ago
  • 🇮🇳India jay jangid Jaipur

    Created MR , please review.

    Thank you.

  • Status changed to Closed: won't fix almost 2 years ago
  • 🇧🇪Belgium RandalV

    Frankly, this is not okay.
    This is the so-manieth issue I've seen from either you or one of your colleagues that is just entirely wrongly done and I refuse to spend any more time fixing these MRs.

    Obviously this was done through phpcbf, but you're quite literally removing all of the specifically descriptive comments and replacing them with "Summary of ..." as well as the return types when they're not specifically typehinted, see the image attached for one example out of tens or even hundreds.
    How is that an improvement?

    To be blunt, if you're going to try and farm "credited on ... fixed issues", please, at least do it in a manner that is helpful.

    I'm going to close this issue as "won't fix". If you wish to actually fix the MR, I'll commit it.

    For future reference: simply running phpcs & phpcbf is not the solution. Phpcbf is merely a tool that could reduce the amount of repeated work you perform but you simply cannot let it replace existing descriptive comments with something vague like "Summary of ...", and remove half of the @return statements simply because it's not specifically typehinted.
    You can run phpcbf on a file, but if the result of phpcbf is not up to standards you yourself still need to fix that.

Production build 0.71.5 2024