Fix the errors/warnings reported by PHP_CodeSniffer

Created on 14 March 2024, 9 months ago
Updated 24 June 2024, 6 months ago

Problem/Motivation

The module must follow the correct Drupal coding standards. So, when developing it, make sure to run phpcs --standard=Drupal,DrupalPractice on the project. This will fix most issues that reviewers might find.

FILE: .../Projects/contribution/prod_no_redirect/lib/ProdNoRedirectDrupalKernel.php
--------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------
  8 | ERROR | [x] Missing class doc comment
 10 | ERROR | [x] Missing function doc comment
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: ..._no_redirect/src/EventSubscriber/ExceptionDetectNeedsInstallSubscriber.php
--------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------
 10 | ERROR | [ ] Namespaced classes/interfaces/traits should be referenced
    |       |     with use statements
 12 | ERROR | [x] Missing function doc comment
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

Time: 34ms; Memory: 10MB

Steps to reproduce

Run the following command:

  • phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml {module_path e.g /web/custom/{module_path}.}
📌 Task
Status

Fixed

Version

1.0

Component

Code

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

Merge Requests

Comments & Activities

  • Issue created by @sunil_lnwebworks
  • I got the following when I run the phpcs command

    FILE: /Users/mac/contribution/my_site_name/web/modules/contrib/prod_no_redirect/lib/ProdNoRedirectDrupalKernel.php
    ------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    ------------------------------------------------------------------------------------------------------------------
      8 | ERROR | [x] Missing class doc comment
     10 | ERROR | [x] Missing function doc comment
    ------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/mac/contribution/my_site_name/web/modules/contrib/prod_no_redirect/prod_no_redirect.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
    -------------------------------------------------------------------------------------------------------------
    ➜  prod_no_redirect git:(master) ✗ /Users/mac/project/phpcs/vendor/bin/phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml   /Users/mac/contribution/my_site_name/web/modules/contrib/prod_no_redirect
    
    
    FILE: /Users/mac/contribution/my_site_name/web/modules/contrib/prod_no_redirect/README.md
    -----------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    -----------------------------------------------------------------------------------------
      7 | WARNING | Line exceeds 80 characters; contains 85 characters
     13 | WARNING | Line exceeds 80 characters; contains 120 characters
    -----------------------------------------------------------------------------------------
    
    
    FILE: /Users/mac/contribution/my_site_name/web/modules/contrib/prod_no_redirect/lib/ProdNoRedirectDrupalKernel.php
    ------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    ------------------------------------------------------------------------------------------------------------------
      8 | ERROR | [x] Missing class doc comment
     10 | ERROR | [x] Missing function doc comment
    ------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/mac/contribution/my_site_name/web/modules/contrib/prod_no_redirect/prod_no_redirect.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
    -------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/mac/contribution/my_site_name/web/modules/contrib/prod_no_redirect/src/EventSubscriber/ExceptionDetectNeedsInstallSubscriber.php
    ---------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    ---------------------------------------------------------------------------------------------------------------------------------------------
     10 | ERROR | [ ] Namespaced classes/interfaces/traits should be referenced with use statements
     12 | ERROR | [x] Missing function doc comment
    ---------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 63ms; Memory: 8MB
    
  • gaurav gupta Jaipur, Rajasthsan

    Gaurav Gupta made their first commit to this issue’s fork.

  • 🇮🇳India sakthi_dev

    Updated IS with the issues of phpcs.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Status changed to Needs review 9 months ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Pipeline finished with Success
    9 months ago
    Total: 138s
    #126908
  • Status changed to RTBC 9 months ago
  • 🇵🇭Philippines clarkssquared

    Hi

    I applied MR !1 and I confirmed that I can no longer see any PHPCS issues/errors.

    ➜  prod_no_redirect git:(1.0.x) curl https://git.drupalcode.org/project/prod_no_redirect/-/merge_requests/1.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  8391    0  8391    0     0  14629      0 --:--:-- --:--:-- --:--:-- 14798
    patching file .gitlab-ci.yml
    patching file 'lib/ProdNoRedirectDrupalKernel.php'
    patching file 'src/EventSubscriber/ExceptionDetectNeedsInstallSubscriber.php'
    ➜  prod_no_redirect git:(1.0.x) ✗ ..
    ➜  contrib git:(master) ✗ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml prod_no_redirect 
    ➜  contrib git:(master) ✗ 
    
    
  • Status changed to Needs review 8 months ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Pipeline finished with Success
    8 months ago
    Total: 145s
    #161297
  • Status changed to RTBC 6 months ago
  • 🇮🇳India deepak5423

    No Phpcs error in !MR1.

  • Status changed to Fixed 6 months ago
  • 🇺🇸United States moshe weitzman Boston, MA
  • gaurav gupta Jaipur, Rajasthsan

    Hi @Moshe Weitzman
    i can see that PR has been merged but we have not get the credit for the issue.
    It would be great if you could ptovide the credit.
    Thanks.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024