Fix the issues reported by PHP_CodeSniffer

Created on 23 September 2024, 3 months ago

Problem/Motivation

FILE: modules\help_text\config\install\help_text.settings.yml
-------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------
5 | ERROR | [x] Expected 1 newline at end of file; 0 found
-------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------

FILE: modules\help_text\help_text.libraries.yml
-----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------
10 | ERROR | [x] Expected 1 newline at end of file; 0 found
-----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------

FILE: modules\help_text\help_text.module
------------------------------------------------------------------------------------------------------------------------------
FOUND 71 ERRORS AND 1 WARNING AFFECTING 31 LINES
------------------------------------------------------------------------------------------------------------------------------
8 | WARNING | [x] Unused use statement
16 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
16 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
17 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
17 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
19 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
19 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
19 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
20 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
20 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
20 | ERROR | [x] Spaces must be used for alignment; tabs are not allowed
20 | ERROR | [x] Whitespace found at end of line
22 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
22 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
23 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
23 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
24 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
24 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
24 | ERROR | [x] Expected 1 space after IF keyword; 0 found
25 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
25 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
25 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
26 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
26 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
28 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
28 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
28 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
29 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
29 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
30 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
30 | ERROR | [x] Array indentation error, expected 4 spaces but found 6
31 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
31 | ERROR | [x] Array indentation error, expected 4 spaces but found 6
32 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
32 | ERROR | [x] Array indentation error, expected 4 spaces but found 6
33 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
33 | ERROR | [x] Array indentation error, expected 4 spaces but found 6
34 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
34 | ERROR | [x] Array closing indentation error, expected 2 spaces but found 4
35 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
35 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
36 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
36 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
37 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
37 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
37 | ERROR | [x] Use "elseif" in place of "else if"
37 | ERROR | [x] Expected 1 space after IF keyword; 0 found
38 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
38 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
38 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
39 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
39 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
41 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
41 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
41 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
42 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
42 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
43 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
43 | ERROR | [x] Array indentation error, expected 4 spaces but found 6
44 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
44 | ERROR | [x] Array indentation error, expected 4 spaces but found 6
45 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
45 | ERROR | [x] Array indentation error, expected 4 spaces but found 6
46 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
46 | ERROR | [x] Array indentation error, expected 4 spaces but found 6
47 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
47 | ERROR | [x] Array closing indentation error, expected 2 spaces but found 4
48 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
48 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
48 | ERROR | [x] Spaces must be used for alignment; tabs are not allowed
48 | ERROR | [x] Whitespace found at end of line
50 | ERROR | [x] Expected 1 newline at end of file; 2 found
------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 72 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------

FILE: modules\help_text\src\Form\HelpTextSettingsForm.php
--------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 24 ERRORS AND 1 WARNING AFFECTING 11 LINES
--------------------------------------------------------------------------------------------------------------------------------------------------
10 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
44 | ERROR | [x] Expected 1 space after "=>"; 0 found
44 | ERROR | [ ] The array declaration extends to column 157 (the limit is 120). The array content should be split up over multiple lines
44 | ERROR | [x] Expected one space after the comma, 0 found
44 | ERROR | [x] Expected one space after the comma, 0 found
44 | ERROR | [x] Expected 1 space between "'fa-2x'" and double arrow; 0 found
44 | ERROR | [x] Expected 1 space before "=>"; 0 found
44 | ERROR | [x] Expected 1 space between "'fa-3x'" and double arrow; 0 found
44 | ERROR | [x] Expected 1 space before "=>"; 0 found
44 | ERROR | [x] Expected 1 space between "'fa-4x'" and double arrow; 0 found
44 | ERROR | [x] Expected 1 space before "=>"; 0 found
44 | ERROR | [x] Expected 1 space between "'fa-5x'" and double arrow; 0 found
44 | ERROR | [x] Expected 1 space before "=>"; 0 found
69 | ERROR | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
78 | ERROR | [x] Whitespace found at end of line
80 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
81 | ERROR | [x] Expected 1 space before "="; 0 found
82 | ERROR | [x] Expected 1 space before "="; 0 found
87 | ERROR | [x] No space found before comment text; expected "// set config to submitted values" but found "//set config to submitted values"
87 | ERROR | [x] Inline comments must start with a capital letter
87 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
92 | ERROR | [x] Whitespace found at end of line
93 | ERROR | [x] Whitespace found at end of line
93 | ERROR | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
98 | ERROR | [x] Expected 1 newline at end of file; 2 found
--------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 23 MARKED SNIFF VIOLATIONS AUTOMATICALLY

Steps to reproduce

Run phpcs command to get the drupal coding standard issues.

Proposed resolution

Many of the issues can be fixed by running the phpcbf command. For the remaining ones, we will need to manually address and then commit these changes before pushing them.

šŸ“Œ Task
Status

Needs work

Version

1.14

Component

Code

Created by

šŸ‡ŗšŸ‡øUnited States sunil jolapara 3265 Summitrun Drive, Independence, KY, 41051

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

Merge Requests

Comments & Activities

  • Issue created by @sunil jolapara
  • šŸ‡ŗšŸ‡øUnited States sunil jolapara 3265 Summitrun Drive, Independence, KY, 41051
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹

    The issue summary for PHP_CodeSniffer issues should always show the report given from PHP_CodeSniffer and the arguments passed to phpcs.

    Furthermore, since GitLab CI is now enabled for all the projects, GitLab CI should be used to get PHP_CodeSniffer errors/warnings.

  • Assigned to cleavinjosh
  • šŸ‡µšŸ‡­Philippines cleavinjosh
  • šŸ‡µšŸ‡­Philippines cleavinjosh
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi @sunil jolapara,

    Thank you for providing an MR. I applied MR!1, it was applied smoothly and 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:

    āžœ  help_text git:(8.x-1.x) curl https://git.drupalcode.org/project/help_text/-/merge_requests/1.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  6673    0  6673    0     0  13985      0 --:--:-- --:--:-- --:--:-- 14018
    patching file config/install/help_text.settings.yml
    patching file help_text.libraries.yml
    patching file help_text.module
    patching file src/Form/HelpTextSettingsForm.php
    āžœ  help_text git:(8.x-1.x) āœ— ..
    āžœ  contrib git:(main) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml help_text
    
    FILE: /Users/interns/Demo-site/drupal_11_test/install-dir/drupal_11_test_site/web/modules/contrib/help_text/help_text.info.yml
    ------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------------
     8 | WARNING | All dependencies must be prefixed with the project name, for example "drupal:"
    ------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal_11_test/install-dir/drupal_11_test_site/web/modules/contrib/help_text/src/Form/HelpTextSettingsForm.php
    ---------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 6 WARNINGS AFFECTING 6 LINES
    ---------------------------------------------------------------------------------------------------------------------------------------------
     45 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     46 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     47 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     48 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     49 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     50 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
    ---------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 204ms; Memory: 10MB
    
    āžœ  contrib git:(main) āœ—
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi,

    Please review, check and advise on MR!1. Thank you.

Production build 0.71.5 2024