Fix the issues reported by phpcs

Created on 7 July 2020, almost 4 years ago
Updated 12 March 2024, 3 months ago

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

FILE: ./README.txt
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
 14 | WARNING | Line exceeds 80 characters; contains 108 characters
 43 | WARNING | Line exceeds 80 characters; contains 303 characters
----------------------------------------------------------------------


FILE: ./block_list_override.install
----------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
----------------------------------------------------------------------
 37 | ERROR | [x] Spaces must be used to indent lines; tabs are not
    |       |     allowed
 38 | ERROR | [x] Spaces must be used to indent lines; tabs are not
    |       |     allowed
 39 | ERROR | [x] Spaces must be used to indent lines; tabs are not
    |       |     allowed
----------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./block_list_override.links.menu.yml
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | ERROR | [x] Expected 1 newline at end of file; 2 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./config/install/block_list_override.settings.yml
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 8 | ERROR | [x] Expected 1 newline at end of file; 2 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/BlockListOverride.php
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 1 LINE
----------------------------------------------------------------------
 148 | ERROR | [x] Expected 1 space after IF keyword; 0 found
 148 | ERROR | [x] Expected 1 space after closing parenthesis; found
     |       |     0
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Controller/DefaultController.php
----------------------------------------------------------------------
FOUND 5 ERRORS AND 1 WARNING AFFECTING 6 LINES
----------------------------------------------------------------------
   7 | ERROR   | [x] Use statements should be sorted alphabetically.
     |         |     The first wrong one is
     |         |     Drupal\Core\Block\BlockManagerInterface.
  14 | WARNING | [ ] The class short comment should describe what the
     |         |     class does and not simply repeat the class name
  49 | ERROR   | [x] Parameter comment indentation must be 3 spaces,
     |         |     found 2 spaces
  51 | ERROR   | [x] Parameter comment indentation must be 3 spaces,
     |         |     found 2 spaces
 129 | ERROR   | [x] Expected 1 blank line after function; 0 found
 130 | ERROR   | [x] The closing brace for the class must have an
     |         |     empty line before it
----------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Controller/LayoutController.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: ./src/Form/SettingsForm.php
----------------------------------------------------------------------
FOUND 16 ERRORS AND 16 WARNINGS AFFECTING 18 LINES
----------------------------------------------------------------------
   7 | ERROR   | [x] Use statements should be sorted alphabetically.
     |         |     The first wrong one is
     |         |     Drupal\Core\Config\ConfigFactoryInterface.
  13 | WARNING | [ ] The class short comment should describe what the
     |         |     class does and not simply repeat the class name
  31 | ERROR   | [x] Missing function doc comment
  59 | WARNING | [ ] Translatable strings must not begin or end with
     |         |     white spaces, use placeholders with t() for
     |         |     variables
  59 | ERROR   | [ ] Concatenating translatable strings is not
     |         |     allowed, use placeholders instead and only one
     |         |     string literal
  71 | WARNING | [ ] Translatable strings must not begin or end with
     |         |     white spaces, use placeholders with t() for
     |         |     variables
  71 | ERROR   | [ ] Concatenating translatable strings is not
     |         |     allowed, use placeholders instead and only one
     |         |     string literal
  84 | WARNING | [ ] Translatable strings must not begin or end with
     |         |     white spaces, use placeholders with t() for
     |         |     variables
  84 | ERROR   | [ ] Concatenating translatable strings is not
     |         |     allowed, use placeholders instead and only one
     |         |     string literal
  89 | WARNING | [ ] Translatable strings must not begin or end with
     |         |     white spaces, use placeholders with t() for
     |         |     variables
  89 | ERROR   | [ ] Concatenating translatable strings is not
     |         |     allowed, use placeholders instead and only one
     |         |     string literal
  96 | WARNING | [ ] Translatable strings must not begin or end with
     |         |     white spaces, use placeholders with t() for
     |         |     variables
  96 | ERROR   | [ ] Concatenating translatable strings is not
     |         |     allowed, use placeholders instead and only one
     |         |     string literal
  99 | WARNING | [ ] Translatable strings must not begin or end with
     |         |     white spaces, use placeholders with t() for
     |         |     variables
  99 | ERROR   | [ ] Concatenating translatable strings is not
     |         |     allowed, use placeholders instead and only one
     |         |     string literal
 105 | WARNING | [ ] Translatable strings must not begin or end with
     |         |     white spaces, use placeholders with t() for
     |         |     variables
 105 | ERROR   | [ ] Concatenating translatable strings is not
     |         |     allowed, use placeholders instead and only one
     |         |     string literal
 124 | WARNING | [ ] Translatable strings must not begin or end with
     |         |     white spaces, use placeholders with t() for
     |         |     variables
 124 | ERROR   | [ ] Concatenating translatable strings is not
     |         |     allowed, use placeholders instead and only one
     |         |     string literal
 140 | WARNING | [ ] Translatable strings must not begin or end with
     |         |     white spaces, use placeholders with t() for
     |         |     variables
 140 | ERROR   | [ ] Concatenating translatable strings is not
     |         |     allowed, use placeholders instead and only one
     |         |     string literal
 147 | WARNING | [ ] Translatable strings must not begin or end with
     |         |     white spaces, use placeholders with t() for
     |         |     variables
 147 | ERROR   | [ ] Concatenating translatable strings is not
     |         |     allowed, use placeholders instead and only one
     |         |     string literal
 161 | WARNING | [ ] Translatable strings must not begin or end with
     |         |     white spaces, use placeholders with t() for
     |         |     variables
 161 | ERROR   | [ ] Concatenating translatable strings is not
     |         |     allowed, use placeholders instead and only one
     |         |     string literal
 171 | WARNING | [ ] Translatable strings must not begin or end with
     |         |     white spaces, use placeholders with t() for
     |         |     variables
 171 | ERROR   | [ ] Concatenating translatable strings is not
     |         |     allowed, use placeholders instead and only one
     |         |     string literal
 178 | WARNING | [ ] Translatable strings must not begin or end with
     |         |     white spaces, use placeholders with t() for
     |         |     variables
 178 | ERROR   | [ ] Concatenating translatable strings is not
     |         |     allowed, use placeholders instead and only one
     |         |     string literal
 185 | WARNING | [ ] Translatable strings must not begin or end with
     |         |     white spaces, use placeholders with t() for
     |         |     variables
 185 | ERROR   | [ ] Concatenating translatable strings is not
     |         |     allowed, use placeholders instead and only one
     |         |     string literal
 196 | WARNING | [ ] Possible useless method overriding detected
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/LayoutPluginAlter.php
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
  8 | ERROR | [x] Expected 1 space before opening brace; found 0
 24 | ERROR | [x] Expected 1 newline at end of file; 2 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/PluginAlter.php
----------------------------------------------------------------------
FOUND 4 ERRORS AND 1 WARNING AFFECTING 5 LINES
----------------------------------------------------------------------
   8 | ERROR   | [x] Use statements should be sorted alphabetically.
     |         |     The first wrong one is
     |         |     Drupal\Core\Config\ConfigFactoryInterface.
   9 | WARNING | [x] Unused use statement
  37 | ERROR   | [ ] Parameter $config_factory is not described in
     |         |     comment
  40 | ERROR   | [ ] Doc comment for parameter $configFactory does
     |         |     not match actual variable name $list_service
 100 | ERROR   | [x] Expected 1 newline at end of file; 2 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./tests/src/Functional/BlockListOverrideTest.php
----------------------------------------------------------------------
FOUND 10 ERRORS AND 1 WARNING AFFECTING 7 LINES
----------------------------------------------------------------------
  34 | ERROR   | [ ] Missing @var tag in member variable comment
  70 | ERROR   | [x] Expected 3 space(s) before asterisk; 4 found
  71 | ERROR   | [x] Expected 3 space(s) before asterisk; 4 found
  71 | ERROR   | [ ] Missing @var tag in member variable comment
  86 | WARNING | [ ] Line exceeds 80 characters; contains 82
     |         |     characters
 145 | ERROR   | [x] No space found before comment text; expected "//
     |         |     sleep(30);" but found "//sleep(30);"
 145 | ERROR   | [x] Inline comments must end in full-stops,
     |         |     exclamation marks, question marks, colons, or
     |         |     closing parentheses
 200 | ERROR   | [x] No space found before comment text; expected "//
     |         |     sleep(30);" but found "//sleep(30);"
 200 | ERROR   | [x] Inline comments must end in full-stops,
     |         |     exclamation marks, question marks, colons, or
     |         |     closing parentheses
 254 | ERROR   | [x] No space found before comment text; expected "//
     |         |     sleep(30);" but found "//sleep(30);"
 254 | ERROR   | [x] Inline comments must end in full-stops,
     |         |     exclamation marks, question marks, colons, or
     |         |     closing parentheses
----------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 107ms; Memory: 10MB
📌 Task
Status

Needs review

Version

1.0

Component

Code

Created by

🇮🇳India jayesh_makwana

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.

  • First commit to issue fork.
  • Assigned to vishaljd
  • Merge request !3fix coding standard → (Open) created by vishaljd
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India vishaljd

    Fixed coding standards using phpcs for Drupal and DrupalPractice standards.

    Please check and merge pr.

    Thanks

  • Status changed to Needs work over 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    See my previous comment. The issue summary has not been updated.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    The MR does not correctly change the files.

     /**
    - * Class DefaultController.
    + * Class of DefaultController.
      */
    

    That is not what a documentation comment for a class should say. Adding of is not sufficient.

    -  /**
    -   * {@inheritdoc}
    -   */
    -  public function validateForm(array &$form, FormStateInterface $form_state) {
    -    parent::validateForm($form, $form_state);
    -  }
    -
    

    That change is not required by the coding standards.

    -    //sleep(30);
    +    // sleep(30);.
    

    There is no need to add a period to commented out code.

  • First commit to issue fork.
  • Status changed to Needs review over 1 year ago
  • Status changed to Needs work over 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    The issue summary still needs to be updated.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    As for the MR, it still uses Class of.

  • 🇮🇳India zkhan.aamir

    Issue summary Updated.
    Please review.

  • 🇮🇳India Shreyas gowda

    resolved some of this error
    still few warnings and errors are left

    FILE: C:\wamp64\www\contribution\block_list_override\README.txt
    ----------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    ----------------------------------------------------------------------
    14 | WARNING | Line exceeds 80 characters; contains 108 characters
    43 | WARNING | Line exceeds 80 characters; contains 303 characters
    ----------------------------------------------------------------------

    FILE: C:\wamp64\www\contribution\block_list_override\src\Controller\DefaultController.php
    -----------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------
    14 | WARNING | The class short comment should describe what the class does and not simply repeat the class name
    -----------------------------------------------------------------------------------------------------------------

    FILE: C:\wamp64\www\contribution\block_list_override\src\Form\SettingsForm.php
    -------------------------------------------------------------------------------------------------------------------------
    FOUND 14 ERRORS AND 16 WARNINGS AFFECTING 16 LINES
    -------------------------------------------------------------------------------------------------------------------------
    13 | WARNING | The class short comment should describe what the class does and not simply repeat the class name
    62 | WARNING | Translatable strings must not begin or end with white spaces, use placeholders with t() for variables
    62 | ERROR | Concatenating translatable strings is not allowed, use placeholders instead and only one string literal
    74 | WARNING | Translatable strings must not begin or end with white spaces, use placeholders with t() for variables
    74 | ERROR | Concatenating translatable strings is not allowed, use placeholders instead and only one string literal
    87 | WARNING | Translatable strings must not begin or end with white spaces, use placeholders with t() for variables
    87 | ERROR | Concatenating translatable strings is not allowed, use placeholders instead and only one string literal
    92 | WARNING | Translatable strings must not begin or end with white spaces, use placeholders with t() for variables
    92 | ERROR | Concatenating translatable strings is not allowed, use placeholders instead and only one string literal
    99 | WARNING | Translatable strings must not begin or end with white spaces, use placeholders with t() for variables
    99 | ERROR | Concatenating translatable strings is not allowed, use placeholders instead and only one string literal
    102 | WARNING | Translatable strings must not begin or end with white spaces, use placeholders with t() for variables
    102 | ERROR | Concatenating translatable strings is not allowed, use placeholders instead and only one string literal
    108 | WARNING | Translatable strings must not begin or end with white spaces, use placeholders with t() for variables
    108 | ERROR | Concatenating translatable strings is not allowed, use placeholders instead and only one string literal
    127 | WARNING | Translatable strings must not begin or end with white spaces, use placeholders with t() for variables
    127 | ERROR | Concatenating translatable strings is not allowed, use placeholders instead and only one string literal
    143 | WARNING | Translatable strings must not begin or end with white spaces, use placeholders with t() for variables
    143 | ERROR | Concatenating translatable strings is not allowed, use placeholders instead and only one string literal
    150 | WARNING | Translatable strings must not begin or end with white spaces, use placeholders with t() for variables
    150 | ERROR | Concatenating translatable strings is not allowed, use placeholders instead and only one string literal
    164 | WARNING | Translatable strings must not begin or end with white spaces, use placeholders with t() for variables
    164 | ERROR | Concatenating translatable strings is not allowed, use placeholders instead and only one string literal
    174 | WARNING | Translatable strings must not begin or end with white spaces, use placeholders with t() for variables
    174 | ERROR | Concatenating translatable strings is not allowed, use placeholders instead and only one string literal
    181 | WARNING | Translatable strings must not begin or end with white spaces, use placeholders with t() for variables
    181 | ERROR | Concatenating translatable strings is not allowed, use placeholders instead and only one string literal
    188 | WARNING | Translatable strings must not begin or end with white spaces, use placeholders with t() for variables
    188 | ERROR | Concatenating translatable strings is not allowed, use placeholders instead and only one string literal
    199 | WARNING | Possible useless method overriding detected
    -------------------------------------------------------------------------------------------------------------------------

    FILE: C:\wamp64\www\contribution\block_list_override\tests\src\Functional\BlockListOverrideTest.php
    ---------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------
    92 | WARNING | Line exceeds 80 characters; contains 82 characters
    ---------------------------------------------------------------------------------------------------

  • First commit to issue fork.
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update 4 months ago
    2 fail
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update 4 months ago
    2 fail
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update 4 months ago
    2 fail
  • Status changed to Needs review 4 months ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update 4 months ago
    2 fail
  • The last submitted patch, 22: phpcs_fix.patch, failed testing. View results
    - codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

  • 🇮🇳India zkhan.aamir

    Hi,

    MR #23 applied successfully.

    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules/block_list_override (1.0.x)
    $ curl https://git.drupalcode.org/project/block_list_override/-/merge_requests/3.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 22431    0 22431    0     0  52231      0 --:--:-- --:--:-- --:--:-- 52286
    patching file README.txt
    patching file block_list_override.install
    patching file block_list_override.links.menu.yml
    patching file config/install/block_list_override.settings.yml
    patching file src/BlockListOverride.php
    patching file src/Controller/DefaultController.php
    patching file src/Controller/LayoutController.php
    patching file src/Form/SettingsForm.php
    patching file src/LayoutPluginAlter.php
    patching file src/PluginAlter.php
    patching file tests/src/Functional/BlockListOverrideTest.php
    

    No errors remaining.

    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules
    $ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,css,js,yml block_list_override/
    
    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules
    $
    
    
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update 4 months ago
    2 fail
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Status changed to Needs review 4 months ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • First commit to issue fork.
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update 3 months ago
    2 fail
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update 3 months ago
    2 fail
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update 3 months ago
    2 fail
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update 3 months ago
    2 fail
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update 3 months ago
    2 fail
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update 3 months ago
    2 fail
  • Pipeline finished with Canceled
    3 months ago
    Total: 54s
    #117351
  • Pipeline finished with Failed
    3 months ago
    Total: 202s
    #117353
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update 3 months ago
    2 fail
  • Pipeline finished with Failed
    3 months ago
    Total: 175s
    #117363
Production build 0.69.0 2024