Drupal Coding Standards Issues | phpcs

Created on 2 February 2023, over 1 year ago

Problem/Motivation

Getting following error/warnings.

FILE: /var/www/html/modules/contrib/token_formatters/README.md
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
1 | ERROR | [x] Expected 1 newline at end of file; 0 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/token_formatters/src/Plugin/Field/FieldFormatter/TokenizedFieldFormatter.php
---------------------------------------------------------------------------------------------------------------------------------------------
FOUND 16 ERRORS AND 7 WARNINGS AFFECTING 10 LINES
---------------------------------------------------------------------------------------------------------------------------------------------
5 | WARNING | [x] Unused use statement
6 | WARNING | [x] Unused use statement
23 | ERROR | [x] Expected 1 space before opening brace; found 0
30 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
30 | ERROR | [x] Line indented incorrectly; expected at least 4 spaces, found 1
30 | ERROR | [x] Expected 1 space before "=>"; 0 found
30 | ERROR | [x] Expected 1 space after "=>"; 0 found
30 | WARNING | [x] A comma should follow the last multiline array item. Found: ""
39 | ERROR | [x] Expected 1 space before "=>"; 0 found
39 | ERROR | [x] Expected 1 space after "=>"; 0 found
40 | ERROR | [x] Expected 1 space before "=>"; 0 found
40 | ERROR | [x] Expected 1 space after "=>"; 0 found
40 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
41 | ERROR | [x] Expected 1 space before "=>"; 0 found
41 | ERROR | [x] Expected 1 space after "=>"; 0 found
41 | WARNING | [x] A comma should follow the last multiline array item. Found: )
43 | ERROR | [x] Expected 1 space after IF keyword; 0 found
43 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
69 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
71 | ERROR | [x] Expected 1 space between "'#markup'" and double arrow; 0 found
71 | ERROR | [x] Expected 1 space between double arrow and "$token_service"; 0 found
71 | ERROR | [x] Expected 1 space before "=>"; 0 found
71 | ERROR | [x] Expected 1 space after "=>"; 0 found
---------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 20 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------

Time: 1.09 secs; Memory: 6MB

Steps to reproduce

Run following command

phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml modules/contrib/token_formatters/

Proposed resolution

Above error/warnings need to be fixed.

📌 Task
Status

Fixed

Version

1.0

Component

Code

Created by

🇮🇳India samit.310@gmail.com

Live updates comments and jobs are added and updated live.
  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024