Problem/Motivation
Fix this issues reported by phpcs.
Steps to reproduce:
phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig .
Errors:
FILE: /Users/specbee/Sites/Projects/twitter_feeds/twitter_feeds.libraries.yml
-----------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------
14 | ERROR | [x] Expected 1 newline at end of file; 2 found
-----------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------
FILE: /Users/specbee/Sites/Projects/twitter_feeds/css/custom.css
----------------------------------------------------------------------------
FOUND 20 ERRORS AFFECTING 11 LINES
----------------------------------------------------------------------------
2 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
2 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
3 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
3 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
4 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
4 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
5 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
5 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
6 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
6 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
9 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
9 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
12 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
12 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
13 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
13 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
15 | ERROR | [x] Multiple selectors should each be on a single line
16 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
16 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
17 | ERROR | [x] Expected 1 newline at end of file; 0 found
----------------------------------------------------------------------------
PHPCBF CAN FIX THE 20 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------
FILE: /Users/specbee/Sites/Projects/twitter_feeds/twitter_feeds.module
---------------------------------------------------------------------------------------------
FOUND 4 ERRORS AND 6 WARNINGS AFFECTING 10 LINES
---------------------------------------------------------------------------------------------
8 | WARNING | [x] Unused use statement
9 | WARNING | [x] Unused use statement
11 | WARNING | [x] Unused use statement
12 | WARNING | [x] Unused use statement
21 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 4
22 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 4
23 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 4
24 | ERROR | [x] Case breaking statement indented incorrectly; expected 6 spaces, found 4
36 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
39 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
---------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 10 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------
FILE: /Users/specbee/Sites/Projects/twitter_feeds/twitter_feeds.info.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: /Users/specbee/Sites/Projects/twitter_feeds/templates/twitter-feeds.html.twig
-----------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------
45 | ERROR | [x] Expected 1 newline at end of file; 0 found
-----------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------
FILE: /Users/specbee/Sites/Projects/twitter_feeds/templates/twitter-follow-button.html.twig
-------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------
17 | ERROR | [x] Expected 1 newline at end of file; 0 found
-------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------
FILE: /Users/specbee/Sites/Projects/twitter_feeds/src/Plugin/Block/TwitterFollowButtonBlock.php
-------------------------------------------------------------------------------------------------------------
FOUND 18 ERRORS AND 4 WARNINGS AFFECTING 11 LINES
-------------------------------------------------------------------------------------------------------------
47 | ERROR | [x] Expected 1 space before "??"; 0 found
47 | ERROR | [x] Expected 1 space after "??"; 0 found
50 | WARNING | [x] A comma should follow the last multiline array item. Found: true
50 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
56 | ERROR | [x] Expected 1 space before "??"; 0 found
56 | ERROR | [x] Expected 1 space after "??"; 0 found
56 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
58 | WARNING | [x] A comma should follow the last multiline array item. Found: )
62 | ERROR | [x] Expected 1 blank line after function; 2 found
70 | ERROR | [x] Expected 1 space after IF keyword; 0 found
87 | ERROR | [x] Short array syntax must be used to define arrays
88 | ERROR | [x] Expected 1 space before "??"; 0 found
88 | ERROR | [x] Expected 1 space after "??"; 0 found
89 | ERROR | [x] Expected 1 space before "?"; 0 found
89 | ERROR | [x] Expected 1 space after "?"; 0 found
89 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
89 | ERROR | [x] Expected 1 space before ":"; 0 found
89 | ERROR | [x] Expected 1 space after ":"; 0 found
89 | WARNING | [x] A comma should follow the last multiline array item. Found: false
89 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
95 | WARNING | [x] A comma should follow the last multiline array item. Found: $twitter_follow_button_data
104 | ERROR | [x] Expected 1 newline at end of file; 0 found
-------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 22 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------
FILE: /Users/specbee/Sites/Projects/twitter_feeds/src/Plugin/Block/TwitterFeedsBlock.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 32 ERRORS AND 13 WARNINGS AFFECTING 29 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
47 | ERROR | [x] Expected 1 space before "??"; 0 found
47 | ERROR | [x] Expected 1 space after "??"; 0 found
50 | WARNING | [x] A comma should follow the last multiline array item. Found: true
50 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
56 | ERROR | [x] Expected 1 space before "??"; 0 found
56 | ERROR | [x] Expected 1 space after "??"; 0 found
58 | WARNING | [ ] Avoid backslash escaping in translatable strings when possible, use "" quotes instead
58 | WARNING | [x] A comma should follow the last multiline array item. Found: )
66 | ERROR | [x] Expected 1 space before "??"; 0 found
66 | ERROR | [x] Expected 1 space after "??"; 0 found
69 | WARNING | [x] A comma should follow the last multiline array item. Found: true
69 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
75 | ERROR | [x] Expected 1 space before "??"; 0 found
75 | ERROR | [x] Expected 1 space after "??"; 0 found
82 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
83 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
84 | ERROR | [x] Short array syntax must be used to define arrays
85 | WARNING | [ ] #options values usually have to run through t() for translation
86 | WARNING | [ ] #options values usually have to run through t() for translation
87 | WARNING | [ ] #options values usually have to run through t() for translation
89 | ERROR | [x] Expected 1 space before "??"; 0 found
89 | ERROR | [x] Expected 1 space after "??"; 0 found
92 | ERROR | [x] Short array syntax must be used to define arrays
94 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
95 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
96 | ERROR | [x] Expected 1 space before "??"; 0 found
96 | ERROR | [x] Expected 1 space after "??"; 0 found
96 | WARNING | [x] A comma should follow the last multiline array item. Found: ''
100 | ERROR | [x] Expected 1 blank line after function; 2 found
108 | ERROR | [x] Expected 1 space after IF keyword; 0 found
133 | ERROR | [x] Short array syntax must be used to define arrays
134 | ERROR | [x] Expected 1 space before "??"; 0 found
134 | ERROR | [x] Expected 1 space after "??"; 0 found
135 | ERROR | [x] Expected 1 space before "??"; 0 found
135 | ERROR | [x] Expected 1 space after "??"; 0 found
136 | ERROR | [x] Expected 1 space before "??"; 0 found
136 | ERROR | [x] Expected 1 space after "??"; 0 found
137 | ERROR | [x] Expected 1 space before "??"; 0 found
137 | ERROR | [x] Expected 1 space after "??"; 0 found
138 | ERROR | [x] Expected 1 space before "??"; 0 found
138 | ERROR | [x] Expected 1 space after "??"; 0 found
139 | ERROR | [x] Expected 1 space before "??"; 0 found
139 | ERROR | [x] Expected 1 space after "??"; 0 found
145 | WARNING | [x] A comma should follow the last multiline array item. Found: $twitter_feeds_data
153 | ERROR | [x] Expected 1 newline at end of file; 0 found
----------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 37 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------
Comments
Comment #2
akshay.kelotra commentedProviding Patch.
Thanks
Comment #3
mauryarahul11Thanks @akshay.kelotra for your patch, i can see you only fixed t() function warnings and after applying your patch i got multiple warnings and error related to code standard. I will going to fix it and create new patch.
Comment #4
mauryarahul11Attaching the patch which fixes all the code standard errors and warning given by phpcs.
Comment #5
lucasscHi!
I applied patch in #4 for drupal 9.4.5 and looks good! Changes in the code makes sense and phpcs returned errors/warning for just 2 js files.
In the 1st case it's about indentation and the other file is minified.
I'm uploading the phpcs output, a new patch to fix the indentation and the interdiff.
Comment #6
WagnerMelo commentedHello, i'll review it. XD
Comment #7
WagnerMelo commentedHello, i reviewed this issue, and all errors related with Drupal Practice, are solved. I tested file per file, and after ran de phpcs code.
So i'll move this issue to RTBC.
Comment #8
sujan shrestha commentedComment #9
sujan shrestha commentedComment #15
sujan shrestha commentedComment #16
avpadernoThe issue summary should always describe what the issue is trying to fix and, in the case, of coding standards issues, report which command has been used, which arguments have been used, and which report that command shown.
Comment #17
avpadernoComment #18
imustakim commentedWorking on this.
Comment #19
imustakim commentedComment #20
imustakim commentedPatch added.
Please review.
Comment #21
avpadernoSee comment #16.
Comment #22
imustakim commentedComment #23
imustakim commentedComment #24
rajneeshb commentedReviewed patch #20 all reported issues fixed. +1RTBC
Attaching screenshot for reference.
Comment #25
sujan shrestha commentedComment #26
sujan shrestha commented