Fix the PHP_CodeSniffer issues reported by GitLab CI

Created on 9 January 2023, almost 2 years ago
Updated 14 August 2024, 4 months ago

GitLab CI reports PHP_CodeSniffer warnings/errors which should be fixed.

FILE: ...es/custom/button_field/tests/src/TestSite/ButtonFieldInstallTestScript.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 39 | ERROR | Missing short description in doc comment
    |       | (Drupal.Commenting.DocComment.MissingShort)
--------------------------------------------------------------------------------
FILE: ...eb/modules/custom/button_field/src/Plugin/migrate/field/d7/ButtonField.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 40 | ERROR | [x] Expected 1 newline at end of file; 2 found
    |       |     (Drupal.Files.EndFileNewline.TooMany)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...ules/custom/button_field/src/Plugin/Field/FieldWidget/ButtonFieldImage.php
--------------------------------------------------------------------------------
FOUND 16 ERRORS AFFECTING 13 LINES
--------------------------------------------------------------------------------
 26 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 40 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 42 | ERROR | [x] Expected 1 space after "=>"; 0 found
    |       |     (Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter)
 47 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 49 | ERROR | [x] Expected 1 space after "=>"; 0 found
    |       |     (Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter)
 54 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 56 | ERROR | [x] Expected 1 space after "=>"; 0 found
    |       |     (Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter)
 68 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 69 | ERROR | [x] Expected 1 space after "="; 0 found
    |       |     (Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter)
 69 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 70 | ERROR | [x] Expected 1 space after "="; 0 found
    |       |     (Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter)
 70 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 71 | ERROR | [x] Expected 1 space after "="; 0 found
    |       |     (Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter)
 71 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 80 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 83 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 16 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...dules/custom/button_field/src/Plugin/Field/FieldWidget/ButtonFieldHtml.php
--------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
--------------------------------------------------------------------------------
 26 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 36 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 38 | ERROR | [x] Expected 1 space after "=>"; 0 found
    |       |     (Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter)
 50 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 62 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...dules/custom/button_field/src/Plugin/Field/FieldWidget/ButtonFieldBase.php
--------------------------------------------------------------------------------
FOUND 11 ERRORS AFFECTING 11 LINES
--------------------------------------------------------------------------------
 30 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 45 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 48 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 49 | ERROR | [x] Expected 1 space after "=>"; 0 found
    |       |     (Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter)
 56 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 57 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 58 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 59 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 60 | ERROR | [x] Expected 1 space before "=>"; 0 found
    |       |     (Squiz.WhiteSpace.OperatorSpacing.NoSpaceBefore)
 67 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 96 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 11 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...web/modules/custom/button_field/src/Plugin/Field/FieldType/ButtonField.php
--------------------------------------------------------------------------------
FOUND 9 ERRORS AFFECTING 9 LINES
--------------------------------------------------------------------------------
 48 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 49 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 50 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 80 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 82 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 84 | ERROR | [x] Expected 1 space after "=>"; 0 found
    |       |     (Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter)
 86 | ERROR | [x] Expected 1 space after "=>"; 0 found
    |       |     (Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter)
 96 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 98 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 9 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...s/custom/button_field/src/Plugin/Field/FieldFormatter/ButtonFieldImage.php
--------------------------------------------------------------------------------
FOUND 16 ERRORS AFFECTING 13 LINES
--------------------------------------------------------------------------------
 26 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 40 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 42 | ERROR | [x] Expected 1 space after "=>"; 0 found
    |       |     (Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter)
 47 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 49 | ERROR | [x] Expected 1 space after "=>"; 0 found
    |       |     (Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter)
 54 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 56 | ERROR | [x] Expected 1 space after "=>"; 0 found
    |       |     (Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter)
 68 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 69 | ERROR | [x] Expected 1 space after "="; 0 found
    |       |     (Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter)
 69 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 70 | ERROR | [x] Expected 1 space after "="; 0 found
    |       |     (Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter)
 70 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 71 | ERROR | [x] Expected 1 space after "="; 0 found
    |       |     (Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter)
 71 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 80 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 83 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 16 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...es/custom/button_field/src/Plugin/Field/FieldFormatter/ButtonFieldHtml.php
--------------------------------------------------------------------------------
FOUND 7 ERRORS AFFECTING 6 LINES
--------------------------------------------------------------------------------
 26 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 36 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 38 | ERROR | [x] Expected 1 space after "=>"; 0 found
    |       |     (Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter)
 50 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 51 | ERROR | [x] Expected 1 space after "="; 0 found
    |       |     (Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter)
 51 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 60 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...es/custom/button_field/src/Plugin/Field/FieldFormatter/ButtonFieldBase.php
--------------------------------------------------------------------------------
FOUND 11 ERRORS AFFECTING 11 LINES
--------------------------------------------------------------------------------
 27 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 42 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 45 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 46 | ERROR | [x] Expected 1 space after "=>"; 0 found
    |       |     (Squiz.WhiteSpace.OperatorSpacing.NoSpaceAfter)
 52 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 53 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 54 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 55 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 56 | ERROR | [x] Expected 1 space before "=>"; 0 found
    |       |     (Squiz.WhiteSpace.OperatorSpacing.NoSpaceBefore)
 63 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 89 | ERROR | [x] Short array syntax must be used to define arrays
    |       |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 11 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...s/project/button_field/web/modules/custom/button_field/button_field.module
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] The PHP open tag must be followed by exactly one blank
   |       |     line (Drupal.WhiteSpace.OpenTagNewline.BlankLine)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
Time: 300ms; Memory: 6MB
📌 Task
Status

Needs review

Version

2.0

Component

Code

Created by

🇮🇳India Jitendra_Kumar

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, 🇮🇹
  • Status changed to Needs work over 1 year ago
  • 🇵🇭Philippines paraderojether

    I reviewed MR!5, and after applying the MR, I'm getting this new error shown below:

    FILE: /Users/studenttrainees/New/drupalorgsite/docroot/modules/contrib/button_field/config/schema/button_field.schema.yml
    -------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------
    59 | ERROR | [x] Expected 1 newline at end of file; 2 found
    -------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------------------

    FILE: /Users/studenttrainees/New/drupalorgsite/docroot/modules/contrib/button_field/button_field.module
    -------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 2 WARNINGS AFFECTING 3 LINES
    -------------------------------------------------------------------------------------------------------
    1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
    15 | WARNING | [ ] Unused variable $table_name.
    16 | WARNING | [ ] Unused variable $id.
    -------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------

    FILE: /Users/studenttrainees/New/drupalorgsite/docroot/modules/contrib/button_field/README.txt
    ----------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------
    10 | WARNING | Line exceeds 80 characters; contains 81 characters
    ----------------------------------------------------------------------------------------------

    FILE: /Users/studenttrainees/New/drupalorgsite/docroot/modules/contrib/button_field/src/Plugin/Field/FieldFormatter/ButtonFieldBase.php
    ---------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------------------------
    68 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    ---------------------------------------------------------------------------------------------------------------------------------------

    Time: 452ms; Memory: 10MB

    Please check.
    Thank You.

  • First commit to issue fork.
  • Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update over 1 year ago
    Waiting for branch to pass
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    As a side note, the issue summary shows the report for the Drupal ruleset. It cannot be compared to a report that uses also the DrupalPractice ruleset.

  • First commit to issue fork.
  • Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update about 1 year ago
    Waiting for branch to pass
  • Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update about 1 year ago
    Waiting for branch to pass
  • Status changed to Needs review about 1 year ago
  • 🇷🇺Russia zniki.ru

    MR #5 is ready for review, please take closer look at src/Plugin/Field/FieldFormatter/ButtonFieldBase.php.

  • First commit to issue fork.
  • Pipeline finished with Failed
    8 months ago
    Total: 202s
    #154312
  • Pipeline finished with Failed
    8 months ago
    Total: 137s
    #154322
  • 🇮🇳India manish-31

    I have rebased the MR and resolved MR conflicts.

    Fixed another issue detected by PHPCS after rebasing the MR. Needs review thanks!

  • Status changed to Needs work 8 months ago
  • 🇵🇭Philippines paraderojether

    Hi

    I reviewed MR!5, and confirmed it is applied however I got this warning warning: 1 line adds whitespace errors. while applying the patch.

    jetherparadero@PrometSources-MacBook-Pro-3 button_field % curl https://git.drupalcode.org/project/button_field/-/merge_requests/5.diff | git apply -v
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 22752    0 22752    0     0  49076      0 --:--:-- --:--:-- --:--:-- 49785
    <stdin>:11: trailing whitespace.
    - Button field reload action has been removed. Use the Rules Core
    Checking patch README.txt...
    Checking patch button_field.module...
    Checking patch src/Plugin/Field/FieldFormatter/ButtonFieldBase.php...
    Checking patch src/Plugin/Field/FieldFormatter/ButtonFieldHtml.php...
    Checking patch src/Plugin/Field/FieldFormatter/ButtonFieldImage.php...
    Checking patch src/Plugin/Field/FieldType/ButtonField.php...
    Checking patch src/Plugin/Field/FieldWidget/ButtonFieldBase.php...
    Checking patch src/Plugin/Field/FieldWidget/ButtonFieldHtml.php...
    Checking patch src/Plugin/Field/FieldWidget/ButtonFieldImage.php...
    Checking patch src/Plugin/migrate/field/d7/ButtonField.php...
    Checking patch tests/src/TestSite/ButtonFieldInstallTestScript.php...
    Applied patch README.txt cleanly.
    Applied patch button_field.module cleanly.
    Applied patch src/Plugin/Field/FieldFormatter/ButtonFieldBase.php cleanly.
    Applied patch src/Plugin/Field/FieldFormatter/ButtonFieldHtml.php cleanly.
    Applied patch src/Plugin/Field/FieldFormatter/ButtonFieldImage.php cleanly.
    Applied patch src/Plugin/Field/FieldType/ButtonField.php cleanly.
    Applied patch src/Plugin/Field/FieldWidget/ButtonFieldBase.php cleanly.
    Applied patch src/Plugin/Field/FieldWidget/ButtonFieldHtml.php cleanly.
    Applied patch src/Plugin/Field/FieldWidget/ButtonFieldImage.php cleanly.
    Applied patch src/Plugin/migrate/field/d7/ButtonField.php cleanly.
    Applied patch tests/src/TestSite/ButtonFieldInstallTestScript.php cleanly.
    warning: 1 line adds whitespace errors.
    jetherparadero@PrometSources-MacBook-Pro-3 button_field % cd ..
    jetherparadero@PrometSources-MacBook-Pro-3 contrib % phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml button_field
    jetherparadero@PrometSources-MacBook-Pro-3 contrib % phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig button_field
    jetherparadero@PrometSources-MacBook-Pro-3 contrib %

    Please check and advise for the warning after applying patch.
    Thank you.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    apaderno → changed the visibility of the branch 3331941-drupal-coding-standard to hidden.

  • Status changed to Needs review 8 months ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Pipeline finished with Failed
    8 months ago
    Total: 176s
    #161461
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Pipeline finished with Failed
    8 months ago
    Total: 130s
    #161473
  • Status changed to Needs work 5 months ago
  • 🇮🇳India atul_ghate

    I have reviewed and applied MR5 cleanly, and fixed most of the PHPCS issues. However, there are still some remaining issues, so marking it as "needs work."

  • Status changed to Needs review 5 months ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Pipeline finished with Failed
    5 months ago
    Total: 140s
    #247940
  • 🇮🇳India atul_ghate

    I have reviewed and applied patch cleanly, it resolved the all phpcs issue. RTBC+

Production build 0.71.5 2024