Fix phpcs (Code Sniffer) coding standards

Created on 12 July 2018, over 6 years ago
Updated 29 April 2023, over 1 year ago

Problem / Motivation
PHP_CodeSniffer is a library that tokenises PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.
I have noticed that we have some violations for this module, and I though would be good fixing this minor issues so we can have a more compliant and consistent code.

FILE: blocktabs/blocktabs.module
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
44 | ERROR | [x] Inline comments must end in full-stops, exclamation
| | marks, colons, question marks, or closing
| | parentheses
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: blocktabs/src/Annotation/Tab.php
----------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 3 LINES
----------------------------------------------------------------------
10 | ERROR | [x] Doc comment long description must end with a full
| | stop
39 | ERROR | [ ] The @var tag must be the first tag in a member
| | variable comment
50 | ERROR | [ ] The @var tag must be the first tag in a member
| | variable comment
50 | ERROR | [x] Expected
| | "\Drupal\Core\Annotation\Translationoptional" but
| | found "\Drupal\Core\Annotation\Translation
| | (optional)" for @var tag in member variable comment
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: blocktabs/src/Form/BlocktabsFormBase.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
72 | WARNING | t() calls should be avoided in classes, use
| | dependency injection and $this->t() instead
----------------------------------------------------------------------

FILE: blocktabs/src/Form/TabFormBase.php
----------------------------------------------------------------------
FOUND 7 ERRORS AND 1 WARNING AFFECTING 5 LINES
----------------------------------------------------------------------
39 | ERROR | [ ] Parameter $form is not described in comment
39 | ERROR | [ ] Parameter $form_state is not described in
| | comment
130 | WARNING | [ ] Line exceeds 80 characters; contains 84
| | characters
142 | ERROR | [x] Spaces must be used to indent lines; tabs are
| | not allowed
142 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 1
142 | ERROR | [x] Closing brace indented incorrectly; expected 4
| | spaces, found 1
150 | ERROR | [x] Inline comments must end in full-stops,
| | exclamation marks, colons, question marks, or
| | closing parentheses
152 | ERROR | [x] Whitespace found at end of line
----------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: blocktabs/src/Plugin/Tab/ViewsTab.php
----------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 3 LINES
----------------------------------------------------------------------
63 | ERROR | [x] Spaces must be used for alignment; tabs are not
| | allowed
63 | ERROR | [x] Whitespace found at end of line
93 | ERROR | [x] Inline comments must end in full-stops,
| | exclamation marks, colons, question marks, or
| | closing parentheses
101 | ERROR | [x] Inline comments must end in full-stops,
| | exclamation marks, colons, question marks, or
| | closing parentheses
----------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: blocktabs/src/TabInterface.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
8 | WARNING | [x] Unused use statement
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: blocktabs/src/TabPluginCollection.php
----------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
----------------------------------------------------------------------
15 | ERROR | Description for the @return value is missing
17 | WARNING | Possible useless method overriding detected
----------------------------------------------------------------------

Proposed Solution
Apply a patch in order to:

1- Comply with comment standards
2- Comply with coding standards
3- Remove unused "use" statements
4- Remove unused comments inside the code.

Regards,

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇯🇵Japan bertonha

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