Fix the errors/warnings reported by PHP_CodeSniffer

Created on 17 January 2024, 5 months ago
Updated 5 June 2024, 25 days 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,css,js,info,txt,md,yml modules/contrib/ppss/

Report:

FILE: /home/contribution/drupal/web/modules/contrib/ppss/ppss.module
------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 15 ERRORS AND 1 WARNING AFFECTING 16 LINES
------------------------------------------------------------------------------------------------------------------------------------------------------------
  1 | ERROR   | [x] Missing file doc comment
  4 | WARNING | [ ] Format should be "* Implements hook_foo().", "* Implements hook_foo_BAR_ID_bar() for xyz_bar().",, "* Implements hook_foo_BAR_ID_bar()
    |         |     for xyz-bar.html.twig.", "* Implements hook_foo_BAR_ID_bar() for xyz-bar.tpl.php.", or "* Implements hook_foo_BAR_ID_bar() for block
    |         |     templates."
  7 | ERROR   | [x] Short array syntax must be used to define arrays
 23 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 26 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 34 | ERROR   | [x] Expected 1 space after FOREACH keyword; 0 found
 36 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 40 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 41 | ERROR   | [x] Namespaced classes/interfaces/traits should be referenced with use statements
 44 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 45 | ERROR   | [x] Whitespace found at end of line
 46 | ERROR   | [x] Short array syntax must be used to define arrays
 48 | ERROR   | [x] Expected newline after closing brace
 52 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 54 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 55 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 15 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------------------------------

FILE: /home/contribution/drupal/web/modules/contrib/ppss/ppss.install
-------------------------------------------------------------------------------------------------------------------------------
FOUND 29 ERRORS AND 4 WARNINGS AFFECTING 30 LINES
-------------------------------------------------------------------------------------------------------------------------------
   1 | ERROR   | [x] The PHP open tag must be followed by exactly one blank line
   1 | ERROR   | [x] Missing file doc comment
   2 | WARNING | [x] Unused use statement
   2 | ERROR   | [x] There must be one blank line after the last USE statement; 0 found;
   8 | ERROR   | [x] Missing function doc comment
   9 | ERROR   | [x] Opening brace should be on the same line as the declaration
  12 | WARNING | [ ] Line exceeds 80 characters; contains 82 characters
  13 | WARNING | [ ] Line exceeds 80 characters; contains 81 characters
  14 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
  21 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
  22 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
  27 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
  33 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
  40 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
  47 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
  55 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
  61 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
  67 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
  74 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
  76 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
  81 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
  83 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
  89 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
  95 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
 112 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
 113 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
 118 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
 125 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
 132 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
 139 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
 145 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
 152 | WARNING | [x] A comma should follow the last multiline array item. Found: true
 152 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
-------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 31 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------


FILE: /home/contribution/drupal/web/modules/contrib/ppss/README.md
----------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------
 13 | WARNING | Line exceeds 80 characters; contains 107 characters
----------------------------------------------------------------------------


FILE: /home/contribution/drupal/web/modules/contrib/ppss/ppss.permissions.yml
---------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------
 7 | ERROR | [x] Expected 1 newline at end of file; 0 found
---------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------


FILE: /home/contribution/drupal/web/modules/contrib/ppss/src/PPSSServiceApi.php
------------------------------------------------------------------------------------------------------------------------------
FOUND 32 ERRORS AND 11 WARNINGS AFFECTING 35 LINES
------------------------------------------------------------------------------------------------------------------------------
  5 | WARNING | [x] Unused use statement
  6 | WARNING | [x] Unused use statement
  6 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Config\ConfigFactory.
  8 | WARNING | [x] Unused use statement
 12 | ERROR   | [x] Doc comment short description must be on the first line
 14 | ERROR   | [x] Additional blank lines found at end of doc comment
 16 | ERROR   | [x] Opening brace should be on the same line as the declaration
 25 | ERROR   | [x] Missing function doc comment
 26 | ERROR   | [x] Opening brace should be on the same line as the declaration
 31 | ERROR   | [x] Function comment short description must start with exactly one space
 31 | ERROR   | [x] Doc comment short description must end with a full stop
 32 | ERROR   | [x] Whitespace found at end of line
 33 | ERROR   | [x] Expected 1 space after asterisk; 2 found
 34 | ERROR   | [x] Parameter comment indentation must be 3 spaces, found 2 spaces
 35 | ERROR   | [x] Expected 1 space after asterisk; 2 found
 36 | ERROR   | [x] Parameter comment indentation must be 3 spaces, found 2 spaces
 37 | ERROR   | [x] Expected 1 space after asterisk; 2 found
 38 | ERROR   | [x] Parameter comment indentation must be 3 spaces, found 2 spaces
 40 | ERROR   | [x] Additional blank lines found at end of doc comment
 42 | ERROR   | [x] Opening brace should be on the same line as the declaration
 43 | ERROR   | [x] Expected 1 space after IF keyword; 0 found
 46 | ERROR   | [x] Concat operator must be surrounded by a single space
 46 | ERROR   | [x] Concat operator must be surrounded by a single space
 46 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 47 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 48 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
 49 | ERROR   | [x] Expected 1 space after SWITCH keyword; 0 found
 53 | ERROR   | [x] Case breaking statements must be followed by a single blank line
 58 | ERROR   | [x] Case breaking statements must be followed by a single blank line
 60 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 62 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 64 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 64 | ERROR   | [x] Short array syntax must be used to define arrays
 65 | ERROR   | [x] Expected newline after closing brace
 66 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 66 | ERROR   | [x] Short array syntax must be used to define arrays
 72 | ERROR   | [x] Doc comment short description must end with a full stop
 74 | ERROR   | [x] Expected "int" but found "integer" for parameter type
 80 | ERROR   | [x] No space found before comment text; expected "// get all user ads" but found "//get all user ads"
 80 | ERROR   | [x] Inline comments must start with a capital letter
 80 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 81 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 82 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 35 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------


FILE: /home/contribution/drupal/web/modules/contrib/ppss/src/Form/PPSSFormSettings.php
------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 29 ERRORS AND 4 WARNINGS AFFECTING 30 LINES
------------------------------------------------------------------------------------------------------------------------------------------------------------
   3 | ERROR   | [x] Namespaced classes, interfaces and traits should not begin with a file doc comment
  12 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\EntityTypeManagerInterface.
  15 | WARNING | [x] Unused use statement
  16 | WARNING | [x] Unused use statement
  16 | ERROR   | [x] There must be one blank line after the last USE statement; 2 found;
  19 | ERROR   | [x] Missing class doc comment
  20 | ERROR   | [x] Opening brace should be on the same line as the declaration
  44 | ERROR   | [x] Opening brace should be on the same line as the declaration
  53 | ERROR   | [x] Opening brace should be on the same line as the declaration
  59 | ERROR   | [x] Whitespace found at end of line
  64 | ERROR   | [x] Opening brace should be on the same line as the declaration
  73 | ERROR   | [x] Opening brace should be on the same line as the declaration
  83 | ERROR   | [x] Opening brace should be on the same line as the declaration
  98 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
 109 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
 111 | ERROR   | [x] Whitespace found at end of line
 124 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
 134 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
 141 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 145 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
 161 | WARNING | [ ] Line exceeds 80 characters; contains 82 characters
 161 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 165 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
 188 | ERROR   | [x] Expected 1 blank line after function; 0 found
 194 | ERROR   | [x] No space found before comment text; expected "// dump(($form_state->getValue('success_url')))" but found
     |         |     "//dump(($form_state->getValue('success_url')))"
 211 | ERROR   | [x] Opening brace should be on the same line as the declaration
 213 | ERROR   | [x] Expected one space after the comma, 0 found
 213 | ERROR   | [x] Expected one space after the comma, 0 found
 214 | WARNING | [x] A comma should follow the last multiline array item. Found: 'mail_scheduled_cancellation_body'
 224 | ERROR   | [x] Expected newline after closing brace
 228 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 4
 240 | ERROR   | [x] Opening brace should be on the same line as the declaration
 247 | ERROR   | [x] Expected 1 blank line after function; 0 found
------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 32 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------------------------------

📌 Task
Status

RTBC

Version

1.0

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