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
----------------------------------------------------------------------------------------------------------------------------------------------
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

akshay.kelotra created an issue. See original summary.

akshay.kelotra’s picture

Assigned: akshay.kelotra » Unassigned
Issue tags: +phpcs, +Novice
StatusFileSize
new1.61 KB

Providing Patch.
Thanks

mauryarahul11’s picture

Assigned: Unassigned » mauryarahul11
Status: Needs review » Needs work

Thanks @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.

mauryarahul11’s picture

Assigned: mauryarahul11 » Unassigned
Status: Needs work » Needs review
StatusFileSize
new12.18 KB

Attaching the patch which fixes all the code standard errors and warning given by phpcs.

lucassc’s picture

StatusFileSize
new3.5 KB
new14.67 KB
new2.45 KB

Hi!

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.

WagnerMelo’s picture

Assigned: Unassigned » WagnerMelo

Hello, i'll review it. XD

WagnerMelo’s picture

Assigned: WagnerMelo » Unassigned
Status: Needs review » Reviewed & tested by the community

Hello, 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.

sujan shrestha’s picture

sujan shrestha’s picture

sujan shrestha’s picture

avpaderno’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: -, -Novice +Coding standards, +Needs issue summary update

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

avpaderno’s picture

Title: phpcs --standard=DrupalPractice » Fix the issues reported by phpcs
imustakim’s picture

Assigned: Unassigned » imustakim

Working on this.

imustakim’s picture

Issue summary: View changes
imustakim’s picture

Assigned: imustakim » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs issue summary update
StatusFileSize
new12.22 KB

Patch added.
Please review.

avpaderno’s picture

Status: Needs review » Needs work

See comment #16.

imustakim’s picture

Issue summary: View changes
imustakim’s picture

Status: Needs work » Needs review
rajneeshb’s picture

StatusFileSize
new526.14 KB
new681.35 KB

Reviewed patch #20 all reported issues fixed. +1RTBC
Attaching screenshot for reference.

sujan shrestha’s picture

Version: 1.0.0 » 1.1.0
Assigned: Unassigned » sujan shrestha
Status: Needs review » Fixed
sujan shrestha’s picture

Status: Fixed » Closed (fixed)