Fixing the issues reported by phpcs

Created on 4 July 2023, over 1 year ago
Updated 30 August 2024, 4 months ago

Problem/Motivation

I ran phpcs command on this module, and I am finding the following errors:

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 toc_js

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\toc_js\css\toc.css
----------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
----------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\toc_js\modules\toc_js_per_node\toc_js_per_node.module
-----------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
-----------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\toc_js\README.txt
-----------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
-----------------------------------------------------------------------------
  94 | WARNING | Line exceeds 80 characters; contains 122 characters
 103 | WARNING | Line exceeds 80 characters; contains 105 characters
-----------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\toc_js\src\Plugin\Block\TocJsBlock.php
-------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 2 WARNINGS AFFECTING 4 LINES
-------------------------------------------------------------------------------------------------------------------------------
   1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
 222 | WARNING | [ ] Avoid backslash escaping in translatable strings when possible, use "" quotes instead
 277 | ERROR   | [x] Inline comments must start with a capital letter
 277 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 282 | WARNING | [ ] Line exceeds 80 characters; contains 103 characters
-------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\toc_js\toc_js.install
--------------------------------------------------------------------------------------------------------------------------------------------
FOUND 4 ERRORS AND 1 WARNING AFFECTING 3 LINES
--------------------------------------------------------------------------------------------------------------------------------------------
  1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
 17 | WARNING | [x] '@todo: simplified when 
            
              #3093289: Update to use latest version of TOC.js library. ā†’
             lands to keep dist folder only.' should match the format '@todo Fix problem X here.'
 42 | ERROR   | [x] There should be no white space after an opening "{"
 42 | ERROR   | [x] There should be no white space before a closing "}"
 42 | ERROR   | [x] Closing brace must be on a line by itself
--------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\toc_js\toc_js.module
---------------------------------------------------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AND 7 WARNINGS AFFECTING 12 LINES
---------------------------------------------------------------------------------------------------------------------------------------------
   1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
  61 | ERROR   | [ ] Type hint "array" missing for $variables
 109 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 124 | ERROR   | [x] Inline comments must start with a capital letter
 124 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 129 | WARNING | [ ] Line exceeds 80 characters; contains 103 characters
 377 | WARNING | [ ] Avoid backslash escaping in translatable strings when possible, use "" quotes instead
 432 | ERROR   | [x] There must be exactly one blank line before the tags in a doc comment
 434 | WARNING | [x] '@todo: simplified when 
            
              #3093289: Update to use latest version of TOC.js library. ā†’
             lands to keep dist folder only.' should match the format '@todo Fix problem X here.'
 444 | WARNING | [x] A comma should follow the last multiline array item. Found: TRUE
 445 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
 452 | WARNING | [x] A comma should follow the last multiline array item. Found: TRUE
 453 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
---------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 10 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------

Time: 8.94 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

Fixed

Version

3.0

Component

Code

Created by

šŸ‡®šŸ‡³India sidharth_soman Bangalore

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

Merge Requests

Comments & Activities

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

    I have fixed all the phpcs issues except those related to line exceeding character limit. It has been left as such for readability purposes.

    Please review the above MR.

  • Status changed to Needs work about 1 year ago
  • šŸ‡µšŸ‡­Philippines clarkssquared

    Hi sidharth_soman,

    I applied your MR !7 and I noticed that there are still remaining PHPCS issues being flagged. For your reference, below is the PHPCS issues after the MR applied.

     toc_js git:(2.0.x) curl https://git.drupalcode.org/project/toc_js/-/merge_requests/7.diff | git apply -v
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  4858    0  4858    0     0   8226      0 --:--:-- --:--:-- --:--:--  8361
    Checking patch src/Plugin/Block/TocJsBlock.php...
    Checking patch toc_js.install...
    Checking patch toc_js.module...
    Applied patch src/Plugin/Block/TocJsBlock.php cleanly.
    Applied patch toc_js.install cleanly.
    Applied patch toc_js.module cleanly.
    āžœ  toc_js git:(2.0.x) āœ— ..
    āžœ  contrib git:(master) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml toc_js
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/toc_js/toc_js.module
    ---------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------
     129 | WARNING | Line exceeds 80 characters; contains 103 characters
    ---------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/toc_js/README.txt
    ------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    ------------------------------------------------------------------------------------------
      94 | WARNING | Line exceeds 80 characters; contains 122 characters
     103 | WARNING | Line exceeds 80 characters; contains 105 characters
    ------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/toc_js/modules/toc_js_per_node/toc_js_per_node.module
    ------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------------
     10 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Form\FormStateInterface.
    ------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/toc_js/src/Plugin/Block/TocJsBlock.php
    ---------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------
     282 | WARNING | Line exceeds 80 characters; contains 103 characters
    ---------------------------------------------------------------------------------------------------------------
    
    Time: 266ms; Memory: 12MB
    
  • Assigned to nitin_lama
  • šŸ‡®šŸ‡³India nitin_lama India

    Please review.

  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • šŸ‡®šŸ‡³India pray_12

    hi,
    Reviewed the MR!7. Still found few phpcbf issue.

    FILE: /toc_js/toc_js.module
    ------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------
     9 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is
       |       |     Drupal\Core\Entity\EntityInterface.
    ------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /toc_js/modules/toc_js_per_node/toc_js_per_node.module
    ------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------
     10 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is
        |       |     Drupal\Core\Form\FormStateInterface.
    ------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------------------
    
  • šŸ‡®šŸ‡³India pray_12

    I have solved #8 errors.
    Please review!!

  • šŸ‡µšŸ‡­Philippines clarkssquared

    Hi

    I applied MR !7 after commit #8 and I confirmed that all PHPCS issues are resolved

    āžœ  toc_js git:(2.0.x) curl https://git.drupalcode.org/project/toc_js/-/merge_requests/7.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  7590    0  7590    0     0  12141      0 --:--:-- --:--:-- --:--:-- 12261
    patching file README.txt
    patching file 'modules/toc_js_per_node/toc_js_per_node.module'
    patching file 'src/Plugin/Block/TocJsBlock.php'
    patching file toc_js.install
    patching file toc_js.module
    āžœ  toc_js git:(2.0.x) āœ— ..
    āžœ  contrib git:(master) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml toc_js 
    āžœ  contrib git:(master) āœ— 
    
  • Status changed to RTBC 11 months ago
  • šŸ‡®šŸ‡³India Yashaswi18

    Hello, ran the command
    phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml toc_js/

    Found that there are no phpcs issues remaining.

  • Status changed to Fixed 4 months ago
  • šŸ‡«šŸ‡·France mably

    Fixed in 3.0.x-dev version.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024