Fix the issues reported by PHP_CodeSniffer

Created on 25 September 2024, about 2 months ago

Problem/Motivation

FILE: modules\account_modal\account_modal.install
-------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-------------------------------------------------------------------------
1 | ERROR | [x] Missing file doc comment
4 | ERROR | [x] Doc comment short description must end with a full stop
-------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------

FILE: modules\account_modal\account_modal.module
---------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 7 ERRORS AND 1 WARNING AFFECTING 8 LINES
---------------------------------------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] Missing file doc comment
60 | ERROR | [x] Namespaced classes/interfaces/traits should be referenced with use statements
110 | WARNING | [x] 'TODO: Use this to prepend/append blocks and modify output as necessary.' should match the format '@todo Fix problem X here.'
113 | ERROR | [x] Missing function doc comment
117 | ERROR | [x] Missing function doc comment
121 | ERROR | [x] Missing function doc comment
125 | ERROR | [x] Missing function doc comment
129 | ERROR | [x] Missing function doc comment
---------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------------

FILE: modules\account_modal\src\AccountModalAjaxHelper.php
------------------------------------------------------------------------------------------------------------------------------------
FOUND 31 ERRORS AFFECTING 28 LINES
------------------------------------------------------------------------------------------------------------------------------------
10 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Ajax\CloseModalDialogCommand.
21 | ERROR | [ ] Missing short description in doc comment
22 | ERROR | [ ] Missing parameter comment
22 | ERROR | [ ] Missing parameter type
23 | ERROR | [ ] Missing parameter comment
24 | ERROR | [ ] Missing parameter comment
26 | ERROR | [ ] Description for the @return value is missing
68 | ERROR | [x] Expected 1 space after IF keyword; 0 found
68 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
73 | ERROR | [x] Expected newline after closing brace
79 | ERROR | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
84 | ERROR | [ ] Missing short description in doc comment
85 | ERROR | [ ] Missing parameter comment
87 | ERROR | [ ] Description for the @return value is missing
99 | ERROR | [ ] Missing short description in doc comment
100 | ERROR | [ ] Missing parameter comment
102 | ERROR | [ ] Description for the @return value is missing
115 | ERROR | [ ] Missing short description in doc comment
116 | ERROR | [ ] Missing parameter comment
118 | ERROR | [ ] Description for the @return value is missing
141 | ERROR | [ ] Missing short description in doc comment
142 | ERROR | [ ] Missing parameter comment
155 | ERROR | [ ] Missing short description in doc comment
156 | ERROR | [ ] Missing parameter comment
190 | ERROR | [ ] Missing short description in doc comment
191 | ERROR | [ ] Missing parameter comment
193 | ERROR | [ ] Description for the @return value is missing
220 | ERROR | [ ] Missing short description in doc comment
221 | ERROR | [ ] Missing parameter comment
221 | ERROR | [ ] Missing parameter type
223 | ERROR | [ ] Description for the @return value is missing
------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------

FILE: modules\account_modal\src\AccountPageHelper.php
-----------------------------------------------------------------------------
FOUND 24 ERRORS AFFECTING 20 LINES
-----------------------------------------------------------------------------
16 | ERROR | Missing short description in doc comment
17 | ERROR | Description for the @return value is missing
73 | ERROR | Missing short description in doc comment
74 | ERROR | Description for the @return value is missing
87 | ERROR | Missing short description in doc comment
88 | ERROR | Missing parameter comment
88 | ERROR | Missing parameter type
90 | ERROR | Description for the @return value is missing
103 | ERROR | Missing short description in doc comment
104 | ERROR | Description for the @return value is missing
117 | ERROR | Missing short description in doc comment
118 | ERROR | Description for the @return value is missing
135 | ERROR | Missing short description in doc comment
136 | ERROR | Missing parameter comment
136 | ERROR | Missing parameter type
138 | ERROR | Description for the @return value is missing
150 | ERROR | Missing short description in doc comment
151 | ERROR | Missing parameter comment
151 | ERROR | Missing parameter type
153 | ERROR | Description for the @return value is missing
177 | ERROR | Missing short description in doc comment
178 | ERROR | Missing parameter comment
178 | ERROR | Missing parameter type
180 | ERROR | Description for the @return value is missing
-----------------------------------------------------------------------------

FILE: modules\account_modal\src\Event\PagesEvent.php
----------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------------
44 | ERROR | Missing parameter comment
46 | ERROR | Description for the @return value is missing

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

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.

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

    Hi @sunil jolapara,

    Thank you for providing an MR. I applied MR!3, 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:

    āžœ  account_modal git:(8.x-1.x) curl https://git.drupalcode.org/project/account_modal/-/merge_requests/3.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 14882    0 14882    0     0  35167      0 --:--:-- --:--:-- --:--:-- 35182
    patching file account_modal.install
    patching file account_modal.module
    patching file src/AccountModalAjaxHelper.php
    patching file src/AccountPageHelper.php
    patching file src/Event/PagesEvent.php
    āžœ  account_modal 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 account_modal
    
    FILE: /Users/interns/Demo-site/drupal_11_test/install-dir/drupal_11_test_site/web/modules/contrib/account_modal/src/AccountPageHelper.php
    -----------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------------
     135 | WARNING | Unused variable $pageId.
    -----------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal_11_test/install-dir/drupal_11_test_site/web/modules/contrib/account_modal/src/Form/AccountModalSettingsForm.php
    -----------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
    -----------------------------------------------------------------------------------------------------------------------------------------------------
      95 | WARNING | #options values usually have to run through t() for translation
      96 | WARNING | #options values usually have to run through t() for translation
     103 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    -----------------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 336ms; Memory: 12MB
    
    āžœ  contrib git:(main) āœ—
  • Pipeline finished with Success
    7 days ago
    Total: 214s
    #339623
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    cleavinjosh ā†’ changed the visibility of the branch 3476664-phpcs-issues to hidden.

  • Pipeline finished with Success
    7 days ago
    Total: 185s
    #339632
  • Pipeline finished with Success
    7 days ago
    Total: 149s
    #339644
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi,

    Please review MR!3. Thank you.

Production build 0.71.5 2024