Fix the issues reported by phpcs

Created on 3 July 2023, over 1 year ago
Updated 15 August 2024, 5 months ago

Problem/Motivation

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 block_styles

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\block_styles\block_styles.module
------------------------------------------------------------------------------------------------------------------------
FOUND 33 ERRORS AND 3 WARNINGS AFFECTING 27 LINES
------------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] Missing file doc comment
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
12 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 5
23 | ERROR | [x] There should be no white space after an opening "("
23 | ERROR | [x] There should be no white space before a closing ")"
26 | ERROR | [x] There should be no white space after an opening "("
26 | ERROR | [x] There should be no white space before a closing ")"
27 | WARNING | [ ] Only string literals should be passed to t() where possible
28 | ERROR | [x] Whitespace found at end of line
36 | 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."
37 | ERROR | [x] There must be no blank lines after the function comment
39 | ERROR | [x] Namespaced classes/interfaces/traits should be referenced with use statements
45 | ERROR | [x] Namespaced classes/interfaces/traits should be referenced with use statements
56 | WARNING | [ ] Unused variable $attributes.
62 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
62 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 3
62 | ERROR | [x] Closing brace indented incorrectly; expected 4 spaces, found 3
68 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
68 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 3
68 | ERROR | [x] Closing brace indented incorrectly; expected 4 spaces, found 3
71 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing
| | parentheses
90 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing
| | parentheses
101 | ERROR | [x] Whitespace found at end of line
112 | ERROR | [x] Whitespace found at end of line
117 | ERROR | [x] Missing function doc comment
121 | ERROR | [x] Missing function doc comment
126 | ERROR | [x] Expected 1 space after IF keyword; 0 found
133 | ERROR | [x] Whitespace found at end of line
137 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
137 | ERROR | [x] Array closing indentation error, expected 4 spaces but found 3
147 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
147 | ERROR | [x] Line indented incorrectly; expected at least 4 spaces, found 1
151 | ERROR | [x] Missing function doc comment
153 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
158 | ERROR | [x] Namespaced classes/interfaces/traits should be referenced with use statements
167 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 33 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------

FILE: ...cs\backendassignment\web\modules\contrib\block_styles\modules\block_styles_bootstrap\block_styles_bootstrap.module
------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 2 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"
5 | ERROR | [x] Expected 1 newline at end of file; 2 found
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------

FILE: ...es\contrib\block_styles\modules\block_styles_bootstrap\templates\bootstrap_collapse\block--bootstrap--collapse.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: ...es\contrib\block_styles\modules\block_styles_bootstrap\templates\bootstrap_dropdown\block--bootstrap--dropdown.css
------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
13 | ERROR | [x] Expected 1 newline at end of file; 0 found
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------

FILE: ...\modules\contrib\block_styles\modules\block_styles_bootstrap\templates\bootstrap_modal\block--bootstrap--modal.css
------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
8 | ERROR | [x] Expected 1 newline at end of file; 0 found
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------

FILE: ...es\contrib\block_styles\modules\block_styles_bootstrap\templates\bootstrap_modal\block--bootstrap--modal.html.twig
------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------
74 | 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\block_styles\src\BlockStyleStorage.php
--------------------------------------------------------------------------------------------------
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\block_styles\src\Entity\BlockStyle.php
--------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AFFECTING 6 LINES
--------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
5 | ERROR | [x] There must be one blank line after the last USE statement; 2 found;
11 | ERROR | [x] Whitespace found at end of line
96 | ERROR | [x] Short array syntax must be used to define arrays
101 | ERROR | [x] Expected 1 blank line after function; 0 found
102 | ERROR | [x] The closing brace for the class must have an empty line before it
--------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\block_styles\src\Entity\BlockStyleInterface.php
-----------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
-----------------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
12 | ERROR | [x] Missing function doc comment
14 | ERROR | [x] Missing function doc comment
16 | ERROR | [x] Missing function doc comment
18 | ERROR | [x] Missing function doc comment
-----------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------

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

Needs work

Version

2.0

Component

Code

Created by

šŸ‡®šŸ‡³India sidharth_soman Bangalore

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

Comments & Activities

  • Issue created by @sidharth_soman
  • Status changed to Needs work over 1 year ago
  • šŸ‡®šŸ‡³India sidharth_soman Bangalore

    Working on solving these.

  • @sidharth_soman opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • šŸ‡®šŸ‡³India sidharth_soman Bangalore

    I have fixed all the issues except for those related to filling out documentation, which I think should be ideally done by the maintainers.
    Please review the MR above.

  • Status changed to Needs work 5 months ago
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi @sidharth_soman,

    I applied MR!3, it was applied smoothly and fixed most of the phpcs issues.

    These are the remaining issues after I run phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml.

    āžœ  block_styles git:(2.x) curl https://git.drupalcode.org/project/block_styles/-/merge_requests/3.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 10655    0 10655    0     0  24159      0 --:--:-- --:--:-- --:--:-- 24160
    patching file block_styles.module
    patching file modules/block_styles_bootstrap/block_styles_bootstrap.module
    patching file modules/block_styles_bootstrap/templates/bootstrap_dropdown/block--bootstrap--dropdown.css
    patching file modules/block_styles_bootstrap/templates/bootstrap_dropdown/block--bootstrap--dropdown.html.twig
    patching file modules/block_styles_bootstrap/templates/bootstrap_modal/block--bootstrap--modal.css
    patching file modules/block_styles_bootstrap/templates/bootstrap_modal/block--bootstrap--modal.html.twig
    patching file src/Entity/BlockStyle.php
    patching file src/Entity/BlockStyleInterface.php
    āžœ  block_styles git:(2.x) āœ— ..
    āžœ  contrib phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml block_styles
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/block_styles/block_styles.module
    ---------------------------------------------------------------------------------------------------------------------------------
    FOUND 4 ERRORS AND 2 WARNINGS AFFECTING 6 LINES
    ---------------------------------------------------------------------------------------------------------------------------------
       9 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Form\FormStateInterface.
      33 | WARNING | [ ] Only string literals should be passed to t() where possible
      61 | WARNING | [ ] Unused variable $attributes.
     122 | ERROR   | [ ] Doc comment is empty
     129 | ERROR   | [ ] Doc comment is empty
     162 | ERROR   | [ ] Doc comment is empty
    ---------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/block_styles/modules/block_styles_bootstrap/block_styles_bootstrap.module
    ----------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------------------------------------------------
     3 | ERROR | Missing short description in doc comment
    ----------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/block_styles/src/Entity/BlockStyleInterface.php
    --------------------------------------------------------------------------------------------------------------------
    FOUND 4 ERRORS AFFECTING 4 LINES
    --------------------------------------------------------------------------------------------------------------------
     12 | ERROR | Doc comment is empty
     17 | ERROR | Doc comment is empty
     22 | ERROR | Doc comment is empty
     27 | ERROR | Doc comment is empty
    --------------------------------------------------------------------------------------------------------------------
    
    Time: 337ms; Memory: 10MB
    
    āžœ  contrib

    Thank you.

Production build 0.71.5 2024