Drupal Coding Standards Issues | phpcs

Created on 17 February 2023, almost 2 years ago
Updated 15 August 2024, 4 months ago

Problem/Motivation

FILE: ...\xampp\htdocs\abc\drupal\modules\current_ip\src\GetCurrentIp.php
----------------------------------------------------------------------
FOUND 26 ERRORS AFFECTING 24 LINES
----------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but
| | found "\r\n"
11 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found
| | 4
16 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found
| | 4
18 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found
| | 4
24 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found
| | 4
25 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found
| | 8
26 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found
| | 4
31 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found
| | 4
32 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found
| | 8
33 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found
| | 8
34 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found
| | 12
35 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found
| | 8
35 | ERROR | [x] Expected newline after closing brace
36 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found
| | 12
37 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found
| | 8
37 | ERROR | [x] Expected newline after closing brace
38 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found
| | 12
39 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found
| | 8
40 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found
| | 8
41 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found
| | 8
42 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found
| | 8
43 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found
| | 12
44 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found
| | 8
45 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found
| | 8
46 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found
| | 4
48 | ERROR | [x] Expected 1 newline at end of file; 3 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 26 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ...urrent_ip\src\Plugin\Field\FieldFormatter\CurrentIpFormatter.php
----------------------------------------------------------------------
FOUND 69 ERRORS AFFECTING 67 LINES
----------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n"
| | but found "\r\n"
32 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
37 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
39 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
59 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
60 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
62 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
63 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
65 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
68 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
69 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 12
79 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
81 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
84 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
85 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
87 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
88 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
89 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
91 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
93 | ERROR | [x] Expected 5 space(s) before asterisk; 4 found
94 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
95 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
97 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
99 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
105 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
106 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
108 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
111 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
112 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
113 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
114 | ERROR | [x] Line indented incorrectly; expected 6 spaces,
| | found 13
115 | ERROR | [x] Line indented incorrectly; expected 6 spaces,
| | found 13
116 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
117 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
118 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
120 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
123 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
124 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
125 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
125 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected
| | "NULL" but found "null"
126 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
127 | ERROR | [x] Line indented incorrectly; expected 6 spaces,
| | found 12
128 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
130 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
131 | ERROR | [x] Line indented incorrectly; expected 6 spaces,
| | found 12
132 | ERROR | [x] Line indented incorrectly; expected 6 spaces,
| | found 12
133 | ERROR | [x] Line indented incorrectly; expected 8 spaces,
| | found 16
138 | ERROR | [x] Line indented incorrectly; expected 6 spaces,
| | found 12
138 | ERROR | [x] Expected newline after closing brace
139 | ERROR | [x] Line indented incorrectly; expected 8 spaces,
| | found 16
140 | ERROR | [x] Line indented incorrectly; expected 6 spaces,
| | found 12
141 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
142 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
143 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
145 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
154 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
155 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
156 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
157 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
162 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
164 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
173 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
174 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
175 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
176 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
177 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
178 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
179 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
181 | ERROR | [x] Expected 1 newline at end of file; 2 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 69 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ...\modules\current_ip\src\Plugin\Field\FieldType\CurrentIpItem.php
----------------------------------------------------------------------
FOUND 34 ERRORS AFFECTING 34 LINES
----------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n"
| | but found "\r\n"
3 | ERROR | [x] Each PHP statement must be on a line by itself
25 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
27 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
30 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
31 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
35 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
37 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
40 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
41 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
50 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
55 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
56 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
58 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
59 | ERROR | [x] Line indented incorrectly; expected 6 spaces,
| | found 12
60 | ERROR | [x] Line indented incorrectly; expected 6 spaces,
| | found 12
61 | ERROR | [x] Array indentation error, expected 14 spaces but
| | found 16
64 | ERROR | [ ] The array declaration extends to column 170 (the
| | limit is 80). The array content should be split up
| | over multiple lines
68 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
70 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
71 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
73 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
76 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
77 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 10
78 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 10
79 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 10
80 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
82 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
85 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
86 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
88 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
98 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
99 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
101 | ERROR | [x] Expected 1 newline at end of file; 2 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 33 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ...ules\current_ip\src\Plugin\Field\FieldWidget\CurrentIpWidget.php
----------------------------------------------------------------------
FOUND 35 ERRORS AND 1 WARNING AFFECTING 35 LINES
----------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n"
| | but found "\r\n"
22 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
24 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
27 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
28 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
32 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
34 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
36 | ERROR | [x] Expected 5 space(s) before asterisk; 4 found
37 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
38 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
42 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected
| | "TRUE" but found "true"
45 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
51 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 9
52 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
54 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
57 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
58 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
60 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
61 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
62 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
63 | ERROR | [x] Line indented incorrectly; expected 6 spaces,
| | found 13
64 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
66 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 8
67 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
69 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
70 | ERROR | [x] Expected 5 space(s) before asterisk; 6 found
72 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
73 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 10
74 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 10
74 | WARNING | [ ] \Drupal calls should be avoided in classes, use
| | dependency injection instead
75 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 10
77 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 10
84 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 12
85 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 12
87 | ERROR | [x] Line indented incorrectly; expected 4 spaces,
| | found 12
88 | ERROR | [x] Line indented incorrectly; expected 2 spaces,
| | found 4
----------------------------------------------------------------------
PHPCBF CAN FIX THE 35 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

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

Proposed resolution

Fix all the PHP coding standard issues.

šŸ“Œ Task
Status

Needs work

Component

Code

Created by

šŸ‡®šŸ‡³India Charchil Khandelwal

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

Comments & Activities

  • Issue created by @Charchil Khandelwal
  • @charchil-khandelwal opened merge request.
  • Issue was unassigned.
  • Status changed to Needs work almost 2 years ago
  • šŸ‡®šŸ‡³India Charchil Khandelwal

    Created MR !3 for the issue.
    Some errors and warnings are fixed now.
    Please review.

    Thanks.

  • Assigned to annmarysruthy
  • Issue was unassigned.
  • šŸ‡®šŸ‡³India annmarysruthy

    Reviewed MR !3. most of the errors and warnings are fixed. However 1 warning remains.

  • šŸ‡®šŸ‡³India Akram Khan Cuttack, Odisha

    Fixed all remaining PHPCS error

  • Status changed to Needs review almost 2 years ago
  • šŸ‡®šŸ‡³India Akram Khan Cuttack, Odisha
  • Status changed to Needs work 4 months ago
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi @Charchil_Khandelwal,

    I applied MR!3, it was applied smoothly and fixed most of the phpcs issues.

    These are the remaining issues after I run phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml.

    āžœ  current_ip git:(8.x-1.x) curl https://git.drupalcode.org/project/current_ip/-/merge_requests/3.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 23016    0 23016    0     0  48695      0 --:--:-- --:--:-- --:--:-- 48762
    patching file src/GetCurrentIp.php
    patching file src/Plugin/Field/FieldFormatter/CurrentIpFormatter.php
    patching file src/Plugin/Field/FieldType/CurrentIpItem.php
    patching file src/Plugin/Field/FieldWidget/CurrentIpWidget.php
    āžœ  current_ip git:(8.x-1.x) āœ— ..
    āžœ  contrib phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml current_ip
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/current_ip/src/Plugin/Field/FieldType/CurrentIpItem.php
    --------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------------------------------------------------
     11 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Field\Plugin\Field\FieldType\StringItemBase.
    --------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/current_ip/src/Plugin/Field/FieldFormatter/CurrentIpFormatter.php
    --------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------------------------------------
     10 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Field\FieldItemListInterface.
    --------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 159ms; Memory: 10MB
    
    āžœ  contrib

    Thank you.

Production build 0.71.5 2024