Fix the errors/warnings reported by PHP_CodeSniffer

Created on 12 January 2024, 5 months ago
Updated 24 January 2024, 5 months ago

Problem/Motivation

When running the module code against Drupal coding standards based on Drupal standard, the module shows errors

Steps to reproduce

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

Report :

FILE: /home/contribution/drupal/web/modules/contrib/notification_popin/src/NotificationListBuilder.php
--------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------
 1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
--------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------


FILE: /home/contribution/drupal/web/modules/contrib/notification_popin/src/Entity/Notification.php
-----------------------------------------------------------------------------------------------------------
FOUND 7 ERRORS AFFECTING 5 LINES
-----------------------------------------------------------------------------------------------------------
   1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
 154 | ERROR | [x] Whitespace found at end of line
 154 | ERROR | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
 159 | ERROR | [x] Expected 1 blank line after function; 3 found
 162 | ERROR | [ ] More than 2 empty lines are not allowed
 163 | ERROR | [ ] Private method name "Notification::_customFieldDefinitions" is not in lowerCamel format
 163 | ERROR | [x] Missing function doc comment
-----------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------


FILE: /home/contribution/drupal/web/modules/contrib/notification_popin/src/NotificationManager.php
----------------------------------------------------------------------------------------------------
FOUND 65 ERRORS AND 4 WARNINGS AFFECTING 54 LINES
----------------------------------------------------------------------------------------------------
  5 | ERROR   | [x] When importing a class with "use", do not include a leading \
  6 | ERROR   | [x] When importing a class with "use", do not include a leading \
  7 | ERROR   | [x] There must be one blank line after the last USE statement; 2 found;
  7 | ERROR   | [x] When importing a class with "use", do not include a leading \
 10 | ERROR   | [x] Missing class doc comment
 12 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 12 | ERROR   | [x] Missing function doc comment
 13 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 14 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 15 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 15 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 17 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 17 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 18 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 20 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 21 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 22 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 23 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 25 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 26 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 27 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 28 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 30 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 31 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 32 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 32 | ERROR   | [x] Expected 1 space after FOREACH keyword; 0 found
 33 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 34 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 35 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 37 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 38 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 39 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 39 | ERROR   | [x] Expected 1 space after IF keyword; 0 found
 40 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 40 | WARNING | [ ] Node::load calls should be avoided in classes, use dependency injection instead
 41 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 41 | ERROR   | [x] Expected 1 space after IF keyword; 0 found
 42 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 16
 43 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 44 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 45 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 47 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 48 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 48 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 50 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 52 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 53 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 53 | ERROR   | [x] Expected 1 blank line after function; 2 found
 56 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 56 | ERROR   | [x] Missing function doc comment
 57 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 58 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 58 | ERROR   | [x] Expected 1 space after IF keyword; 0 found
 59 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 59 | ERROR   | [x] Expected 1 space after FOREACH keyword; 0 found
 60 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 16
 61 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 16
 61 | ERROR   | [x] Expected 1 space after IF keyword; 0 found
 62 | ERROR   | [x] Line indented incorrectly; expected 10 spaces, found 20
 63 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 16
 64 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 16
 64 | ERROR   | [x] Expected 1 space after IF keyword; 0 found
 65 | ERROR   | [x] Line indented incorrectly; expected 10 spaces, found 20
 66 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 16
 67 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 68 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 69 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 70 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 72 | ERROR   | [x] Expected 1 newline at end of file; 0 found
----------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 65 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------


FILE: /home/contribution/drupal/web/modules/contrib/notification_popin/src/NotificationInterface.php
------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------
 1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------


FILE: /home/contribution/drupal/web/modules/contrib/notification_popin/src/Controller/NotificationController.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 14 ERRORS AND 2 WARNINGS AFFECTING 15 LINES
------------------------------------------------------------------------------------------------------------------------------------------
  5 | ERROR   | [x] When importing a class with "use", do not include a leading \
  7 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\notification_popin\NotificationManager.
  7 | ERROR   | [x] When importing a class with "use", do not include a leading \
  8 | ERROR   | [x] When importing a class with "use", do not include a leading \
 33 | ERROR   | [ ] Missing parameter comment
 34 | ERROR   | [ ] Missing parameter comment
 54 | ERROR   | [x] Additional blank lines found at end of doc comment
 56 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 61 | ERROR   | [x] Expected 1 space after IF keyword; 0 found
 62 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 63 | ERROR   | [x] Expected 1 space after FOREACH keyword; 0 found
 66 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
 67 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
 68 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
 73 | ERROR   | [x] Expected 1 blank line after function; 2 found
 76 | ERROR   | [x] The closing brace for the class must have an empty line before it
------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 12 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------------


FILE: /home/contribution/drupal/web/modules/contrib/notification_popin/src/Form/NotificationForm.php
------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------
 1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------


FILE: /home/contribution/drupal/web/modules/contrib/notification_popin/src/Form/NotificationSettingsForm.php
--------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------
 1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
--------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------
📌 Task
Status

RTBC

Version

1.2

Component

Code

Created by

🇮🇳India realsp

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.69.0 2024