Fix the issues reported by PHP_CodeSniffer

Created on 24 September 2024, 4 months ago

Problem/Motivation

FILE: D:\wamp64\www\d10_2_2\modules\menu_banner\menu_banner.admin.inc
--------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
--------------------------------------------------------------------------
18 | ERROR | [x] Use null coalesce operator instead of ternary operator.
32 | ERROR | [x] Use null coalesce operator instead of ternary operator.
33 | ERROR | [x] Array indentation error, expected 6 spaces but found 7
35 | ERROR | [x] Use null coalesce operator instead of ternary operator.
36 | ERROR | [x] Array indentation error, expected 6 spaces but found 7
--------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------

FILE: D:\wamp64\www\d10_2_2\modules\menu_banner\menu_banner.info
------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 3 WARNINGS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------
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
1 | ERROR | [ ] Duplicate entry for "core" in info file
12 | ERROR | [x] Expected 1 newline at end of file; 2 found
------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------

FILE: D:\wamp64\www\d10_2_2\modules\menu_banner\menu_banner.install
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
1 | ERROR | [x] Missing file doc comment
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: D:\wamp64\www\d10_2_2\modules\menu_banner\menu_banner.module
---------------------------------------------------------------------------------------------------------------------------------------
FOUND 16 ERRORS AFFECTING 14 LINES
---------------------------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] Missing file doc comment
62 | ERROR | [x] Use null coalesce operator instead of ternary operator.
157 | ERROR | [x] Use null coalesce operator instead of ternary operator.
162 | ERROR | [x] Use null coalesce operator instead of ternary operator.
163 | ERROR | [x] Array indentation error, expected 6 spaces but found 7
167 | ERROR | [x] Use null coalesce operator instead of ternary operator.
167 | ERROR | [ ] The array declaration extends to column 127 (the limit is 120). The array content should be split up over multiple
| | lines
172 | ERROR | [x] Array indentation error, expected 6 spaces but found 7
172 | ERROR | [x] Use null coalesce operator instead of ternary operator.
174 | ERROR | [x] Use null coalesce operator instead of ternary operator.
175 | ERROR | [x] Array indentation error, expected 6 spaces but found 7
224 | ERROR | [ ] Description for the @return value is missing
228 | ERROR | [x] Use null coalesce operator instead of ternary operator.
231 | ERROR | [x] Use null coalesce operator instead of ternary operator.
269 | ERROR | [ ] Missing parameter comment
280 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
---------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 13 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.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
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹

    A Drupal 7 module cannot use the null coalescing operator, since Drupal 7 still runs on PHP 5.6, not PHP 7.

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

    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:

    āžœ  menu_banner git:(7.x-1.x) curl https://git.drupalcode.org/project/menu_banner/-/merge_requests/1.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  4705    0  4705    0     0  10746      0 --:--:-- --:--:-- --:--:-- 10742
    patching file menu_banner.install
    patching file menu_banner.module
    āžœ  menu_banner git:(7.x-1.x) āœ— ..
    āžœ  contrib git:(main) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml menu_banner
    
    FILE: /Users/interns/Demo-site/drupal_11_test/install-dir/drupal_11_test_site/web/modules/contrib/menu_banner/menu_banner.admin.inc
    -----------------------------------------------------------------------------------------------------------------------------------
    FOUND 5 ERRORS AFFECTING 5 LINES
    -----------------------------------------------------------------------------------------------------------------------------------
     18 | ERROR | [x] Use null coalesce operator instead of ternary operator.
     32 | ERROR | [x] Use null coalesce operator instead of ternary operator.
     33 | ERROR | [x] Array indentation error, expected 6 spaces but found 7
     35 | ERROR | [x] Use null coalesce operator instead of ternary operator.
     36 | ERROR | [x] Array indentation error, expected 6 spaces but found 7
    -----------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------
    
    Time: 222ms; Memory: 10MB
    
    āžœ  contrib git:(main) āœ—

    Thank you.

  • Pipeline finished with Success
    about 1 month ago
    Total: 131s
    #366428
  • šŸ‡µšŸ‡­Philippines cleavinjosh

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

  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi,

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

Production build 0.71.5 2024