Fix the errors/warnings reported by PHP_CodeSniffer

Created on 16 March 2024, 8 months ago
Updated 6 April 2024, 8 months ago

Problem/Motivation

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

FILE: /web/modules/contrib/tardis/tardis.module
----------------------------------------------------------------------------------------------------------
FOUND 4 ERRORS AND 1 WARNING AFFECTING 5 LINES
----------------------------------------------------------------------------------------------------------
  1 | ERROR   | [x] Missing file doc comment
 17 | ERROR   | [x] Short array syntax must be used to define arrays
 18 | ERROR   | [x] Short array syntax must be used to define arrays
 39 | ERROR   | [x] Short array syntax must be used to define arrays
 46 | WARNING | [ ] Avoid backslash escaping in translatable strings when possible, use "" quotes instead
----------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------


FILE: /web/modules/contrib/tardis/tardis.theme.inc
------------------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AND 4 WARNINGS AFFECTING 7 LINES
------------------------------------------------------------------------------------------------------------------------------
  6 | ERROR   | [x] There must be exactly one blank line after the file comment
  7 | ERROR   | [x] Missing function doc comment
 12 | ERROR   | [x] Short array syntax must be used to define arrays
 14 | WARNING | [ ] Unused variable $id.
 15 | WARNING | [x] 'Todo: date field options apart from "created date".' should match the format '@todo Fix problem X here.'
 28 | WARNING | [x] 'TODO: CLEAN UP & MATCH WITH BELOW' should match the format '@todo Fix problem X here.'
 28 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 32 | WARNING | [x] 'TODO: CLEAN UP & MATCH WITH ABOVE' should match the format '@todo Fix problem X here.'
 32 | 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
------------------------------------------------------------------------------------------------------------------------------


FILE: /web/modules/contrib/tardis/src/Plugin/views/style/TardisStyle.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 14 ERRORS AND 8 WARNINGS AFFECTING 21 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
   3 | ERROR   | [x] Namespaced classes, interfaces and traits should not begin with a file doc comment
  15 | ERROR   | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
  27 | ERROR   | [x] Additional blank lines found at end of doc comment
  30 | ERROR   | [x] Doc comment short description must end with a full stop
  32 | ERROR   | [x] Expected 1 blank line before function; 0 found
  34 | ERROR   | [x] Short array syntax must be used to define arrays
  45 | ERROR   | [x] Short array syntax must be used to define arrays
  47 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  49 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  53 | ERROR   | [x] Short array syntax must be used to define arrays
  55 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  57 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  57 | ERROR   | [x] Short array syntax must be used to define arrays
  60 | ERROR   | [x] Short array syntax must be used to define arrays
  66 | ERROR   | [x] Short array syntax must be used to define arrays
  68 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  71 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 103 | ERROR   | [x] Short array syntax must be used to define arrays
 105 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 107 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 109 | ERROR   | [x] Expected 1 blank line after function; 0 found
 110 | ERROR   | [x] The closing brace for the class must have an empty line before it
----------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 13 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------

Time: 53ms; Memory: 10MB

πŸ› Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine Andrii Momotov

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