Drupal coding standards issues

Created on 8 December 2022, about 2 years ago
Updated 22 February 2023, almost 2 years ago

Problem/Motivation

Getting following error/warnings

FILE: /app/modules/contrib/taxonomy_menu/src/Controller/TaxonomyMenu.php
------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
------------------------------------------------------------------------
25 | WARNING | Unused variable $links.
29 | WARNING | Unused variable $links.
------------------------------------------------------------------------

FILE: /app/modules/contrib/taxonomy_menu/src/Entity/TaxonomyMenu.php
-----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 4 WARNINGS AFFECTING 5 LINES
-----------------------------------------------------------------------------------------------------------------------------------------------
148 | ERROR | [x] Use null coalesce operator instead of ternary operator.
199 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
259 | WARNING | [x] 'TODO:' should match the format '@todo Fix problem X here.'
262 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
277 | WARNING | [x] 'TODO: Consider implementing a forced weight based on taxonomy tree.' should match the format '@todo Fix problem X here.'
-----------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/taxonomy_menu/src/Form/TaxonomyMenuForm.php
-------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------------------
156 | WARNING | [ ] Menu::loadMultiple calls should be avoided in classes, use dependency injection instead
178 | ERROR | [x] Use null coalesce operator instead of ternary operator.
-------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/taxonomy_menu/src/Plugin/Derivative/TaxonomyMenuMenuLink.php
---------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
---------------------------------------------------------------------------------------
48 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
53 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
---------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------

FILE: /app/modules/contrib/taxonomy_menu/src/TaxonomyMenuHelper.php
-------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
-------------------------------------------------------------------------------
99 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
138 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
-------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------

FILE: /app/modules/contrib/taxonomy_menu/tests/src/Functional/TaxonomyMenuOperationsTest.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 8 ERRORS AND 8 WARNINGS AFFECTING 16 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
34 | ERROR | [ ] The array declaration extends to column 93 (the limit is 80). The array content should be split up over multiple lines
44 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
60 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
67 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
73 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
81 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
94 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
104 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
109 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
114 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
121 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
141 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
145 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
158 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
161 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
172 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
----------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------

Time: 330ms; Memory: 10MB

Steps to reproduce

Run following command

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

Proposed resolution

Above error/warnings need to be fixed

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

🇮🇳India samit.310@gmail.com

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024