Coding Standard

Created on 4 March 2024, 10 months ago
Updated 12 March 2024, 10 months ago

Problem/Motivation

In the file pagerange404/modules/pagerangeforums404/src/Controller/PageRangeForums404Controller.php, there is a direct call to the service of the Request stack and other services. Instead of this, we should utilize dependency injection.
run command:
vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions='php,module,inc,yml,install,test,profile,theme,info,txt,md,twig' /pagerange404

Steps to reproduce


FILE: ...upal-10/web/modules/contrib/pagerange404/src/EventSubscriber/PageRange404Subscriber.php
---------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 2 WARNINGS AFFECTING 5 LINES
---------------------------------------------------------------------------------------------
 13 | ERROR   | [ ] Doc comment short description must be on a single line, further text
    |         |     should be a separate paragraph
 19 | ERROR   | [ ] Missing short description in doc comment
 43 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection
    |         |     instead
 53 | ERROR   | [x] Namespaced classes/interfaces/traits should be referenced with use
    |         |     statements
 84 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
---------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------


FILE: ...pagerange404/modules/pagerangeforums404/src/Controller/PageRangeForums404Controller.php
---------------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
---------------------------------------------------------------------------------------------
 15 | ERROR | [x] There must be no blank lines after the function comment
 20 | ERROR | [x] Equals sign not aligned with surrounding assignments; expected 5 spaces
    |       |     but found 4 spaces
 21 | ERROR | [x] Equals sign not aligned with surrounding assignments; expected 4 spaces
    |       |     but found 3 spaces
 50 | ERROR | [x] Expected 1 blank line after function; 0 found
 51 | ERROR | [x] The closing brace for the class must have an empty line before it
---------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------


FILE: ...04/modules/pagerangeforums404/src/EventSubscriber/PageRangeForums404RouteSubscriber.php
---------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 4 WARNINGS AFFECTING 6 LINES
---------------------------------------------------------------------------------------------
  5 | WARNING | [x] Unused use statement
  6 | WARNING | [x] Unused use statement
  7 | WARNING | [x] Unused use statement
  9 | WARNING | [x] Unused use statement
 24 | ERROR   | [x] Expected 1 blank line after function; 0 found
 25 | ERROR   | [x] The closing brace for the class must have an empty line before it
---------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------


FILE: ...web/modules/contrib/pagerange404/modules/pagerangeforums404/pagerangeforums404.info.yml
---------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------
 6 | WARNING | All dependencies must be prefixed with the project name, for example
   |         | "drupal:"
---------------------------------------------------------------------------------------------


FILE: /var/www/html/Drupal-10/web/modules/contrib/pagerange404/README.md
------------------------------------------------------------------------
FOUND 1 ERROR AND 6 WARNINGS AFFECTING 7 LINES
------------------------------------------------------------------------
  3 | WARNING | [ ] Line exceeds 80 characters; contains 402 characters
  5 | WARNING | [ ] Line exceeds 80 characters; contains 314 characters
  9 | WARNING | [ ] Line exceeds 80 characters; contains 196 characters
 11 | WARNING | [ ] Line exceeds 80 characters; contains 117 characters
 14 | WARNING | [ ] Line exceeds 80 characters; contains 196 characters
 16 | WARNING | [ ] Line exceeds 80 characters; contains 117 characters
 22 | ERROR   | [x] Expected 1 newline at end of file; 2 found
------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇮🇳India govind_giri_goswami

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024