Fix phpcs errors and warnings

Created on 11 November 2022, about 2 years ago
Updated 30 July 2024, 5 months ago

Problem/Motivation

There are a few Phpcs issues which have been reported and needs to be fixed!

Steps to reproduce

Running phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,js shows the following warnings/errors, which should be fixed.

FILE: /app/web/themes/custom/sailor/js/script.js
----------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
----------------------------------------------------------------------
 15 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
 18 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected
    |       |     "FALSE" but found "false"
 19 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected
    |       |     "FALSE" but found "false"
----------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: /app/web/themes/custom/sailor/sailor.theme
----------------------------------------------------------------------
FOUND 10 ERRORS AFFECTING 10 LINES
----------------------------------------------------------------------
  12 | ERROR | [x] Use statements should be sorted alphabetically.
     |       |     The first wrong one is
     |       |     Drupal\Component\Utility\Html.
 272 | ERROR | [x] Functions must not contain multiple empty lines in
     |       |     a row; found 2 empty lines
 275 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
     |       |     found 1
 279 | ERROR | [x] Closing brace indented incorrectly; expected 1
     |       |     spaces, found 2
 292 | ERROR | [x] Functions must not contain multiple empty lines in
     |       |     a row; found 2 empty lines
 302 | ERROR | [x] Whitespace found at end of line
 306 | ERROR | [x] Whitespace found at end of line
 312 | ERROR | [x] Whitespace found at end of line
 588 | ERROR | [x] Inline comments must end in full-stops,
     |       |     exclamation marks, question marks, colons, or
     |       |     closing parentheses
 910 | ERROR | [x] Use null coalesce operator instead of ternary
     |       |     operator.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 10 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: /app/web/themes/custom/sailor/webpack.config.js
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
  34 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected
     |       |     "TRUE" but found "true"
 102 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected
     |       |     "TRUE" but found "true"
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 322ms; Memory: 18MB
📌 Task
Status

Fixed

Version

3.0

Component

Code

Created by

🇮🇳India arti_parmar

Live updates comments and jobs are added and updated live.
  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Issue was unassigned.
  • Status changed to Active 5 months ago
  • Hello @davidwbarratt,
    A few Phpcs issues are still there, so I think it'll be a good idea to reopen this issue only to address them, instead of creating new issue for the same purpose.
    As of now, I'm getting all these Phpcs issues which can be fixed:

    FILE: /app/web/themes/custom/sailor/js/script.js
    ----------------------------------------------------------------------
    FOUND 3 ERRORS AFFECTING 3 LINES
    ----------------------------------------------------------------------
     15 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
     18 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected
        |       |     "FALSE" but found "false"
     19 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected
        |       |     "FALSE" but found "false"
    ----------------------------------------------------------------------
    PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------
    
    
    FILE: /app/web/themes/custom/sailor/sailor.theme
    ----------------------------------------------------------------------
    FOUND 10 ERRORS AFFECTING 10 LINES
    ----------------------------------------------------------------------
      12 | ERROR | [x] Use statements should be sorted alphabetically.
         |       |     The first wrong one is
         |       |     Drupal\Component\Utility\Html.
     272 | ERROR | [x] Functions must not contain multiple empty lines in
         |       |     a row; found 2 empty lines
     275 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
         |       |     found 1
     279 | ERROR | [x] Closing brace indented incorrectly; expected 1
         |       |     spaces, found 2
     292 | ERROR | [x] Functions must not contain multiple empty lines in
         |       |     a row; found 2 empty lines
     302 | ERROR | [x] Whitespace found at end of line
     306 | ERROR | [x] Whitespace found at end of line
     312 | ERROR | [x] Whitespace found at end of line
     588 | ERROR | [x] Inline comments must end in full-stops,
         |       |     exclamation marks, question marks, colons, or
         |       |     closing parentheses
     910 | ERROR | [x] Use null coalesce operator instead of ternary
         |       |     operator.
    ----------------------------------------------------------------------
    PHPCBF CAN FIX THE 10 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------
    
    
    FILE: /app/web/themes/custom/sailor/webpack.config.js
    ----------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    ----------------------------------------------------------------------
      34 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected
         |       |     "TRUE" but found "true"
     102 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected
         |       |     "TRUE" but found "true"
    ----------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------
    
    Time: 322ms; Memory: 18MB
  • First commit to issue fork.
  • Merge request !93320722-fix-phpcs-errors:fixed phpcs issues → (Merged) created by bhaveshdas
  • Status changed to Needs review 5 months ago
  • 🇮🇳India bhaveshdas

    I have fixed phpcs Issues could you please review it.

    Thankyou !

  • Status changed to RTBC 5 months ago
  • 🇮🇳India prem suthar Ahemdabad- Gujrat , Jodhpur - Rajsthan

    Hi,

    I have verified the PHPCS issue with the #3320722 merge request applied cleanly in the Drupal 10 version.

    Testing Steps:
    -> Install the Drupal 10 version.
    -> Open the command line and run PHPCS on this module.
    -> Check for errors and warnings.

    Testing Results:
    Showing no errors and warnings.

    Attached The after screenshots. Based on these results, the issue can be moved to RTBC.

    RTBC+1

  • Status changed to Fixed 5 months ago
  • Thanks all for the prompt action. A small correction on the issue metadata, which I forgot to change previously. The phpcs issues seemed to be persistent on the latest version of the theme as well, though the MR solves all the Phpcs issues on the latest version as well!

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

Production build 0.71.5 2024