Drupal Coding Standards Issues | phpcs

Created on 3 February 2023, almost 2 years ago
Updated 5 February 2023, almost 2 years ago

Problem/Motivation

C:\xampp\htdocs\abc\drupal\modules>phpcs --standard="Drupal,DrupalPractice" --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml entity_type_clone

FILE: ...rupal\modules\entity_type_clone\entity_type_clone.links.menu.yml
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
7 | ERROR | [x] Expected 1 newline at end of file; 2 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ...cs\abc\drupal\modules\entity_type_clone\entity_type_clone.module
----------------------------------------------------------------------
FOUND 16 ERRORS AFFECTING 11 LINES
----------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but
| | found "\r\n"
6 | ERROR | [x] There must be exactly one blank line after the file
| | comment
11 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found
| | 1
12 | ERROR | [x] Expected 2 space(s) before asterisk; 1 found
13 | ERROR | [x] Expected 2 space(s) before asterisk; 1 found
37 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found
| | 0
37 | ERROR | [x] No space found before comment text; expected "//
| | Get the entity info." but found "//Get the entity
| | info."
39 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found
| | 0
39 | ERROR | [x] No space found before comment text; expected "//
| | Get the entity bundle." but found "//Get the entity
| | bundle."
41 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found
| | 0
41 | ERROR | [x] No space found before comment text; expected "//
| | Get the user account." but found "//Get the user
| | account."
43 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found
| | 0
43 | ERROR | [x] No space found before comment text; expected "//
| | Add the clone link to operations." but found "//Add
| | the clone link to operations."
50 | ERROR | [x] The first index in a multi-value array must be on a
| | new line
50 | ERROR | [x] Each index in a multi-line array must be on a new
| | line
51 | ERROR | [x] Array closing indentation error, expected 8 spaces
| | but found 6
----------------------------------------------------------------------
PHPCBF CAN FIX THE 16 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ...s\entity_type_clone\src\Controller\EntityTypeCloneController.php
----------------------------------------------------------------------
FOUND 5 ERRORS AND 2 WARNINGS AFFECTING 7 LINES
----------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n"
| | but found "\r\n"
12 | WARNING | [ ] The class short comment should describe what the
| | class does and not simply repeat the class name
24 | ERROR | [x] Separate the @param and @return sections by a
| | blank line.
27 | ERROR | [ ] Type hint "array" missing for $arr
40 | ERROR | [x] Missing function doc comment
41 | ERROR | [x] Inline comments must end in full-stops,
| | exclamation marks, question marks, colons, or
| | closing parentheses
55 | WARNING | [ ] Unused variable $displayConfig.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ...upal\modules\entity_type_clone\src\Controller\UUIDController.php
----------------------------------------------------------------------
FOUND 2 ERRORS AND 4 WARNINGS AFFECTING 6 LINES
----------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n"
| | but found "\r\n"
12 | WARNING | [ ] The class short comment should describe what the
| | class does and not simply repeat the class name
15 | ERROR | [x] Missing function doc comment
17 | WARNING | [ ] \Drupal calls should be avoided in classes, use
| | dependency injection instead
20 | WARNING | [ ] \Drupal calls should be avoided in classes, use
| | dependency injection instead
24 | WARNING | [ ] \Drupal calls should be avoided in classes, use
| | dependency injection instead
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ...bc\drupal\modules\entity_type_clone\src\Form\CloneEntityType.php
----------------------------------------------------------------------
FOUND 11 ERRORS AND 9 WARNINGS AFFECTING 19 LINES
----------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n"
| | but found "\r\n"
15 | WARNING | [ ] The class short comment should describe what the
| | class does and not simply repeat the class name
32 | ERROR | [x] Missing function doc comment
36 | ERROR | [x] Missing function doc comment
46 | WARNING | [ ] \Drupal calls should be avoided in classes, use
| | dependency injection instead
68 | WARNING | [x] Inline @var declarations should use the /** */
| | delimiters
85 | ERROR | [x] Use null coalesce operator instead of ternary
| | operator.
90 | WARNING | [x] A comma should follow the last multiline array
| | item. Found: ]
93 | ERROR | [x] Use null coalesce operator instead of ternary
| | operator.
94 | WARNING | [ ] \Drupal calls should be avoided in classes, use
| | dependency injection instead
95 | WARNING | [ ] Line exceeds 80 characters; contains 85
| | characters
112 | WARNING | [x] A comma should follow the last multiline array
| | item. Found: '

'
197 | ERROR | [ ] Missing parameter comment
197 | ERROR | [x] Data types in @param tags need to be fully
| | namespaced
199 | ERROR | [ ] Description for the @return value is missing
207 | ERROR | [ ] The array declaration extends to column 106 (the
| | limit is 80). The array content should be split
| | up over multiple lines
209 | WARNING | [ ] \Drupal calls should be avoided in classes, use
| | dependency injection instead
225 | ERROR | [ ] Missing parameter comment
227 | ERROR | [ ] Description for the @return value is missing
233 | WARNING | [ ] \Drupal calls should be avoided in classes, use
| | dependency injection instead
----------------------------------------------------------------------
PHPCBF CAN FIX THE 9 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ...rupal\modules\entity_type_clone\src\Form\CloneEntityTypeData.php
----------------------------------------------------------------------
FOUND 13 ERRORS AND 2 WARNINGS AFFECTING 14 LINES
----------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n"
| | but found "\r\n"
17 | WARNING | [ ] The class short comment should describe what the
| | class does and not simply repeat the class name
36 | WARNING | [ ] Line exceeds 80 characters; contains 81
| | characters
76 | ERROR | [ ] PHP4 style constructors are not allowed; use
| | "__construct()" instead
109 | ERROR | [x] Short array syntax must be used to define arrays
110 | ERROR | [x] Array indentation error, expected 8 spaces but
| | found 10
111 | ERROR | [x] Array indentation error, expected 8 spaces but
| | found 10
112 | ERROR | [x] Array indentation error, expected 8 spaces but
| | found 10
120 | ERROR | [x] Array indentation error, expected 10 spaces but
| | found 12
121 | ERROR | [x] Array indentation error, expected 10 spaces but
| | found 12
122 | ERROR | [x] Array indentation error, expected 10 spaces but
| | found 12
122 | ERROR | [x] Use null coalesce operator instead of ternary
| | operator.
123 | ERROR | [x] Array indentation error, expected 10 spaces but
| | found 12
124 | ERROR | [x] Array indentation error, expected 10 spaces but
| | found 12
125 | ERROR | [x] Array indentation error, expected 10 spaces but
| | found 12
----------------------------------------------------------------------
PHPCBF CAN FIX THE 12 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 628ms; Memory: 10MB

Steps to reproduce

Run the following command : phpcs --standard="Drupal,DrupalPractice" --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml /10.1.x/drupal/modules/contrib/entity_type_clone

Proposed resolution

Fix all the PHP coding standard issues.

📌 Task
Status

Fixed

Version

2.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