Fix the issues reported by phpcs

Created on 8 July 2024, 5 months ago
Updated 10 August 2024, 3 months ago

Problem/Motivation

Running :-
vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig web/modules/contrib/visual_debugger/
returns the following warnings/errors, which should be fixed.

FILE: /home/prem/Documents/drupal-10.3.1/web/modules/contrib/visual_debugger/css/dist/vd.css
------------------------------------------------------------------------------------------------
FOUND 38 ERRORS AFFECTING 35 LINES
------------------------------------------------------------------------------------------------
8 | ERROR | [ ] Style definitions must end with a semicolon
9 | ERROR | [ ] Style definitions must end with a semicolon
10 | ERROR | [ ] Style definitions must end with a semicolon
11 | ERROR | [ ] Style definitions must end with a semicolon
12 | ERROR | [ ] Style definitions must end with a semicolon
13 | ERROR | [ ] Style definitions must end with a semicolon
14 | ERROR | [ ] Style definitions must end with a semicolon
15 | ERROR | [ ] Style definitions must end with a semicolon
16 | ERROR | [ ] Style definitions must end with a semicolon
17 | ERROR | [ ] Style definitions must end with a semicolon
18 | ERROR | [ ] Style definitions must end with a semicolon
19 | ERROR | [ ] Style definitions must end with a semicolon
20 | ERROR | [ ] Style definitions must end with a semicolon
21 | ERROR | [ ] Style definitions must end with a semicolon
22 | ERROR | [ ] Style definitions must end with a semicolon
23 | ERROR | [ ] Style definitions must end with a semicolon
24 | ERROR | [ ] Style definitions must end with a semicolon
25 | ERROR | [ ] Style definitions must end with a semicolon
26 | ERROR | [ ] Style definitions must end with a semicolon
27 | ERROR | [ ] Style definitions must end with a semicolon
90 | ERROR | [x] CSS colours must be defined in lowercase; expected #0000cc but found #0000CC
92 | ERROR | [x] CSS colours must be defined in lowercase; expected #cc0000 but found #CC0000
94 | ERROR | [x] CSS colours must be defined in lowercase; expected #00cc00 but found #00CC00
106 | ERROR | [ ] Style definitions must end with a semicolon
107 | ERROR | [ ] Style definitions must end with a semicolon
108 | ERROR | [ ] Style definitions must end with a semicolon
366 | ERROR | [x] Multiple selectors should each be on a single line
433 | ERROR | [x] Multiple selectors should each be on a single line
487 | ERROR | [x] Multiple selectors should each be on a single line
490 | ERROR | [x] Multiple selectors should each be on a single line
501 | ERROR | [x] Multiple selectors should each be on a single line
559 | ERROR | [x] Multiple selectors should each be on a single line
559 | ERROR | [x] Multiple selectors should each be on a single line
581 | ERROR | [x] Multiple selectors should each be on a single line
581 | ERROR | [x] Multiple selectors should each be on a single line
581 | ERROR | [x] Multiple selectors should each be on a single line
763 | ERROR | [x] Multiple selectors should each be on a single line
790 | ERROR | [x] Multiple selectors should each be on a single line
------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 15 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------

FILE: /home/prem/Documents/drupal-10.3.1/web/modules/contrib/visual_debugger/README.md
--------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 36 WARNINGS AFFECTING 36 LINES
--------------------------------------------------------------------------------------
6 | WARNING | Line exceeds 80 characters; contains 176 characters
8 | WARNING | Line exceeds 80 characters; contains 227 characters
10 | WARNING | Line exceeds 80 characters; contains 236 characters
12 | WARNING | Line exceeds 80 characters; contains 287 characters
18 | WARNING | Line exceeds 80 characters; contains 253 characters
20 | WARNING | Line exceeds 80 characters; contains 183 characters
21 | WARNING | Line exceeds 80 characters; contains 273 characters
27 | WARNING | Line exceeds 80 characters; contains 236 characters
29 | WARNING | Line exceeds 80 characters; contains 247 characters
31 | WARNING | Line exceeds 80 characters; contains 297 characters
36 | WARNING | Line exceeds 80 characters; contains 252 characters
38 | WARNING | Line exceeds 80 characters; contains 141 characters
40 | WARNING | Line exceeds 80 characters; contains 145 characters
46 | WARNING | Line exceeds 80 characters; contains 173 characters
58 | WARNING | Line exceeds 80 characters; contains 218 characters
62 | WARNING | Line exceeds 80 characters; contains 382 characters
64 | WARNING | Line exceeds 80 characters; contains 331 characters
69 | WARNING | Line exceeds 80 characters; contains 309 characters
70 | WARNING | Line exceeds 80 characters; contains 86 characters
71 | WARNING | Line exceeds 80 characters; contains 254 characters
72 | WARNING | Line exceeds 80 characters; contains 149 characters
73 | WARNING | Line exceeds 80 characters; contains 82 characters
74 | WARNING | Line exceeds 80 characters; contains 82 characters
75 | WARNING | Line exceeds 80 characters; contains 86 characters
76 | WARNING | Line exceeds 80 characters; contains 245 characters
81 | WARNING | Line exceeds 80 characters; contains 242 characters
83 | WARNING | Line exceeds 80 characters; contains 124 characters
84 | WARNING | Line exceeds 80 characters; contains 96 characters
85 | WARNING | Line exceeds 80 characters; contains 105 characters
86 | WARNING | Line exceeds 80 characters; contains 163 characters
87 | WARNING | Line exceeds 80 characters; contains 149 characters
88 | WARNING | Line exceeds 80 characters; contains 108 characters
89 | WARNING | Line exceeds 80 characters; contains 155 characters
90 | WARNING | Line exceeds 80 characters; contains 262 characters
91 | WARNING | Line exceeds 80 characters; contains 131 characters
93 | WARNING | Line exceeds 80 characters; contains 240 characters
--------------------------------------------------------------------------------------

FILE: /home/prem/Documents/drupal-10.3.1/web/modules/contrib/visual_debugger/src/Form/SettingsForm.php
------------------------------------------------------------------------------------------------------------------------
FOUND 7 ERRORS AND 2 WARNINGS AFFECTING 7 LINES
------------------------------------------------------------------------------------------------------------------------
17 | ERROR | [x] There must be exactly one blank line before the tags in a doc comment
17 | ERROR | [x] Do not append variable name "$use_on_frontend" to the type declaration in a member variable comment
19 | ERROR | [ ] Class property $use_on_frontend should use lowerCamel naming without underscores
23 | ERROR | [x] There must be exactly one blank line before the tags in a doc comment
23 | ERROR | [x] Do not append variable name "$use_on_admin" to the type declaration in a member variable comment
25 | ERROR | [ ] Class property $use_on_admin should use lowerCamel naming without underscores
59 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
87 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
92 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------

FILE: /home/prem/Documents/drupal-10.3.1/web/modules/contrib/visual_debugger/src/VisualDebuggerConstants.php
------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------
5 | ERROR | [x] Missing class doc comment
10 | ERROR | [x] The closing brace for the class must have an empty line before it
------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------

FILE: /home/prem/Documents/drupal-10.3.1/web/modules/contrib/visual_debugger/visual_debugger.module
---------------------------------------------------------------------------------------------------
FOUND 4 ERRORS AND 3 WARNINGS AFFECTING 7 LINES
---------------------------------------------------------------------------------------------------
1 | ERROR | [x] Missing file doc comment
17 | ERROR | [x] Expected 1 space after cast statement; 0 found
18 | ERROR | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
21 | ERROR | [x] Inline control structures are not allowed
23 | WARNING | [ ] Unused variable $cache_invalidator.
52 | WARNING | [ ] Line exceeds 80 characters; contains 81 characters
53 | WARNING | [ ] Line exceeds 80 characters; contains 99 characters
---------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------

FILE: /home/prem/Documents/drupal-10.3.1/web/modules/contrib/visual_debugger/js/dist/vd.min.js
----------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------
1 | WARNING | File appears to be minified and cannot be processed
----------------------------------------------------------------------------------------------

FILE: /home/prem/Documents/drupal-10.3.1/web/modules/contrib/visual_debugger/js/dist/controllerElement.min.js
-------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------
1 | WARNING | File appears to be minified and cannot be processed
-------------------------------------------------------------------------------------------------------------

FILE: /home/prem/Documents/drupal-10.3.1/web/modules/contrib/visual_debugger/js/dist/themeElement.min.js
--------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------
1 | WARNING | File appears to be minified and cannot be processed
--------------------------------------------------------------------------------------------------------

FILE: /home/prem/Documents/drupal-10.3.1/web/modules/contrib/visual_debugger/js/dist/utilities.min.js
-----------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------
1 | WARNING | File appears to be minified and cannot be processed
-----------------------------------------------------------------------------------------------------

FILE: /home/prem/Documents/drupal-10.3.1/web/modules/contrib/visual_debugger/visual_debugger.info.yml
-------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------
1 | WARNING | Remove "project" from the info file, it will be added by drupal.org packaging automatically
1 | WARNING | Remove "datestamp" from the info file, it will be added by drupal.org packaging automatically
1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
-------------------------------------------------------------------------------------------------------------

Time: 222ms; Memory: 20MB

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Fixed

Version

1.0

Component

Code

Created by

🇮🇳India prem suthar Ahemdabad- Gujrat , Jodhpur - Rajsthan

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

  • Issue created by @prem suthar
  • 🇧🇷Brazil mabho Rio de Janeiro, RJ

    Thank you for reporting this, Suthat, I will run PHPCS and apply the suggested fixes.

    I will keep this ticket as a 'to do' for now: I have ongoing changes already affecting another branch that would trigger many conflicts if I were to work on this topic now. Once those changes are merged back to the dev branch and deployed, I can kick-start the PHPCS adjustments.

  • Assigned to abhiyanshu_rawat
  • 🇧🇷Brazil mabho Rio de Janeiro, RJ

    Thank you for taking over the ticket, abhiyanshu. I will ask you to wait for my sign to fork this and start working. Many thanks for helping!

  • 🇮🇳India abhiyanshu_rawat

    @mabho No worries, I'll fix this locally and attach a patch once the PHPCS issues are resolved. Thanks.

  • 🇧🇷Brazil mabho Rio de Janeiro, RJ

    @abhiyanshu, I just completed applying multiple changes to the project, and released a new alpha9 version. If you are still willing to run the task on this issue queue, you can grab the latest version just released, run phpcs again and apply the suggested fixes. Let me know if you are willing to do that. I can also go over this task. Many thanks!

  • Merge request !14Multiple PHPCS and eslint fixes. → (Merged) created by mabho
  • 🇮🇳India abhiyanshu_rawat

    Sure @mabho,
    I somehow missed the notification and just got the message after the MR.
    I will continue addressing any remaining issues in the new alpha9 version. Thank you for your patience and understanding.

  • 🇧🇷Brazil mabho Rio de Janeiro, RJ

    @abhiyanshu, I can see your changes on top of mine, thank you for your contributions, it truly helped me see further and investigate deeper on this validation landscape, I am learning a lot from this interaction.

    Some comments here:

    • We don't need to validate anything within the fonts/* folder. That folder is auto-generated by Icomoon and I don't want to revalidate things every time I push a new icon (when that happens, Icomoon generates an entirely new package of files that I just replace/overwrite on top of the existing ones, including CSS, HTML, SASS, font files). We can exclude any changes within that folder.
    • The updates need to be applied to the SASS files, we don't want to validate the compiled CSS files. We also want folder /js/dist to be left out of the validation.
    • It looks like Javascript code validation is done via Eslint, not PHPCS. Please, check this documentation on how to specify Drupal coding standards ( https://www.drupal.org/drupalorg/docs/drupal-ci/using-coderphpcs-in-drup... → ) and this Acquia recommended project as references: https://github.com/acquia/drupal-recommended-project/blob/master/phpcs.x.... Javascript should thus be left out of the <arg name="extensions" /> values.
    • I am also leaving the .md file out of the PHPCS scope, I reworked the file to limit each line to 80 characters maximum, but it is very limiting to keep that rule.
    • Finally, I have an update for the phpcs.xml.dist file that is redeclaring the exclude folders within the exclude-pattern rules block and, most important, it is adjusting the file extensions we want to validate according to the benchmarks mentioned above. In order to run PHPCS out of these new rules you will need to rename phpcs.xml.dist to phpcs.xml. You can run it with the command you see in the documentation: vendor/bin/phpcs --standard=web/modules/custom/visual_debugger/phpcs.xml web/modules/custom/visual_debugger (edit paths accordingly depending on your environment).

    Because of all these differences, I reverted your commit, and packed the adjusted phpcs.xml.dist file, but your help was invaluable and I will provide all the credit on this thread.

    One final question: do you know if we can get PHPCS to validate SCSS files with the same recommendations it delivers to CSS files: my SCSS validation did not find the problem with the hexadecimal uppercase codes and other issues the original validation raised when running on CSS.

  • Status changed to Needs review 4 months ago
  • 🇧🇷Brazil mabho Rio de Janeiro, RJ
  • 🇧🇷Brazil mabho Rio de Janeiro, RJ
  • Pipeline finished with Skipped
    4 months ago
    #241035
  • Status changed to Fixed 4 months ago
    • mabho → committed 433affa4 on 1.0.x
      Issue #3459930 by mabho, abhiyanshu, Prem Suthar: Fix the issues...
  • Status changed to Fixed 4 months ago
  • 🇧🇷Brazil mabho Rio de Janeiro, RJ
  • Merge request !15Resolve #3459930 "02 fix phpcs issues" → (Merged) created by mabho
  • Pipeline finished with Skipped
    3 months ago
    #249701
Production build 0.71.5 2024