Fix the errors/warnings reported by PHP_CodeSniffer

Created on 7 March 2024, 4 months ago

Problem/Motivation

When running the module code against Drupal coding standards based on Drupal standard, the module shows errors

Steps to reproduce

Run the following commands:

phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,yml modules/contrib/autoplay/

Report:

FILE: /home/contribution/drupal/web/modules/contrib/autoplay/src/Plugin/WebformHandler/AutoplayHandler.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 12 ERRORS AND 2 WARNINGS AFFECTING 11 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
   9 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\autoplay\AutoplayBase.
  61 | ERROR   | [x] Expected 1 space after cast statement; 0 found
  63 | WARNING | [x] A comma should follow the last multiline array item. Found: configuration
 172 | WARNING | [x] 'TODO? Multiple multiples?? Potentially many permutations/requests' should match the format '@todo Fix problem X here.'
 172 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 260 | ERROR   | [ ] The array declaration extends to column 185 (the limit is 120). The array content should be split up over multiple lines
 266 | ERROR   | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
 270 | ERROR   | [x] Separate the @param and @return sections by a blank line.
 270 | ERROR   | [ ] Return type missing for @return tag in function comment
 282 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 285 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 305 | ERROR   | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
 309 | ERROR   | [x] Separate the @param and @return sections by a blank line.
 309 | ERROR   | [ ] Return type missing for @return tag in function comment
----------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 9 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------


FILE: /home/contribution/drupal/web/modules/contrib/autoplay/src/Plugin/QueueWorker/AutoplaySubmissionHandler.php
------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 11 ERRORS AND 2 WARNINGS AFFECTING 9 LINES
------------------------------------------------------------------------------------------------------------------------------------------------
  5 | ERROR   | [x] No space found before comment text; expected "// use Drupal\Core\Entity\EntityStorageInterface;" but found "//use
    |         |     Drupal\Core\Entity\EntityStorageInterface;"
  5 | ERROR   | [x] Inline comments must start with a capital letter
  5 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
  6 | WARNING | [x] Unused use statement
  8 | ERROR   | [x] No space found before comment text; expected "// use Drupal\node\NodeInterface;" but found "//use
    |         |     Drupal\node\NodeInterface;"
  8 | ERROR   | [x] Inline comments must start with a capital letter
  8 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 10 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\autoplay\AutoplayBase.
 25 | ERROR   | [x] Expected 1 blank line before function; 0 found
 26 | WARNING | [ ] Line exceeds 80 characters; contains 94 characters
 30 | ERROR   | [x] Missing function doc comment
 36 | ERROR   | [x] Expected 1 blank line after function; 0 found
 37 | ERROR   | [x] The closing brace for the class must have an empty line before it
------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 12 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------------------


FILE: /home/contribution/drupal/web/modules/contrib/autoplay/src/Form/AutoplayConfigForm.php
-----------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
-----------------------------------------------------------------------------------------------------
  8 | ERROR | [x] Missing class doc comment
 75 | ERROR | [x] Expected 1 blank line after function; 0 found
 76 | ERROR | [x] The closing brace for the class must have an empty line before it
-----------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------


FILE: /home/contribution/drupal/web/modules/contrib/autoplay/src/AutoplayBase.php
------------------------------------------------------------------------------------------
FOUND 10 ERRORS AND 1 WARNING AFFECTING 11 LINES
------------------------------------------------------------------------------------------
   5 | ERROR   | [x] When importing a class with "use", do not include a leading \
   7 | ERROR   | [x] Missing class doc comment
   9 | ERROR   | [x] Missing function doc comment
  52 | ERROR   | [x] Missing function doc comment
  55 | ERROR   | [x] Expected newline after closing brace
  60 | ERROR   | [x] Missing function doc comment
  67 | ERROR   | [x] Missing function doc comment
  92 | ERROR   | [x] Missing function doc comment
 109 | ERROR   | [x] Missing function doc comment
 132 | WARNING | [ ] The use of function dpm() is discouraged
 148 | ERROR   | [x] Concat operator must be surrounded by a single space
------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 10 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------

📌 Task
Status

Needs review

Version

1.0

Component

Code

Created by

🇮🇳India realsp

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

Production build 0.69.0 2024