Drupal coding standarts

Created on 31 January 2024, 11 months ago
Updated 2 February 2024, 11 months ago

Problem/Motivation

Hello.

Need to fix Drupal coding standards:

$ vendor/bin/phpcs --basepath=$CI_PROJECT_DIR -s $_WEB_ROOT/sites/all/modules/custom --report-junit=junit.xml --report-full --report-summary --report-source
FILE: .../all/modules/custom/file_compressor_field/includes/CompressProviderZip.php
--------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
--------------------------------------------------------------------------------
 20 | ERROR | [ ] Missing short description in doc comment
    |       |     (Drupal.Commenting.DocComment.MissingShort)
 27 | ERROR | [ ] Missing short description in doc comment
    |       |     (Drupal.Commenting.DocComment.MissingShort)
 34 | ERROR | [ ] Missing short description in doc comment
    |       |     (Drupal.Commenting.DocComment.MissingShort)
 60 | ERROR | [x] Expected 1 blank line after function; 0 found
    |       |     (Squiz.WhiteSpace.FunctionSpacing.AfterLast)
 61 | ERROR | [x] The closing brace for the class must have an empty line
    |       |     before it
    |       |     (Drupal.Classes.ClassDeclaration.CloseBraceAfterBody)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...odules/custom/file_compressor_field/includes/CompressProviderInterface.php
--------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
--------------------------------------------------------------------------------
 35 | ERROR | [ ] Missing parameter type
    |       |     (Drupal.Commenting.FunctionComment.MissingParamType)
 43 | ERROR | [x] Expected 1 blank line after function; 0 found
    |       |     (Squiz.WhiteSpace.FunctionSpacing.AfterLast)
 44 | ERROR | [x] The closing brace for the interface must have an empty line
    |       |     before it
    |       |     (Drupal.Classes.ClassDeclaration.CloseBraceAfterBody)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...all/modules/custom/file_compressor_field/includes/CompressProviderGZip.php
--------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
--------------------------------------------------------------------------------
 20 | ERROR | [ ] Missing short description in doc comment
    |       |     (Drupal.Commenting.DocComment.MissingShort)
 27 | ERROR | [ ] Missing short description in doc comment
    |       |     (Drupal.Commenting.DocComment.MissingShort)
 34 | ERROR | [ ] Missing short description in doc comment
    |       |     (Drupal.Commenting.DocComment.MissingShort)
 49 | ERROR | [x] Expected 1 blank line after function; 0 found
    |       |     (Squiz.WhiteSpace.FunctionSpacing.AfterLast)
 50 | ERROR | [x] The closing brace for the class must have an empty line
    |       |     before it
    |       |     (Drupal.Classes.ClassDeclaration.CloseBraceAfterBody)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: .../sites/all/modules/custom/file_compressor_field/file_compressor_field.test
--------------------------------------------------------------------------------
FOUND 32 ERRORS AND 8 WARNINGS AFFECTING 39 LINES
--------------------------------------------------------------------------------
  13 | ERROR   | [x] Missing function doc comment
     |         |     (Drupal.Commenting.FunctionComment.Missing)
  21 | ERROR   | [x] Visibility must be declared on method "setUp"
     |         |     (Drupal.Scope.MethodScope.Missing)
  21 | ERROR   | [x] Missing function doc comment
     |         |     (Drupal.Commenting.FunctionComment.Missing)
  28 | ERROR   | [x] Visibility must be declared on method
     |         |     "testBasicCompressField"
     |         |     (Drupal.Scope.MethodScope.Missing)
  37 | WARNING | [x] A comma should follow the last multiline array item.
     |         |     Found: 'field_image' (Drupal.Arrays.Array.CommaLastItem)
  38 | WARNING | [x] A comma should follow the last multiline array item.
     |         |     Found: ) (Drupal.Arrays.Array.CommaLastItem)
  46 | ERROR   | [x] list(...) is forbidden, use [...] instead.
     |         |     (SlevomatCodingStandard.PHP.ShortList.LongListUsed)
  55 | ERROR   | [x] Visibility must be declared on method
     |         |     "testCompressFieldRevisions"
     |         |     (Drupal.Scope.MethodScope.Missing)
  63 | WARNING | [x] A comma should follow the last multiline array item.
     |         |     Found: 'field_image' (Drupal.Arrays.Array.CommaLastItem)
  64 | WARNING | [x] A comma should follow the last multiline array item.
     |         |     Found: ) (Drupal.Arrays.Array.CommaLastItem)
  72 | ERROR   | [x] list(...) is forbidden, use [...] instead.
     |         |     (SlevomatCodingStandard.PHP.ShortList.LongListUsed)
  82 | ERROR   | [x] list(...) is forbidden, use [...] instead.
     |         |     (SlevomatCodingStandard.PHP.ShortList.LongListUsed)
  91 | ERROR   | [x] Visibility must be declared on method
     |         |     "testCompressFiledMultilingual"
     |         |     (Drupal.Scope.MethodScope.Missing)
 118 | WARNING | [x] A comma should follow the last multiline array item.
     |         |     Found: 'field_image' (Drupal.Arrays.Array.CommaLastItem)
 119 | WARNING | [x] A comma should follow the last multiline array item.
     |         |     Found: ) (Drupal.Arrays.Array.CommaLastItem)
 134 | ERROR   | [x] Array indentation error, expected 6 spaces but found 4
     |         |     (Drupal.Arrays.Array.ArrayIndentation)
 135 | ERROR   | [x] Array indentation error, expected 6 spaces but found 4
     |         |     (Drupal.Arrays.Array.ArrayIndentation)
 136 | ERROR   | [x] Array closing indentation error, expected 4 spaces but
     |         |     found 2 (Drupal.Arrays.Array.ArrayClosingIndentation)
 140 | ERROR   | [x] list(...) is forbidden, use [...] instead.
     |         |     (SlevomatCodingStandard.PHP.ShortList.LongListUsed)
 159 | ERROR   | [ ] Missing parameter type
     |         |     (Drupal.Commenting.FunctionComment.MissingParamType)
 161 | ERROR   | [ ] Missing parameter type
     |         |     (Drupal.Commenting.FunctionComment.MissingParamType)
 163 | ERROR   | [ ] Missing parameter type
     |         |     (Drupal.Commenting.FunctionComment.MissingParamType)
 165 | ERROR   | [ ] Missing parameter type
     |         |     (Drupal.Commenting.FunctionComment.MissingParamType)
 167 | ERROR   | [ ] Missing parameter type
     |         |     (Drupal.Commenting.FunctionComment.MissingParamType)
 170 | ERROR   | [x] Visibility must be declared on method
     |         |     "createCompressFileField"
     |         |     (Drupal.Scope.MethodScope.Missing)
 186 | ERROR   | [ ] Missing parameter type
     |         |     (Drupal.Commenting.FunctionComment.MissingParamType)
 188 | ERROR   | [ ] Missing parameter type
     |         |     (Drupal.Commenting.FunctionComment.MissingParamType)
 190 | ERROR   | [ ] Missing parameter type
     |         |     (Drupal.Commenting.FunctionComment.MissingParamType)
 192 | ERROR   | [ ] Missing parameter type
     |         |     (Drupal.Commenting.FunctionComment.MissingParamType)
 194 | ERROR   | [ ] Missing parameter type
     |         |     (Drupal.Commenting.FunctionComment.MissingParamType)
 197 | ERROR   | [x] Visibility must be declared on method
     |         |     "attachCompressFileField"
     |         |     (Drupal.Scope.MethodScope.Missing)
 218 | ERROR   | [x] Visibility must be declared on method
     |         |     "assertCompressField" (Drupal.Scope.MethodScope.Missing)
 219 | ERROR   | [x] list(...) is forbidden, use [...] instead.
     |         |     (SlevomatCodingStandard.PHP.ShortList.LongListUsed)
 291 | WARNING | [ ] Line exceeds 80 characters; contains 111 characters
     |         |     (Drupal.Files.LineLength.TooLong)
 293 | ERROR   | [ ] Missing parameter type
     |         |     (Drupal.Commenting.FunctionComment.MissingParamType)
 296 | ERROR   | [x] Visibility must be declared on method "addLanguage"
     |         |     (Drupal.Scope.MethodScope.Missing)
 314 | WARNING | [x] A comma should follow the last multiline array item.
     |         |     Found: ) (Drupal.Arrays.Array.CommaLastItem)
 333 | ERROR   | [x] Visibility must be declared on method
     |         |     "configureContentType" (Drupal.Scope.MethodScope.Missing)
 339 | ERROR   | [x] Expected 1 blank line after function; 0 found
     |         |     (Squiz.WhiteSpace.FunctionSpacing.AfterLast)
 340 | ERROR   | [x] The closing brace for the class must have an empty line
     |         |     before it
     |         |     (Drupal.Classes.ClassDeclaration.CloseBraceAfterBody)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 28 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...ites/all/modules/custom/file_compressor_field/file_compressor_field.module
--------------------------------------------------------------------------------
FOUND 19 ERRORS AFFECTING 17 LINES
--------------------------------------------------------------------------------
  30 | ERROR | [x] Case breaking statements must be followed by a single blank
     |       |     line
     |       |     (Squiz.ControlStructures.SwitchDeclaration.SpacingAfterBreak)
 104 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
     |       |     (Squiz.Functions.MultiLineFunctionDeclaration.SpaceAfterFunction)
 104 | ERROR | [x] Expected 1 space before opening brace; found 0
     |       |     (Generic.Functions.OpeningFunctionBraceKernighanRitchie.SpaceBeforeBrace)
 104 | ERROR | [x] Expected 1 space before opening brace; found 0
     |       |     (Squiz.Functions.MultiLineFunctionDeclaration.SpaceBeforeBrace)
 257 | ERROR | [ ] Missing parameter type
     |       |     (Drupal.Commenting.FunctionComment.MissingParamType)
 259 | ERROR | [ ] Missing parameter type
     |       |     (Drupal.Commenting.FunctionComment.MissingParamType)
 261 | ERROR | [ ] Missing parameter type
     |       |     (Drupal.Commenting.FunctionComment.MissingParamType)
 263 | ERROR | [ ] Missing parameter type
     |       |     (Drupal.Commenting.FunctionComment.MissingParamType)
 265 | ERROR | [ ] Missing parameter type
     |       |     (Drupal.Commenting.FunctionComment.MissingParamType)
 267 | ERROR | [ ] Missing parameter type
     |       |     (Drupal.Commenting.FunctionComment.MissingParamType)
 269 | ERROR | [ ] Missing parameter type
     |       |     (Drupal.Commenting.FunctionComment.MissingParamType)
 440 | ERROR | [x] Expected 1 blank line after function; 0 found
     |       |     (Squiz.WhiteSpace.FunctionSpacing.After)
 444 | ERROR | [ ] Missing parameter type
     |       |     (Drupal.Commenting.FunctionComment.MissingParamType)
 471 | ERROR | [ ] Missing parameter type
     |       |     (Drupal.Commenting.FunctionComment.MissingParamType)
 473 | ERROR | [ ] Missing parameter type
     |       |     (Drupal.Commenting.FunctionComment.MissingParamType)
 475 | ERROR | [ ] Missing parameter type
     |       |     (Drupal.Commenting.FunctionComment.MissingParamType)
 477 | ERROR | [ ] Missing parameter type
     |       |     (Drupal.Commenting.FunctionComment.MissingParamType)
 479 | ERROR | [ ] Missing parameter type
     |       |     (Drupal.Commenting.FunctionComment.MissingParamType)
 492 | ERROR | [x] list(...) is forbidden, use [...] instead.
     |       |     (SlevomatCodingStandard.PHP.ShortList.LongListUsed)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: .../sites/all/modules/custom/file_compressor_field/file_compressor_field.info
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 9 | 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: ...s/all/modules/custom/file_compressor_field/file_compressor_field.admin.inc
--------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------
 12 | ERROR | [x] Expected 1 space after FUNCTION keyword; 0 found
    |       |     (Squiz.Functions.MultiLineFunctionDeclaration.SpaceAfterFunction)
 69 | ERROR | [x] list(...) is forbidden, use [...] instead.
    |       |     (SlevomatCodingStandard.PHP.ShortList.LongListUsed)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
Time: 210ms; Memory: 8MB
PHP CODE SNIFFER REPORT SUMMARY
--------------------------------------------------------------------------------
FILE                                                            ERRORS  WARNINGS
--------------------------------------------------------------------------------
...ustom/file_compressor_field/file_compressor_field.admin.inc  2       0
...les/custom/file_compressor_field/file_compressor_field.info  1       0
...s/custom/file_compressor_field/file_compressor_field.module  19      0
...les/custom/file_compressor_field/file_compressor_field.test  32      8
...tom/file_compressor_field/includes/CompressProviderGZip.php  5       0
...ile_compressor_field/includes/CompressProviderInterface.php  3       0
...stom/file_compressor_field/includes/CompressProviderZip.php  5       0
--------------------------------------------------------------------------------
A TOTAL OF 67 ERRORS AND 8 WARNINGS WERE FOUND IN 9 FILES
--------------------------------------------------------------------------------
PHPCBF CAN FIX 43 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
PHP CODE SNIFFER VIOLATION SOURCE SUMMARY
--------------------------------------------------------------------------------
    SOURCE                                                                 COUNT
--------------------------------------------------------------------------------
[ ] Drupal.Commenting.FunctionComment.MissingParamType                     25
[x] Drupal.Scope.MethodScope.Missing                                       9
[x] Drupal.Arrays.Array.CommaLastItem                                      7
[x] SlevomatCodingStandard.PHP.ShortList.LongListUsed                      7
[ ] Drupal.Commenting.DocComment.MissingShort                              6
[x] Drupal.Classes.ClassDeclaration.CloseBraceAfterBody                    4
[x] Squiz.WhiteSpace.FunctionSpacing.AfterLast                             4
[x] Drupal.Arrays.Array.ArrayIndentation                                   2
[x] Drupal.Commenting.FunctionComment.Missing                              2
[x] Squiz.Functions.MultiLineFunctionDeclaration.SpaceAfterFunction        2
[x] Drupal.Arrays.Array.ArrayClosingIndentation                            1
[x] Drupal.Files.EndFileNewline.TooMany                                    1
[ ] Drupal.Files.LineLength.TooLong                                        1
[x] Generic.Functions.OpeningFunctionBraceKernighanRitchie.SpaceBeforeBra  1
[x] Squiz.ControlStructures.SwitchDeclaration.SpacingAfterBreak            1
[x] Squiz.Functions.MultiLineFunctionDeclaration.SpaceBeforeBrace          1
[x] Squiz.WhiteSpace.FunctionSpacing.After                                 1
--------------------------------------------------------------------------------
A TOTAL OF 75 SNIFF VIOLATIONS WERE FOUND IN 17 SOURCES
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 14 MARKED SOURCES AUTOMATICALLY (43 VIOLATIONS IN TOTAL)
📌 Task
Status

Fixed

Version

1.0

Component

Code

Created by

🇺🇦Ukraine ankondrat4 Lutsk

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024