Fix the issues reported by PHP_CodeSniffer

Created on 20 September 2024, 3 months ago

Problem/Motivation

FILE: poll_rest\poll_rest.info.yml
-------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------
1 | WARNING | Remove "project" from the info file, it will be added by drupal.org packaging automatically
1 | WARNING | Remove "datestamp" from the info file, it will be added by drupal.org packaging automatically
1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
-------------------------------------------------------------------------------------------------------------

FILE: poll_rest\poll_rest.install
----------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------
12 | WARNING | [ ] Line exceeds 80 characters; contains 95 characters
12 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing
| | parentheses
----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------

FILE: poll_rest\README.md
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
3 | WARNING | Line exceeds 80 characters; contains 109 characters
88 | WARNING | Line exceeds 80 characters; contains 101 characters
----------------------------------------------------------------------

FILE: poll_rest\src\Plugin\rest\resource\PollVoteResource.php
----------------------------------------------------------------------------------------------------------------------
FOUND 47 ERRORS AND 4 WARNINGS AFFECTING 46 LINES
----------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
1 | ERROR | [x] Expected 1 line before declare statement, found 0.
1 | ERROR | [x] Expected strict_types=1, found strict_types = 1.
6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is
| | Drupal\Component\Datetime\TimeInterface.
7 | WARNING | [x] Unused use statement
12 | WARNING | [x] Unused use statement
15 | WARNING | [x] Unused use statement
15 | ERROR | [x] Non-namespaced classes/interfaces/traits should not be referenced with use statements
38 | ERROR | [ ] Missing short description in doc comment
57 | ERROR | [ ] Missing short description in doc comment
76 | ERROR | [x] Parameter comment indentation must be 3 spaces, found 2 spaces
77 | ERROR | [ ] Doc comment for parameter $current_user does not match actual variable name $time
80 | ERROR | [x] Parameter comment must end with a full stop
84 | ERROR | [x] Expected 1 space between comma and type hint "Request"; 2 found
84 | ERROR | [x] Expected one space after the comma, 2 found
133 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
139 | ERROR | [x] Expected newline after closing brace
142 | ERROR | [x] Expected newline after closing brace
146 | ERROR | [x] Expected newline after closing brace
171 | ERROR | [ ] Missing parameter type
172 | ERROR | [x] Parameter comment indentation must be 3 spaces, found 2 spaces
173 | ERROR | [ ] Missing parameter type
174 | ERROR | [x] Parameter comment indentation must be 3 spaces, found 2 spaces
176 | ERROR | [ ] Description for the @return value is missing
185 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing
| | parentheses
187 | ERROR | [x] Expected 1 space after IF keyword; 0 found
201 | ERROR | [x] Expected newline after closing brace
209 | ERROR | [x] Perl-style comments are not allowed; use "// Comment" instead
210 | ERROR | [x] Perl-style comments are not allowed; use "// Comment" instead
211 | ERROR | [x] Perl-style comments are not allowed; use "// Comment" instead
212 | ERROR | [x] Perl-style comments are not allowed; use "// Comment" instead
214 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
221 | ERROR | [ ] Missing parameter type
222 | ERROR | [x] Parameter comment indentation must be 3 spaces, found 2 spaces
224 | ERROR | [ ] Description for the @return value is missing
238 | ERROR | [x] Expected newline after closing brace
247 | ERROR | [x] Perl-style comments are not allowed; use "// Comment" instead
248 | ERROR | [x] Perl-style comments are not allowed; use "// Comment" instead
249 | ERROR | [x] Perl-style comments are not allowed; use "// Comment" instead
250 | ERROR | [x] Perl-style comments are not allowed; use "// Comment" instead
252 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
259 | ERROR | [ ] Missing parameter type
260 | ERROR | [x] Parameter comment indentation must be 3 spaces, found 2 spaces
288 | ERROR | [x] Parameter comment indentation must be 3 spaces, found 2 spaces
290 | ERROR | [x] Parameter comment indentation must be 3 spaces, found 2 spaces
290 | ERROR | [x] Parameter comment must end with a full stop
301 | ERROR | [x] Expected newline after closing brace
329 | WARNING | [x] 'TODO: If we are anonymous the poll is not allowed.' should match the format '@todo Fix problem
| | X here.'
335 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
436 | ERROR | [x] Expected 1 blank line after function; 2 found
439 | ERROR | [x] The closing brace for the class must have an empty line before it
----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 42 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------

Steps to reproduce

Run phpcs command to get the drupal coding standard issues.

Proposed resolution

Many of the issues can be fixed by running the phpcbf command. For the remaining ones, we will need to manually address and then commit these changes before pushing them.

📌 Task
Status

Needs review

Version

1.0

Component

Code

Created by

🇺🇸United States sunil jolapara 3265 Summitrun Drive, Independence, KY, 41051

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