Fix the issues reported by phpcs

Created on 9 January 2023, almost 2 years ago
Updated 14 December 2023, about 1 year ago

Steps to reproduce

Run following command
phpcs --standard=“Drupal,DrupalPractice” --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml .

Problem/Motivation

FILE: /var/www/html/Drupal/drupalp/web/modules/contrib/config_token/src/Form/ConfigTokensForm.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 7 ERRORS AND 3 WARNINGS AFFECTING 10 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
   5 | WARNING | [x] Unused use statement
  76 | ERROR   | [x] Short array syntax must be used to define arrays
  79 | ERROR   | [x] Short array syntax must be used to define arrays
  97 | ERROR   | [x] Concat operator must be surrounded by a single space
 114 | ERROR   | [x] Whitespace found at end of line
 122 | ERROR   | [x] Whitespace found at end of line
 127 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 130 | WARNING | [x] A comma should follow the last multiline array item. Found: )
 134 | ERROR   | [x] Short array syntax must be used to define arrays
 136 | ERROR   | [x] Short array syntax must be used to define arrays
----------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 9 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/Drupal/drupalp/web/modules/contrib/config_token/src/Form/AllowedConfigTokensForm.php
--------------------------------------------------------------------------------------------------------
FOUND 4 ERRORS AND 2 WARNINGS AFFECTING 6 LINES
--------------------------------------------------------------------------------------------------------
   5 | WARNING | [x] Unused use statement
   8 | WARNING | [x] Unused use statement
  51 | ERROR   | [x] Short array syntax must be used to define arrays
  54 | ERROR   | [x] Short array syntax must be used to define arrays
  95 | ERROR   | [x] Whitespace found at end of line
 103 | ERROR   | [x] Whitespace found at end of line
--------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------


FILE: /var/www/html/Drupal/drupalp/web/modules/contrib/config_token/tests/src/Functional/ConfigTokenContent.php
---------------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 4 WARNINGS AFFECTING 6 LINES
---------------------------------------------------------------------------------------------------------------------------------------------
  5 | WARNING | [x] Unused use statement
  6 | WARNING | [x] Unused use statement
  7 | WARNING | [x] Unused use statement
 24 | ERROR   | [ ] The array declaration extends to column 96 (the limit is 80). The array content should be split up over multiple lines
 29 | ERROR   | [x] Visibility must be declared on method "testTokenFilter"
 35 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
---------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/Drupal/drupalp/web/modules/contrib/config_token/tests/src/Functional/ConfigTokenTest.php
------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 1 WARNING AFFECTING 3 LINES
------------------------------------------------------------------------------------------------------------
  5 | WARNING | [x] Unused use statement
 22 | ERROR   | [x] Visibility must be declared on method "testTokens"
 30 | ERROR   | [x] Expected 1 space after comma in argument list; 2 found
 30 | ERROR   | [x] Expected one space after the comma, 2 found
------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/Drupal/drupalp/web/modules/contrib/config_token/tests/src/Functional/ConfigTokenAdminUi.php
---------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------
 5 | WARNING | [x] Unused use statement
---------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/Drupal/drupalp/web/modules/contrib/config_token/tests/src/Functional/ConfigTokenBase.php
---------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 5 LINES
---------------------------------------------------------------------------------------------------------------------------------------------
  6 | WARNING | [x] Unused use statement
  7 | WARNING | [x] Unused use statement
  8 | WARNING | [x] Unused use statement
 62 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 68 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
---------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------

Time: 74ms; Memory: 10MB

📌 Task
Status

Needs review

Version

1.0

Component

Code

Created by

🇮🇳India Vinni_Kadyan

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.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    The issue summary should always describe what the issue is trying to fix and, in the case, of coding standards issues, show which command has been used, which arguments have been used, and which report that command shown.

  • Status changed to Needs review over 1 year ago
  • 🇨🇦Canada imustakim Canada

    Issue summary updated.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • First commit to issue fork.
  • 🇮🇳India rahulrasgon

    rahulrasgon changed the visibility of the branch 8.x-1.x to hidden.

  • 🇮🇳India rahulrasgon

    Patch provided in https://www.drupal.org/project/config_token/issues/3331946#comment-14858795 📌 Fix the issues reported by phpcs Needs review is relative to the project root directory not relative to the module directly.

    Created the correct MR for easy merge https://git.drupalcode.org/project/config_token/-/merge_requests/3

    Also verify by running the following command

    phpcs --standard=“Drupal,DrupalPractice” --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml

    No issues are reported now.

    Thanks

    Please review.

  • Status changed to Needs work about 1 year ago
  • 🇵🇭Philippines clarkssquared

    Hi

    I applied the MR !3 but there are still many issues that needs to be resolved

    ➜  config_token git:(8.x-1.6) curl https://git.drupalcode.org/project/config_token/-/merge_requests/3.diff | patch -p
    1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  8744    0  8744    0     0  14779      0 --:--:-- --:--:-- --:--:-- 14972
    patching file 'src/Form/AllowedConfigTokensForm.php'
    patching file 'src/Form/ConfigTokensForm.php'
    patching file 'tests/src/Functional/ConfigTokenAdminUi.php'
    patching file 'tests/src/Functional/ConfigTokenBase.php'
    patching file 'tests/src/Functional/ConfigTokenContent.php'
    patching file 'tests/src/Functional/ConfigTokenTest.php'
    ➜  config_token git:(8.x-1.6) ✗ ..
    ➜  contrib git:(master) ✗ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml config_token
    
    FILE: ...arksubing-subing/Projects/d9/d9-local/web/modules/contrib/config_token/tests/src/Functional/ConfigTokenTest.php
    ---------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------
     6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Link.
    ---------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/config_token/config_token.module
    ---------------------------------------------------------------------------------------------------------------------
    FOUND 11 ERRORS AND 2 WARNINGS AFFECTING 13 LINES
    ---------------------------------------------------------------------------------------------------------------------
      5 | ERROR   | [x] Doc comment short description must start with a capital letter
      9 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is
        |         |     Drupal\Core\Render\BubbleableMetadata.
     29 | ERROR   | [x] Short array syntax must be used to define arrays
     30 | ERROR   | [x] Short array syntax must be used to define arrays
     41 | ERROR   | [x] Short array syntax must be used to define arrays
     43 | WARNING | [x] A comma should follow the last multiline array item. Found: )
     47 | ERROR   | [x] Short array syntax must be used to define arrays
     48 | ERROR   | [x] Short array syntax must be used to define arrays
     49 | ERROR   | [x] Short array syntax must be used to define arrays
     56 | ERROR   | [x] Additional blank lines found at end of doc comment
     58 | ERROR   | [x] Short array syntax must be used to define arrays
     67 | WARNING | [ ] Line exceeds 80 characters; contains 89 characters
     69 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
    ---------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 12 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/config_token/README.md
    -----------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
    -----------------------------------------------------------------------------------------------
     21 | WARNING | Line exceeds 80 characters; contains 87 characters
     29 | WARNING | Line exceeds 80 characters; contains 107 characters
     30 | WARNING | Line exceeds 80 characters; contains 91 characters
     33 | WARNING | Line exceeds 80 characters; contains 134 characters
    -----------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/config_token/src/Form/ConfigTokensForm.php
    ---------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------
     6 | 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: 341ms; Memory: 10MB
    
    ➜  contrib git:(master) ✗

    moving this to needs work

  • First commit to issue fork.
  • Status changed to Needs review about 1 year ago
  • Hi,
    Updated the MR3 , Kindly review the changes.

  • 🇬🇧United Kingdom marcelovani London

    PR looks good, pls confirm that everything still works as expected and we can merge.

  • Hi @marcelovani,

    I have tested the MR3 against the dev build, patch applies cleanly and it successfully resolves all code style errors /warnings. Everything is working as expected. I recommend moving it to RTBC .

Production build 0.71.5 2024