Drupal Coding Standards Issues | phpcs

Created on 27 January 2023, almost 2 years ago
Updated 30 January 2023, almost 2 years ago

Problem/Motivation

Getting following error/warnings

FILE: C:\xampp\htdocs\abc\drupal\modules\unmanaged_files\README.md
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
24 | WARNING | Line exceeds 80 characters; contains 86 characters
59 | WARNING | Line exceeds 80 characters; contains 84 characters
----------------------------------------------------------------------

FILE: ...tdocs\abc\drupal\modules\unmanaged_files\src\File\FileSystem.php
----------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 3 LINES
----------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n"
| | but found "\r\n"
98 | ERROR | [ ] Type hint "array" missing for $options
139 | ERROR | [ ] Type hint "array" missing for $options
139 | ERROR | [ ] Type hint "array" missing for $directories
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ...al\modules\unmanaged_files\src\Form\DeleteUnmanagedFilesForm.php
----------------------------------------------------------------------
FOUND 5 ERRORS AND 4 WARNINGS AFFECTING 9 LINES
----------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n"
| | but found "\r\n"
11 | WARNING | [ ] The class short comment should describe what the
| | class does and not simply repeat the class name
19 | ERROR | [ ] Class property $UnmanagedFilesManager should use
| | lowerCamel naming without underscores
117 | WARNING | [x] A comma should follow the last multiline array
| | item. Found: ]
130 | ERROR | [ ] Type hint "array" missing for $form
176 | ERROR | [ ] Parameter $unmanagedFiles is not described in
| | comment
182 | ERROR | [ ] Type hint "array" missing for $form
228 | WARNING | [ ] t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait
| | and $this->t() instead
233 | WARNING | [ ] Unused variable $dir.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ...pal\modules\unmanaged_files\src\Form\UnmanagedFilesAdminForm.php
----------------------------------------------------------------------
FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES
----------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n"
| | but found "\r\n"
11 | WARNING | [ ] The class short comment should describe what the
| | class does and not simply repeat the class name
19 | ERROR | [ ] Class property $UnmanagedFilesManager should use
| | lowerCamel naming without underscores
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ...abc\drupal\modules\unmanaged_files\src\UnmanagedFilesManager.php
----------------------------------------------------------------------
FOUND 13 ERRORS AND 2 WARNINGS AFFECTING 15 LINES
----------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n"
| | but found "\r\n"
11 | WARNING | [ ] The class short comment should describe what the
| | class does and not simply repeat the class name
17 | ERROR | [ ] Class constants must be uppercase; expected
| | MANDATORYEXDIRS but found mandatoryExDirs
89 | WARNING | [x] A comma should follow the last multiline array
| | item. Found: TRUE
129 | ERROR | [ ] Missing parameter type
131 | ERROR | [ ] Missing parameter type
133 | ERROR | [ ] Missing parameter type
135 | ERROR | [ ] Missing parameter type
176 | ERROR | [ ] Missing parameter type
178 | ERROR | [ ] Missing parameter type
180 | ERROR | [ ] Missing parameter type
182 | ERROR | [ ] Missing parameter type
204 | ERROR | [ ] Missing parameter type
277 | ERROR | [ ] Missing parameter type
279 | ERROR | [ ] Missing parameter type
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ...s\abc\drupal\modules\unmanaged_files\unmanaged_files.routing.yml
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
7 | WARNING | The administration page callback should probably use
| | "administer site configuration" - which implies the
| | user can change something - rather than "access
| | administration pages" which is about viewing but not
| | changing configurations.
17 | WARNING | The administration page callback should probably use
| | "administer site configuration" - which implies the
| | user can change something - rather than "access
| | administration pages" which is about viewing but not
| | changing configurations.
----------------------------------------------------------------------

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/unmanaged_files/

Proposed resolution

Above error/warnings need to be fixed.

📌 Task
Status

RTBC

Version

1.0

Component

Code

Created by

🇮🇳India Charchil Khandelwal

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

Comments & Activities

Production build 0.71.5 2024