Fix coding standard issue | PHPCS

Created on 10 February 2023, over 1 year ago
Updated 12 September 2024, 16 days ago

Problem/Motivation

Fix the following issues from PHPCS.

FILE: ...htdocs/d9/web/modules/contrib/last_visited_pages/last_visited_pages.module
--------------------------------------------------------------------------------
FOUND 19 ERRORS AFFECTING 11 LINES
--------------------------------------------------------------------------------
4 | ERROR | [x] The second line in the file doc comment must be "@file"
15 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
15 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
16 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
16 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
17 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
17 | ERROR | [x] Case breaking statement indented incorrectly; expected 4
| | spaces, found 2
19 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
19 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
20 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
20 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 2
21 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
21 | ERROR | [x] Case breaking statement indented incorrectly; expected 4
| | spaces, found 2
22 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
22 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
28 | ERROR | [ ] last_visited_pages_uninstall() is an installation hook and
| | must be declared in an install file
29 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
29 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
30 | ERROR | [x] Expected 1 newline at end of file; 0 found
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 18 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: ...tdocs/d9/web/modules/contrib/last_visited_pages/last_visited_pages.install
--------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------
1 | ERROR | [x] Missing file doc comment
49 | ERROR | [x] Expected 1 newline at end of file; 0 found
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: ...dules/contrib/last_visited_pages/src/Form/LastVisitedPagesSettingsForm.php
--------------------------------------------------------------------------------
FOUND 8 ERRORS AFFECTING 7 LINES
--------------------------------------------------------------------------------
21 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
32 | ERROR | [x] Expected 3 space(s) before asterisk; 2 found
33 | ERROR | [x] Expected 3 space(s) before asterisk; 2 found
35 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
45 | ERROR | [x] Expected one space after the comma, 0 found
45 | ERROR | [x] Expected one space after the comma, 0 found
68 | ERROR | [x] Expected 1 blank line after function; 0 found
69 | ERROR | [x] The closing brace for the class must have an empty line
| | before it
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: .../web/modules/contrib/last_visited_pages/src/LastVisitedPagesSubscriber.php
--------------------------------------------------------------------------------
FOUND 30 ERRORS AFFECTING 22 LINES
--------------------------------------------------------------------------------
3 | ERROR | [x] Namespaced classes, interfaces and traits should not begin
| | with a file doc comment
30 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
31 | ERROR | [x] Short array syntax must be used to define arrays
36 | ERROR | [x] Expected 1 space after IF keyword; 0 found
38 | ERROR | [x] Expected newline after closing brace
42 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
43 | ERROR | [x] Expected 1 space after IF keyword; 0 found
49 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 6
49 | ERROR | [x] Object operator not indented correctly; expected 8 spaces but
| | found 6
55 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 6
55 | ERROR | [x] Short array syntax must be used to define arrays
61 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 6
64 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 6
64 | ERROR | [x] Object operator not indented correctly; expected 8 spaces but
| | found 6
64 | ERROR | [x] Short array syntax must be used to define arrays
65 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 6
66 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 6
67 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 6
70 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 6
70 | ERROR | [x] Object operator not indented correctly; expected 8 spaces but
| | found 6
71 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 6
73 | ERROR | [x] Expected 1 space after IF keyword; 0 found
75 | ERROR | [x] Line indented incorrectly; expected 10 spaces, found 8
75 | ERROR | [x] Object operator not indented correctly; expected 10 spaces
| | but found 8
76 | ERROR | [x] Line indented incorrectly; expected 10 spaces, found 8
85 | ERROR | [x] Visibility must be declared on method "getSubscribedEvents"
85 | ERROR | [x] Expected 1 space before opening brace; found 0
86 | ERROR | [x] Short array syntax must be used to define arrays
89 | ERROR | [x] Expected 1 newline at end of file; 0 found
89 | ERROR | [x] The closing brace for the class must have an empty line
| | before it
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 30 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: ...ules/contrib/last_visited_pages/src/Plugin/Block/LastVisitedPagesBlock.php
--------------------------------------------------------------------------------
FOUND 120 ERRORS AFFECTING 83 LINES
--------------------------------------------------------------------------------
20 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
23 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
23 | ERROR | [x] Expected 1 blank line before function; 2 found
24 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
25 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
26 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
28 | 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 6
34 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
34 | ERROR | [x] Inline comments must end in full-stops, exclamation marks,
| | question marks, colons, or closing parentheses
35 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
36 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
36 | ERROR | [x] Expected 1 space after "??"; 0 found
38 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
38 | ERROR | [x] Inline comments must end in full-stops, exclamation marks,
| | question marks, colons, or closing parentheses
39 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
40 | ERROR | [x] Object operator not indented correctly; expected 8 spaces
| | but found 6
40 | ERROR | [x] Short array syntax must be used to define arrays
45 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
46 | ERROR | [x] Object operator not indented correctly; expected 8 spaces
| | but found 6
49 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
49 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but
| | found "false"
51 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
51 | ERROR | [x] Expected 1 space after IF keyword; 0 found
52 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
52 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but
| | found "true"
53 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
53 | ERROR | [x] Expected 1 space after "??"; 0 found
55 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
56 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
56 | ERROR | [x] Inline comments must end in full-stops, exclamation marks,
| | question marks, colons, or closing parentheses
57 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
57 | ERROR | [x] Comments may not appear after statements
59 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
59 | ERROR | [x] Expected 1 space after IF keyword; 0 found
60 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 10
61 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 12
61 | ERROR | [x] Short array syntax must be used to define arrays
63 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 12
63 | ERROR | [x] Expected 1 space after IF keyword; 0 found
64 | ERROR | [x] Line indented incorrectly; expected 10 spaces, found 14
65 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 12
67 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 12
67 | ERROR | [x] Expected 1 space after IF keyword; 0 found
68 | ERROR | [x] Line indented incorrectly; expected 10 spaces, found 14
68 | ERROR | [x] Expected one space after the comma, 0 found
70 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 12
70 | ERROR | [x] Expected newline after closing brace
71 | ERROR | [x] Line indented incorrectly; expected 10 spaces, found 14
73 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 12
74 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 10
76 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
78 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
79 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 10
81 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 10
81 | ERROR | [x] Expected 1 space after IF keyword; 0 found
82 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 12
82 | ERROR | [ ] Concatenating translatable strings is not allowed, use
| | placeholders instead and only one string literal
82 | ERROR | [x] Concat operator must be surrounded by a single space
82 | ERROR | [x] Concat operator must be surrounded by a single space
83 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 10
85 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 10
86 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
87 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
87 | ERROR | [x] Short array syntax must be used to define arrays
88 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
88 | ERROR | [x] Closing brace indented incorrectly; expected 4 spaces, found
| | 6
90 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
93 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
94 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
96 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
97 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
98 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
98 | ERROR | [x] Use null coalesce operator instead of ternary operator.
100 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
100 | ERROR | [x] Expected 1 space before "??"; 0 found
100 | ERROR | [x] Expected 1 space after "??"; 0 found
100 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but
| | found "true"
102 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
103 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
103 | ERROR | [x] Short array syntax must be used to define arrays
107 | ERROR | [x] Expected one space after the comma, 0 found
107 | ERROR | [x] Expected one space after the comma, 0 found
110 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
112 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
113 | ERROR | [x] Object operator not indented correctly; expected 8 spaces
| | but found 6
116 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
117 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
117 | ERROR | [ ] The array declaration extends to column 183 (the limit is
| | 80). The array content should be split up over multiple
| | lines
118 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
120 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
122 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
126 | ERROR | [x] Expected 1 space after "=>"; 2 found
126 | ERROR | [x] Expected 1 space before "??"; 0 found
126 | ERROR | [x] Expected 1 space after "??"; 0 found
129 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
133 | ERROR | [x] Expected 1 space after "=>"; 2 found
133 | ERROR | [x] Expected 1 space before "??"; 0 found
133 | ERROR | [x] Expected 1 space after "??"; 0 found
136 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
140 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
141 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
143 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
146 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
147 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
148 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
149 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
150 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
151 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
153 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
156 | ERROR | [x] Doc comment long description must start with a capital
| | letter
158 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
159 | ERROR | [x] Opening brace should be on the same line as the declaration
160 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
161 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
161 | ERROR | [x] Expected 1 blank line after function; 0 found
162 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 2
162 | ERROR | [x] The closing brace for the class must have an empty line
| | before it
162 | ERROR | [x] Closing brace indented incorrectly; expected 0 spaces, found
| | 2
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 118 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

๐Ÿ“Œ Task
Status

Needs review

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia noorulshameera

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

Merge Requests

Comments & Activities

  • Issue created by @noorulshameera
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia noorulshameera

    Adding patch to fix the issue.

  • Assigned to sidharth_soman
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sidharth_soman Bangalore

    I will review this

  • Issue was unassigned.
  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sidharth_soman Bangalore

    #2 applied cleanly. It resolved most of the errors. However, there are still some minor ones left. Moving back to 'Needs Work' for now in case anyone is interested in taking up the rest of the task.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia kkalashnikov Ghaziabad, India
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Akram Khan Cuttack, Odisha

    after applying patch #5 still there are some issue added SS

  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Akram Khan Cuttack, Odisha

    Added updated patch and fixed all remaining PHPCS issues

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia rassoni Bangalore

    Rashmisoni โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia saket-001

    applying patch #7 it fixes the all minor phpcs issue.

  • Status changed to Needs work about 2 months ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines cleavinjosh

    Hi @soni.rashu,

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

    I still encounter one issue after I run phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml.

    โžœ  last_visited_pages git:(1.0.1) curl https://git.drupalcode.org/project/last_visited_pages/-/merge_requests/2.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 22744    0 22744    0     0  45823      0 --:--:-- --:--:-- --:--:-- 45762
    patching file README.md
    patching file config/install/last_visited_pages.settings.yml
    patching file last_visited_pages.info.yml
    patching file last_visited_pages.install
    patching file last_visited_pages.module
    patching file last_visited_pages.routing.yml
    patching file last_visited_pages.services.yml
    patching file src/Form/LastVisitedPagesSettingsForm.php
    patching file src/LastVisitedPagesSubscriber.php
    patching file src/Plugin/Block/LastVisitedPagesBlock.php
    โžœ  last_visited_pages git:(1.0.1) โœ— ..
    โžœ  contrib phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml last_visited_pages
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/last_visited_pages/src/LastVisitedPagesSubscriber.php
    ----------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------------------------------------------------------
     6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Symfony\Component\EventDispatcher\EventSubscriberInterface.
    ----------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 173ms; Memory: 10MB
    
    โžœ  contrib

    Thank you.

  • Status changed to Needs review 16 days ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines cleavinjosh

    Hi,

    Please review MR!2. Thank you.

Production build 0.71.5 2024