Fix the errors/warnings reported by Php_CodeSniffer

Created on 5 July 2023, 12 months ago
Updated 1 March 2024, 4 months ago

Problem/Motivation

Phpcs gives the following errors upon being run on the module:

C:\xampp\htdocs\backendassignment\web\modules\contrib>phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig pirate

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\pirate\INSTALL.txt
------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------
 4 | WARNING | Line exceeds 80 characters; contains 90 characters
------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\pirate\pirate.module
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AND 1 WARNING AFFECTING 4 LINES
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  1 | ERROR   | [x] Missing file doc comment
  1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
  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."
  9 | ERROR   | [x] Short array syntax must be used to define arrays
 10 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 10 | ERROR   | [x] Closing brace indented incorrectly; expected 2 spaces, found 4
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\pirate\pirate.services.yml
--------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------
 3 | ERROR | [x] Expected 1 newline at end of file; 0 found
--------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\pirate\src\Hook\Captain.php
------------------------------------------------------------------------------------------------------
FOUND 9 ERRORS AFFECTING 8 LINES
------------------------------------------------------------------------------------------------------
   1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
   3 | ERROR | [x] Namespaced classes, interfaces and traits should not begin with a file doc comment
  14 | ERROR | [x] Missing function doc comment
  14 | ERROR | [x] Expected 1 blank line before function; 0 found
  15 | ERROR | [x] Short array syntax must be used to define arrays
  31 | ERROR | [x] Expected 1 space after "=>"; 2 found
  52 | ERROR | [x] Expected 1 space after "=>"; 2 found
 113 | ERROR | [x] Expected 1 blank line after function; 0 found
 114 | ERROR | [x] The closing brace for the class must have an empty line before it
------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 9 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\pirate\src\Plugin\Filter\Pirate.php
-------------------------------------------------------------------------------------------------------------------------------
FOUND 11 ERRORS AND 2 WARNINGS AFFECTING 12 LINES
-------------------------------------------------------------------------------------------------------------------------------
   1 | ERROR   | [x] The PHP open tag must be followed by exactly one blank line
   1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
   2 | ERROR   | [x] Namespaced classes, interfaces and traits should not begin with a file doc comment
  12 | WARNING | [x] Unused use statement
  13 | WARNING | [x] Unused use statement
  16 | ERROR   | [x] Doc comment short description must end with a full stop
  34 | ERROR   | [x] Expected 1 blank line before function; 0 found
  35 | ERROR   | [x] Short array syntax must be used to define arrays
  38 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
  56 | ERROR   | [x] Short array syntax must be used to define arrays
  71 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 107 | ERROR   | [x] Expected 1 blank line after function; 0 found
 108 | ERROR   | [x] The closing brace for the class must have an empty line before it
-------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 13 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------

Time: 5.95 secs; Memory: 6MB

Steps to reproduce

Run the phpcs command on the module.

Proposed resolution

Fix all errors and provide an MR.

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ“Œ Task
Status

RTBC

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia sidharth_soman Bangalore

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