Fix the PHP_CodeSniffer issues reported by GitLab CI

Created on 13 March 2024, 8 months ago
Updated 1 May 2024, 7 months ago

GitLab CI reports the following errors/warnings that should be fixed.

FILE: .../custom/cloudfilt-3427593/src/StackMiddleware/CloudfiltStackMiddleware.php
--------------------------------------------------------------------------------
FOUND 3 ERRORS AND 1 WARNING AFFECTING 4 LINES
--------------------------------------------------------------------------------
   9 | ERROR   | [x] Use statements should be sorted alphabetically. The first
     |         |     wrong one is Drupal\Core\Config\ConfigFactoryInterface.
     |         |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
  85 | WARNING | [x] A comma should follow the last multiline array item.
     |         |     Found: 'no-cache' (Drupal.Arrays.Array.CommaLastItem)
 123 | ERROR   | [x] Expected 1 blank line after function; 0 found
     |         |     (Squiz.WhiteSpace.FunctionSpacing.AfterLast)
 124 | ERROR   | [x] The closing brace for the class must have an empty line
     |         |     before it
     |         |     (Drupal.Classes.ClassDeclaration.CloseBraceAfterBody)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...7593/web/modules/custom/cloudfilt-3427593/src/Form/CloudfiltConfigForm.php
--------------------------------------------------------------------------------
FOUND 6 ERRORS AND 3 WARNINGS AFFECTING 9 LINES
--------------------------------------------------------------------------------
   6 | ERROR   | [x] Use statements should be sorted alphabetically. The first
     |         |     wrong one is Drupal\Core\Form\ConfigFormBase.
     |         |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
  14 | WARNING | [ ] The class short comment should describe what the class
     |         |     does and not simply repeat the class name
     |         |     (Drupal.Commenting.ClassComment.Short)
  25 | ERROR   | [ ] Doc comment short description must start with a capital
     |         |     letter (Drupal.Commenting.DocComment.ShortNotCapital)
  32 | ERROR   | [ ] Missing short description in doc comment
     |         |     (Drupal.Commenting.DocComment.MissingShort)
  38 | ERROR   | [x] Expected 1 blank line before function; 2 found
     |         |     (Squiz.WhiteSpace.FunctionSpacing.Before)
 131 | WARNING | [x] A comma should follow the last multiline array item.
     |         |     Found: ] (Drupal.Arrays.Array.CommaLastItem)
 158 | ERROR   | [ ] The array declaration extends to column 198 (the limit is
     |         |     120). The array content should be split up over multiple
     |         |     lines (Drupal.Arrays.Array.LongLineDeclaration)
 180 | ERROR   | [x] Expected 1 blank line after function; 2 found
     |         |     (Squiz.WhiteSpace.FunctionSpacing.After)
 184 | WARNING | [ ] Line exceeds 80 characters; contains 82 characters
     |         |     (Drupal.Files.LineLength.TooLong)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...ue/cloudfilt-3427593/web/modules/custom/cloudfilt-3427593/cloudfilt.module
--------------------------------------------------------------------------------
FOUND 3 ERRORS AND 2 WARNINGS AFFECTING 5 LINES
--------------------------------------------------------------------------------
  8 | WARNING | [x] Unused use statement
    |         |     (Drupal.Classes.UnusedUseStatement.UnusedUse)
 15 | ERROR   | [ ] cloudfilt_requirements() is an installation hook and must
    |         |     be declared in an install file
    |         |     (Drupal.Semantics.InstallHooks.InstallHook)
 22 | ERROR   | [x] Short array syntax must be used to define arrays
    |         |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 29 | ERROR   | [x] Short array syntax must be used to define arrays
    |         |     (Drupal.Arrays.DisallowLongArraySyntax.Found)
 78 | WARNING | [x] A comma should follow the last multiline array item. Found:
    |         |     TRUE (Drupal.Arrays.Array.CommaLastItem)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
Time: 153ms; Memory: 6MB

 
 

📌 Task
Status

Needs review

Version

1.0

Component

Code

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @sunil_lnwebworks
  • Hi

    Here is the Patch file for the above phpcs issues.

  • sunil_lnwebworks → changed the visibility of the branch 3427593-module-have-some to hidden.

  • Status changed to Needs review 8 months ago
  • Assigned to sunil_lnwebworks
  • Status changed to RTBC 8 months ago
  • 🇵🇭Philippines paraderojether

    Hi

    I reviewed patch 2, applied it against CloudFilt - Prevent & block bad bots - Bot Manager 1.0.x-dev, confirmed patch was applied successfully, and fixed all the issues reported by phpcs.

    command used: phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml cloudfilt

    jetherparadero@PrometSources-MacBook-Pro cloudfilt % curl https://www.drupal.org/files/issues/2024-03-13/Issues-3427593-Fixed-phpcs-issues.patch | git apply -v
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  5618  100  5618    0     0  11082      0 --:--:-- --:--:-- --:--:-- 11349
    Checking patch cloudfilt.info.yml...
    Checking patch cloudfilt.module...
    Checking patch src/Form/CloudfiltConfigForm.php...
    Checking patch src/StackMiddleware/CloudfiltStackMiddleware.php...
    Applied patch cloudfilt.info.yml cleanly.
    Applied patch cloudfilt.module cleanly.
    Applied patch src/Form/CloudfiltConfigForm.php cleanly.
    Applied patch src/StackMiddleware/CloudfiltStackMiddleware.php cleanly.
    jetherparadero@PrometSources-MacBook-Pro cloudfilt % cd ..
    jetherparadero@PrometSources-MacBook-Pro contrib % phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml cloudfilt
    jetherparadero@PrometSources-MacBook-Pro contrib %

    Thank you.

  • First commit to issue fork.
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Pipeline finished with Success
    8 months ago
    Total: 139s
    #126924
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Pipeline finished with Success
    8 months ago
    #126975
  • Issue was unassigned.
  • Status changed to Needs review 7 months ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Pipeline finished with Canceled
    7 months ago
    Total: 64s
    #161289
  • Pipeline finished with Success
    7 months ago
    Total: 173s
    #161290
Production build 0.71.5 2024