Fix the issues reported by PHPCS

Created on 5 May 2023, about 1 year ago
Updated 10 June 2024, 13 days 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

Needs review

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 about 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 about 1 year ago
    PHPLint Failed
  • Issue was unassigned.
  • Status changed to Needs review about 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 11 months 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 Preethy_ray

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

  • Status changed to Needs work 13 days 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 13 days ago
    PHPLint Failed
  • Status changed to Needs review 13 days ago
  • 🇮🇳India dev16.addweb

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

Production build 0.69.0 2024