Fix the issues reported by PHPCS

Created on 5 May 2023, over 1 year ago
Updated 2 July 2024, 6 months ago

Problem/Motivation

Getting errors and warnings below in PHPCS,

FILE: /Users/studenttrainees/shield/shield.install
-------------------------------------------------------------------------
FOUND 7 ERRORS AFFECTING 7 LINES
-------------------------------------------------------------------------
133 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
134 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
135 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
136 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
137 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
138 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
139 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
-------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------

FILE: /Users/studenttrainees/shield/src/Form/ShieldSettingsForm.php
---------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------
136 | WARNING | #options values usually have to run through t() for translation
---------------------------------------------------------------------------------

FILE: /Users/studenttrainees/shield/src/ShieldMiddleware.php
--------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
--------------------------------------------------------------------------------------------------
336 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
344 | ERROR | [x] Expected newline after closing brace
--------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------

Time: 556ms; Memory: 12MB

Steps to reproduce

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

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

šŸ› Bug report
Status

Closed: outdated

Version

1.7

Component

Code

Created by

šŸ‡µšŸ‡­Philippines clarkssquared

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

Merge Requests

Comments & Activities

  • Issue created by @clarkssquared
  • Open on Drupal.org ā†’
    Core: 9.5.5 + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    Not currently mergeable.
  • Open in Jenkins ā†’ Open on Drupal.org ā†’
    Core: 9.5.5 + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    PHPLint Failed
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • šŸ‡µšŸ‡­Philippines clarkssquared

    Created an MR to fix the issues reported by phpcs.

    Please review.
    Thank You.

  • Open in Jenkins ā†’ Open on Drupal.org ā†’
    Core: 9.5.5 + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    9 pass
  • Hi @clarkssquared , Thanks for the MR. I switched to your branch and ran the command:

    ./vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml/modules/contrib/shield

    I found 1 error.

    I run this command to fix that error:

    ./vendor/bin/phpcbf --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml modules/contrib/shield/

    I again run phpcs command and found no errors.

    Please Review.

  • šŸ‡®šŸ‡³India pray_12

    Hi,
    Applied the above patch found no errors or warnings.
    Thank You!!

  • Status changed to Needs work 7 months ago
  • šŸ‡®šŸ‡³India dev16.addweb

    I have tested MR, below Errors is remaining to fix.

    modules/custom/shield/
    
    FILE: /home/addweb/Drupal8-vagrant/web/web/contribution/drupal-10-3/web/modules/custom/shield/src/ShieldMiddleware.php
    --------------------------------------------------------------------------------------------------------------------------
    FOUND 9 ERRORS AFFECTING 8 LINES
    --------------------------------------------------------------------------------------------------------------------------
     110 | ERROR | [x] The first parameter of a multi-line function declaration must be on the line after the opening bracket
     111 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
     112 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
     113 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
     114 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
     115 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
     116 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
     117 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
     117 | ERROR | [x] The closing parenthesis of a multi-line function declaration must be on a new line
    --------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 9 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /home/addweb/Drupal8-vagrant/web/web/contribution/drupal-10-3/web/modules/custom/shield/src/Form/ShieldSettingsForm.php
    -----------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------
     8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Form\ConfigFormBase.
    -----------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------
    
    Time: 259ms; Memory: 12MB
    
  • Open in Jenkins ā†’ Open on Drupal.org ā†’
    Core: 9.5.5 + Environment: PHP 7.4 & MySQL 5.7
    last update 7 months ago
    PHPLint Failed
  • Status changed to Needs review 7 months ago
  • šŸ‡®šŸ‡³India dev16.addweb

    I have Fixed Errors mention on #7, Please review.

  • šŸ‡µšŸ‡­Philippines clarkssquared

    Hi

    I applied the updated MR !11 and I confirmed that the PHPCS issues were resolved.

    āžœ  shield git:(main) āœ— curl https://git.drupalcode.org/project/shield/-/merge_requests/11.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  4345    0  4345    0     0   7400      0 --:--:-- --:--:-- --:--:--  7504
    patching file shield.install
    patching file 'src/Form/ShieldSettingsForm.php'
    patching file 'src/ShieldMiddleware.php'
    āžœ  shield git:(main) āœ— ..
    āžœ  contrib git:(main) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml shield 
    
    FILE: ...ubing/Projects/d10/drupal_local/web/modules/contrib/shield/shield.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
    --------------------------------------------------------------------------------
    
    Time: 518ms; Memory: 12MB
    
    āžœ  contrib git:(main) āœ— 
    

    retaining the status to needs review to give way to others for their feedback

  • Status changed to Closed: outdated 6 months ago
  • šŸ‡ŗšŸ‡øUnited States japerry KVUO
Production build 0.71.5 2024