Drupal Coding Standards Issues | phpcs

Created on 25 January 2023, almost 2 years ago
Updated 4 March 2024, 10 months ago

Problem/Motivation

Getting following error/warnings

FILE: /var/www/html/modules/contrib/notificationswidget/notifications_widget.install
------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
------------------------------------------------------------------------------------
161 | ERROR | [x] Whitespace found at end of line
310 | ERROR | [x] Whitespace found at end of line
319 | ERROR | [x] Expected 1 newline at end of file; 0 found
------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/notificationswidget/notifications_widget.module
-------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------------
281 | WARNING | Avoid backslash escaping in translatable strings when possible, use "" quotes instead
282 | WARNING | Avoid backslash escaping in translatable strings when possible, use "" quotes instead
-------------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/notificationswidget/README.md
----------------------------------------------------------------------
FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
----------------------------------------------------------------------
74 | WARNING | Line exceeds 80 characters; contains 81 characters
96 | WARNING | Line exceeds 80 characters; contains 114 characters
99 | WARNING | Line exceeds 80 characters; contains 116 characters
102 | WARNING | Line exceeds 80 characters; contains 145 characters
----------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/notificationswidget/src/Form/NotificationsWidgetSettingsForm.php
----------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 3 WARNINGS AFFECTING 4 LINES
----------------------------------------------------------------------------------------------------
275 | WARNING | [ ] #options values usually have to run through t() for translation
276 | WARNING | [ ] #options values usually have to run through t() for translation
277 | WARNING | [ ] #options values usually have to run through t() for translation
343 | ERROR | [x] Object operator not indented correctly; expected 15 spaces but found 14
----------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/notificationswidget/src/Plugin/Block/NotificationsWidgetBlock.php
-----------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
-----------------------------------------------------------------------------------------------------
84 | ERROR | [x] Use null coalesce operator instead of ternary operator.
90 | ERROR | [x] Use null coalesce operator instead of ternary operator.
134 | ERROR | [x] Use null coalesce operator instead of ternary operator.
179 | ERROR | [x] Use null coalesce operator instead of ternary operator.
180 | ERROR | [x] Use null coalesce operator instead of ternary operator.
-----------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/notificationswidget/src/Services/NotificationsWidgetServiceInterface.php
------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 2 WARNINGS AFFECTING 4 LINES
------------------------------------------------------------------------------------------------------------
21 | ERROR | [x] Parameter comment must end with a full stop
24 | ERROR | [x] Parameter comment must end with a full stop
29 | WARNING | [ ] Line exceeds 80 characters; contains 114 characters
32 | WARNING | [ ] Line exceeds 80 characters; contains 116 characters
------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------

Time: 1.61 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/notificationswidget/

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