Fix the issues reported by phpcs

Created on 24 November 2023, about 1 year ago
Updated 1 December 2023, about 1 year ago

Problem/Motivation

Getting following error/warnings.

FILE: /modules/contrib/book_navigation_block/book_navigation_block.module
------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 1 WARNING AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] Missing file doc comment
11 | WARNING | [ ] Line exceeds 80 characters; contains 96 characters
11 | ERROR | [x] Comments may not appear after statements
11 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
--------------------------------------------------------------------------------

FILE: /modules/contrib/book_navigation_block/src/Plugin/Block/BookNavigationBlock.php
------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 15 ERRORS AND 3 WARNINGS AFFECTING 17 LINES
------------------------------------------------------------------------------------------------------------------------------------------------
10 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Plugin\ContainerFactoryPluginInterface.
60 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
61 | ERROR | [x] Expected 2 space(s) before asterisk; 3 found
62 | ERROR | [x] Expected 2 space(s) before asterisk; 3 found
63 | ERROR | [x] Expected 2 space(s) before asterisk; 3 found
64 | ERROR | [x] Expected 2 space(s) before asterisk; 3 found
65 | ERROR | [x] Expected 2 space(s) before asterisk; 3 found
71 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
72 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
112 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
115 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
121 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
127 | WARNING | [ ] Node::load calls should be avoided in classes, use dependency injection instead
132 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
152 | ERROR | [x] Use null coalesce operator instead of ternary operator.
152 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
163 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
166 | ERROR | [x] Expected 1 newline at end of file; 0 found

Steps to reproduce

Run following command

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

Proposed resolution

Above error/warnings need to be fixed.

šŸ“Œ Task
Status

RTBC

Version

1.0

Component

Code

Created by

šŸ‡®šŸ‡³India manpreet_singh

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

Merge Requests

Comments & Activities

  • Issue created by @manpreet_singh
  • Assigned to nitin_lama
  • šŸ‡®šŸ‡³India nitin_lama India

    Two warnings remaining. Please review.

    FILE: /home/system/Documents/contribution/book_navigation_block-3403917/src/Plugin/Block/BookNavigationBlock.php
    ----------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    ----------------------------------------------------------------------------------------------------------------
      83 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     123 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    ----------------------------------------------------------------------------------------------------------------
    
  • Issue was unassigned.
  • Status changed to Needs work about 1 year ago
  • Status changed to Needs review about 1 year ago
  • All the issues reported by PHPcs has been fixed in attached patch.
    Please review
    Thank you

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

    Hi

    I applied patch #6 and I confirmed that it fixes all the PHPCS issues the remaining issues that my terminal flagged occurs when the module is installed via composer.

    āžœ  book_navigation_block git:(master) āœ— curl https://www.drupal.org/files/issues/2023-11-29/fixed_phpcs_issues.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  6853  100  6853    0     0  13382      0 --:--:-- --:--:-- --:--:-- 13816
    patching file book_navigation_block.module
    patching file 'src/Plugin/Block/BookNavigationBlock.php'
    āžœ  book_navigation_block git:(master) āœ— ..
    āžœ  contrib git:(master) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml book_navigation_block 
    
    FILE: ...jects/d9/d9-local/web/modules/contrib/book_navigation_block/book_navigation_block.info.yml
    ------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 2 LINES
    ------------------------------------------------------------------------------------------------
     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
     7 | WARNING | All dependencies must be prefixed with the project name, for example "drupal:"
    ------------------------------------------------------------------------------------------------
    
    Time: 555ms; Memory: 10MB
    
    āžœ  contrib git:(master) āœ— 
    
Production build 0.71.5 2024