Fix the issues reported by PHP_CodeSniffer

Created on 25 September 2024, about 2 months ago

Problem/Motivation

FILE: modules\freshmail\freshmail.install
-------------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------------------------------------------------
14 | ERROR | [x] Short array syntax must be used to define arrays
24 | ERROR | [ ] The array declaration extends to column 241 (the limit is 120). The array content should be split up over multiple lines
24 | ERROR | [x] Short array syntax must be used to define arrays
-------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------------------

FILE: modules\freshmail\modules\freshmail_block\src\Forms\FreshmailBlockForm.php
--------------------------------------------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 4 LINES
--------------------------------------------------------------------------------------------------------
26 | ERROR | [x] Short array syntax must be used to define arrays
27 | ERROR | [x] Short array syntax must be used to define arrays
32 | ERROR | [x] Short array syntax must be used to define arrays
38 | ERROR | [x] Short array syntax must be used to define arrays
--------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------

FILE: modules\freshmail\modules\freshmail_block\src\Plugin\Block\FreshmailBlock.php
-----------------------------------------------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 4 LINES
-----------------------------------------------------------------------------------------------------------
62 | ERROR | [x] Short array syntax must be used to define arrays
72 | ERROR | [x] Short array syntax must be used to define arrays
78 | ERROR | [x] Short array syntax must be used to define arrays
110 | ERROR | [x] Short array syntax must be used to define arrays
-----------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------

FILE: modules\freshmail\src\Controller\FreshmailController.php
---------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES
---------------------------------------------------------------------------------------------------------------------
11 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
14 | ERROR | [ ] Missing member variable doc comment
32 | ERROR | [x] Short array syntax must be used to define arrays
---------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------

FILE: modules\freshmail\src\Controller\FreshmailRestController.php
-----------------------------------------------------------------------------------------------------------------------
FOUND 10 ERRORS AFFECTING 10 LINES
-----------------------------------------------------------------------------------------------------------------------
9 | ERROR | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
11 | ERROR | [x] Doc comment long description must end with a full stop
20 | ERROR | [ ] Missing member variable doc comment
21 | ERROR | [ ] Missing member variable doc comment
22 | ERROR | [ ] Missing member variable doc comment
23 | ERROR | [ ] Missing member variable doc comment
25 | ERROR | [ ] Missing member variable doc comment
77 | ERROR | [x] Short array syntax must be used to define arrays
91 | ERROR | [x] Short array syntax must be used to define arrays
134 | ERROR | [x] Short array syntax must be used to define arrays
-----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------

FILE: modules\freshmail\src\Forms\FreshmailSettingsForm.php
-----------------------------------------------------------------------------------
FOUND 3 ERRORS AND 1 WARNING AFFECTING 4 LINES
-----------------------------------------------------------------------------------
40 | ERROR | [x] Short array syntax must be used to define arrays
47 | ERROR | [x] Short array syntax must be used to define arrays
54 | ERROR | [x] Short array syntax must be used to define arrays
68 | WARNING | [x] 'TODO.' should match the format '@todo Fix problem X here.'
-----------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 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

2.0

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
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi @sunil jolapara,

    Thank you for providing an MR. I applied MR!2, it was applied smoothly and fixed most of the phpcs issues.

    This is the remaining issues after I ran

    phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml
    

    :

    āžœ  freshmail git:(2.0.0-alpha1) curl https://git.drupalcode.org/project/freshmail/-/merge_requests/2.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  9703    0  9703    0     0  20619      0 --:--:-- --:--:-- --:--:-- 20644
    patching file freshmail.install
    patching file modules/freshmail_block/src/Forms/FreshmailBlockForm.php
    patching file modules/freshmail_block/src/Plugin/Block/FreshmailBlock.php
    patching file src/Controller/FreshmailController.php
    patching file src/Controller/FreshmailRestController.php
    patching file src/Forms/FreshmailSettingsForm.php
    āžœ  freshmail git:(2.0.0-alpha1) āœ— ..
    āžœ  contrib git:(main) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml freshmail
    
    FILE: /Users/interns/Demo-site/drupal_11_test/install-dir/drupal_11_test_site/web/modules/contrib/freshmail/modules/freshmail_block/freshmail_block.info.yml
    ------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------------------------------------------
     7 | ERROR | "dependencies" should be an array in the info yaml file
    ------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 244ms; Memory: 10MB
    
    āžœ  contrib git:(main) āœ—

    Thank you.

  • šŸ‡®šŸ‡¹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.

  • Merge request !3Add gitlab-ci template ā†’ (Open) created by cleavinjosh
  • Pipeline finished with Success
    about 2 months ago
    Total: 146s
    #298082
  • Pipeline finished with Success
    about 2 months ago
    Total: 133s
    #298103
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi,

    Please review MR!3. Thank you.

  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹

    avpaderno ā†’ changed the visibility of the branch 3476684- to hidden.

  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • Pipeline finished with Success
    22 days ago
    Total: 156s
    #325805
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi @avpaderno,

    Please check and advise.

    Thank you.

  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi @avpaderno,

    Please check and advise. Thank you.

  • Pipeline finished with Success
    16 days ago
    Total: 153s
    #330866
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹

    The merge request seems fine.

Production build 0.71.5 2024