Fix the issues reported by phpcs

Created on 10 July 2023, 12 months ago
Updated 16 March 2024, 3 months ago

Problem/Motivation

PHPCS reports the following errors:

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

FILE: C:\xampp\htdocs\backendassignment\web\modules\custom\time_ticker\src\Controller\TimeController.php
--------------------------------------------------------------------------------------------------------
FOUND 38 ERRORS AFFECTING 22 LINES
--------------------------------------------------------------------------------------------------------
  1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
  8 | ERROR | [x] There must be one blank line after the last USE statement; 2 found;
 11 | ERROR | [x] Missing class doc comment
 11 | ERROR | [x] Expected 1 space before opening brace; found 0
 13 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 13 | ERROR | [ ] Missing member variable doc comment
 15 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
 15 | ERROR | [ ] Missing short description in doc comment
 16 | ERROR | [x] Expected 7 space(s) before asterisk; 3 found
 16 | ERROR | [ ] Missing parameter comment
 16 | ERROR | [ ] Doc comment for parameter $configuration does not match actual variable name $time
 17 | ERROR | [x] Expected 7 space(s) before asterisk; 3 found
 17 | ERROR | [ ] Missing parameter comment
 17 | ERROR | [ ] Doc comment for parameter $plugin_id does not match actual variable name $time
 18 | ERROR | [x] Expected 7 space(s) before asterisk; 3 found
 18 | ERROR | [ ] Missing parameter comment
 18 | ERROR | [ ] Superfluous parameter comment
 19 | ERROR | [x] Expected 7 space(s) before asterisk; 3 found
 19 | ERROR | [ ] Missing parameter comment
 19 | ERROR | [ ] Superfluous parameter comment
 20 | ERROR | [x] Expected 7 space(s) before asterisk; 3 found
 20 | ERROR | [ ] Superfluous parameter comment
 21 | ERROR | [x] Expected 7 space(s) before asterisk; 3 found
 21 | ERROR | [x] Parameter comment indentation must be 3 spaces, found 2 spaces
 22 | ERROR | [x] Expected 7 space(s) before asterisk; 3 found
 22 | ERROR | [x] There must be no blank lines after the function comment
 26 | ERROR | [x] Expected 1 blank line after function; 0 found
 27 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 3
 28 | ERROR | [x] Expected 4 space(s) before asterisk; 3 found
 29 | ERROR | [x] Expected 4 space(s) before asterisk; 3 found
 31 | ERROR | [x] Whitespace found at end of line
 36 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 36 | ERROR | [x] Missing function doc comment
 36 | ERROR | [x] Expected 1 space before opening brace; found 0
 37 | ERROR | [x] Whitespace found at end of line
 38 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
 39 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 41 | ERROR | [x] Expected 1 newline at end of file; 0 found
--------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 27 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\custom\time_ticker\src\Form\TimeSettingsForm.php
-----------------------------------------------------------------------------------------------------
FOUND 12 ERRORS AFFECTING 11 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
  5 | ERROR | [x] Doc comment short description must end with a full stop
 13 | ERROR | [x] Missing class doc comment
 65 | ERROR | [x] Whitespace found at end of line
 66 | ERROR | [x] Whitespace found at end of line
 68 | ERROR | [x] Whitespace found at end of line
 68 | ERROR | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
 69 | ERROR | [x] Whitespace found at end of line
 80 | ERROR | [x] Whitespace found at end of line
 88 | ERROR | [x] Expected 1 blank line after function; 0 found
 89 | 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: C:\xampp\htdocs\backendassignment\web\modules\custom\time_ticker\src\Plugin\Block\TimeBlock.php
-------------------------------------------------------------------------------------------------------------
FOUND 27 ERRORS AFFECTING 25 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
  5 | ERROR | [x] Doc comment short description must end with a full stop
 25 | ERROR | [x] Expected 1 space before opening brace; found 0
 27 | ERROR | [ ] Missing short description in doc comment
 28 | ERROR | [x] Data types in @var tags need to be fully namespaced
 28 | ERROR | [x] Do not append variable name "$time" to the type declaration in a member variable comment
 32 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 33 | ERROR | [x] Expected 5 space(s) before asterisk; 3 found
 34 | ERROR | [x] Expected 5 space(s) before asterisk; 3 found
 35 | ERROR | [x] Expected 5 space(s) before asterisk; 3 found
 36 | ERROR | [x] Expected 5 space(s) before asterisk; 3 found
 47 | ERROR | [ ] Missing short description in doc comment
 47 | ERROR | [ ] Parameter $config_factory is not described in comment
 48 | ERROR | [ ] Missing parameter comment
 49 | ERROR | [ ] Missing parameter comment
 50 | ERROR | [ ] Missing parameter comment
 51 | ERROR | [ ] Missing parameter comment
 53 | ERROR | [x] Parameter comment indentation must be 3 spaces, found 2 spaces
 54 | ERROR | [x] There must be no blank lines after the function comment
 81 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 0
 83 | ERROR | [x] Equals sign not aligned with surrounding assignments; expected 4 spaces but found 3 spaces
 84 | ERROR | [x] Equals sign not aligned with surrounding assignments; expected 3 spaces but found 2 spaces
 85 | ERROR | [x] Equals sign not aligned with surrounding assignments; expected 6 spaces but found 5 spaces
 86 | ERROR | [x] Equals sign not aligned with surrounding assignments; expected 1 space but found 5 spaces
 97 | ERROR | [x] Whitespace found at end of line
 99 | ERROR | [x] Whitespace found at end of line
-------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 20 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\custom\time_ticker\src\TimeService.php
---------------------------------------------------------------------------------------------------------------
FOUND 27 ERRORS AFFECTING 23 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
 13 | ERROR | [x] Missing class doc comment
 15 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 16 | ERROR | [x] Expected 5 space(s) before asterisk; 3 found
 17 | ERROR | [x] Expected 5 space(s) before asterisk; 3 found
 18 | ERROR | [x] Expected 5 space(s) before asterisk; 3 found
 19 | ERROR | [x] Expected 5 space(s) before asterisk; 3 found
 22 | ERROR | [ ] Missing short description in doc comment
 22 | ERROR | [ ] Parameter $config_factory is not described in comment
 23 | ERROR | [ ] Missing parameter comment
 23 | ERROR | [ ] Doc comment for parameter $configuration does not match actual variable name $config_factory
 24 | ERROR | [ ] Missing parameter comment
 24 | ERROR | [ ] Doc comment for parameter $plugin_id does not match actual variable name $config_factory
 25 | ERROR | [ ] Missing parameter comment
 25 | ERROR | [ ] Superfluous parameter comment
 26 | ERROR | [x] There must be no blank lines after the function comment
 35 | ERROR | [x] Additional blank lines found at end of doc comment
 36 | ERROR | [x] Whitespace found at end of line
 37 | ERROR | [x] Whitespace found at end of line
 40 | ERROR | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
 41 | ERROR | [x] Whitespace found at end of line
 42 | ERROR | [x] Expected one space after the comma, 0 found
 55 | ERROR | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
 56 | ERROR | [x] Whitespace found at end of line
 57 | ERROR | [x] Whitespace found at end of line
 60 | ERROR | [x] Whitespace found at end of line
---------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 19 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\custom\time_ticker\templates\time-ticker-block.html.twig
------------------------------------------------------------------------------------------------------------
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: C:\xampp\htdocs\backendassignment\web\modules\custom\time_ticker\time_ticker.info.yml
-------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------
 10 | 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\custom\time_ticker\time_ticker.libraries.yml
------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------
 9 | 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\custom\time_ticker\time_ticker.module
-----------------------------------------------------------------------------------------
FOUND 8 ERRORS 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"
  7 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
  9 | ERROR | [x] Expected one space after the comma, 0 found
  9 | ERROR | [x] Expected one space after the comma, 0 found
 12 | ERROR | [x] Expected 1 newline at end of file; 0 found
 12 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 2
 12 | ERROR | [x] Closing brace indented incorrectly; expected 0 spaces, found 2
-----------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------


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

Time: 1.12 secs; Memory: 6MB

Steps to reproduce

Run the phpcs command on the module.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

šŸ“Œ Task
Status

RTBC

Version

9.1

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

  • Issue created by @sidharth_soman
  • Merge request !1Fixed phpcs issues. ā†’ (Open) created by sidharth_soman
  • Issue was unassigned.
  • Status changed to Needs review 12 months ago
  • šŸ‡®šŸ‡³India sidharth_soman Bangalore

    All issues fixed. Please review the MR. I've raised it against the main branch.

  • šŸ‡®šŸ‡³India Preethy_ray

    Hi,
    Apllied the MR!1 found few errors that need to be addressed.
    Thank You!!

  • šŸ‡®šŸ‡³India Yashaswi18

    Hello, I applied MR!1, and ran the command

    phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig time_ticker

    Found no errors or warnings remaining.

  • Status changed to RTBC 3 months ago
  • šŸ‡µšŸ‡­Philippines clarkssquared

    Hi

    I also applied MR !1 and I confirmed that it resolves the PHPCS issues reported, the PHPCS issues that my terminal flags happens when a module is installed via composer.

    āžœ  time_ticker git:(master) āœ— curl https://git.drupalcode.org/project/time_ticker/-/merge_requests/1.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 10706    0 10706    0     0  20692      0 --:--:-- --:--:-- --:--:-- 20992
    patching file 'src/Controller/TimeController.php'
    patching file 'src/Form/TimeSettingsForm.php'
    patching file 'src/Plugin/Block/TimeBlock.php'
    patching file 'src/TimeService.php'
    patching file 'templates/time-ticker-block.html.twig'
    patching file time_ticker.info.yml
    1 out of 1 hunks failed--saving rejects to time_ticker.info.yml.rej
    patching file time_ticker.libraries.yml
    patching file time_ticker.module
    patching file time_ticker.services.yml
    āžœ  time_ticker git:(master) āœ— ..
    āžœ  contrib git:(master) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml time_ticker 
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/time_ticker/time_ticker.info.yml
    -------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------
     1 | WARNING | Remove "project" from the info file, it will be added by drupal.org packaging automatically
     1 | WARNING | Remove "datestamp" from the info file, it will be added by drupal.org packaging automatically
     1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
    -------------------------------------------------------------------------------------------------------------
    
    Time: 248ms; Memory: 10MB
    
    āžœ  contrib git:(master) āœ— 
    
    
Production build 0.69.0 2024