Drupal Coding Standards Issues | phpcs

Created on 9 February 2023, almost 2 years ago
Updated 29 March 2024, 8 months ago

Problem/Motivation

Getting following error/warnings.

FILE: /var/www/html/modules/contrib/feed_block/README.md
----------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
----------------------------------------------------------------------
4 | WARNING | Line exceeds 80 characters; contains 343 characters
36 | WARNING | Line exceeds 80 characters; contains 83 characters
39 | WARNING | Line exceeds 80 characters; contains 82 characters
----------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/feed_block/src/Plugin/Field/FieldWidget/RSSFeedWidget.php
--------------------------------------------------------------------------------------------------
FOUND 8 ERRORS AND 1 WARNING AFFECTING 9 LINES
--------------------------------------------------------------------------------------------------
75 | ERROR | [x] Use null coalesce operator instead of ternary operator.
84 | ERROR | [x] Use null coalesce operator instead of ternary operator.
89 | ERROR | [x] Use null coalesce operator instead of ternary operator.
95 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
121 | ERROR | [x] Use null coalesce operator instead of ternary operator.
127 | ERROR | [x] Use null coalesce operator instead of ternary operator.
150 | ERROR | [x] Use null coalesce operator instead of ternary operator.
167 | ERROR | [x] Use null coalesce operator instead of ternary operator.
173 | ERROR | [x] Use null coalesce operator instead of ternary operator.
--------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/feed_block/src/Plugin/Field/FieldFormatter/RSSFeedFormatter.php
---------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
---------------------------------------------------------------------------------------------------
65 | ERROR | [x] Short array syntax must be used to define arrays
85 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
---------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/feed_block/src/EventSubscriber/FeedBlockCacheExpire.php
------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------
20 | WARNING | The class short comment should describe what the class does and not simply repeat the class name
124 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
------------------------------------------------------------------------------------------------------------------

Time: 1.97 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/feed_block/

Proposed resolution

Above error/warnings need to be fixed.

📌 Task
Status

Fixed

Version

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024