Fix the issue reported by phpcs

Created on 21 July 2023, 11 months ago
Updated 29 August 2023, 10 months ago

Problem/Motivation

Getting following error/warnings:

FILE: D:\xampp\htdocs\project_10\web\modules\contrib\advanced_help_block\advanced_help_block.module
---------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
---------------------------------------------------------------------------------------------------
 1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
 9 | WARNING | [x] Unused use statement
---------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------


FILE: D:\xampp\htdocs\project_10\web\modules\contrib\advanced_help_block\library\css\ahb.css
--------------------------------------------------------------------------------------------
FOUND 14 ERRORS AFFECTING 14 LINES
--------------------------------------------------------------------------------------------
  1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
  2 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
  5 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
  8 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
  9 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 10 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 11 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 14 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 15 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 16 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 17 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 20 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 23 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 24 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
--------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 14 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------


FILE: D:\xampp\htdocs\project_10\web\modules\contrib\advanced_help_block\src\AdvancedHelpBlockAccessControlHandler.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: D:\xampp\htdocs\project_10\web\modules\contrib\advanced_help_block\src\AdvancedHelpBlockInterface.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: D:\xampp\htdocs\project_10\web\modules\contrib\advanced_help_block\src\AdvancedHelpBlockViewsData.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: D:\xampp\htdocs\project_10\web\modules\contrib\advanced_help_block\src\Entity\AdvancedHelpBlock.php
-----------------------------------------------------------------------------------------------------------
FOUND 15 ERRORS AND 8 WARNINGS AFFECTING 22 LINES
-----------------------------------------------------------------------------------------------------------
   1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
   6 | WARNING | [x] Unused use statement
   7 | WARNING | [x] Unused use statement
   8 | WARNING | [x] Unused use statement
 115 | WARNING | [ ] Line exceeds 80 characters; contains 82 characters
 151 | ERROR   | [x] Short array syntax must be used to define arrays
 179 | ERROR   | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
 189 | WARNING | [x] There must be no blank line following an inline comment
 189 | WARNING | [ ] There must be no blank line following an inline comment
 195 | ERROR   | [x] Short array syntax must be used to define arrays
 202 | ERROR   | [x] Short array syntax must be used to define arrays
 209 | ERROR   | [x] Short array syntax must be used to define arrays
 221 | WARNING | [ ] Avoid backslash escaping in translatable strings when possible, use "" quotes instead
 225 | ERROR   | [x] Short array syntax must be used to define arrays
 231 | ERROR   | [x] Short array syntax must be used to define arrays
 238 | ERROR   | [x] Short array syntax must be used to define arrays
 240 | WARNING | [x] A comma should follow the last multiline array item. Found: 5
 251 | ERROR   | [x] Short array syntax must be used to define arrays
 252 | ERROR   | [x] Short array syntax must be used to define arrays
 260 | ERROR   | [x] Short array syntax must be used to define arrays
 267 | ERROR   | [x] Short array syntax must be used to define arrays
 338 | ERROR   | [x] Expected 1 blank line after function; 0 found
 339 | ERROR   | [x] The closing brace for the class must have an empty line before it
-----------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 20 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------


FILE: D:\xampp\htdocs\project_10\web\modules\contrib\advanced_help_block\src\Form\AdvancedHelpBlockDeleteForm.php
---------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
---------------------------------------------------------------------------------------------------------------------------------------------
  1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
 23 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
---------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------


FILE: D:\xampp\htdocs\project_10\web\modules\contrib\advanced_help_block\src\Form\AdvancedHelpBlockForm.php
-----------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 3 WARNINGS AFFECTING 6 LINES
-----------------------------------------------------------------------------------------------------------
  1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
 32 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 44 | WARNING | [x] A comma should follow the last multiline array item. Found: )
 54 | WARNING | [x] A comma should follow the last multiline array item. Found: )
 62 | ERROR   | [x] Expected 1 blank line after function; 0 found
 63 | ERROR   | [x] The closing brace for the class must have an empty line before it
-----------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------


FILE: D:\xampp\htdocs\project_10\web\modules\contrib\advanced_help_block\src\Form\AdvancedHelpBlockSettingsForm.php
---------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 8 WARNINGS AFFECTING 8 LINES
---------------------------------------------------------------------------------------------------------------------------------------------
  1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
  5 | WARNING | [x] Unused use statement
  9 | WARNING | [x] Unused use statement
 16 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
 41 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 46 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 48 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 49 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 49 | WARNING | [x] A comma should follow the last multiline array item. Found: )
---------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------

Steps to reproduce

Run following command:

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

Proposed resolution

Above error/warnings need to be fixed.

📌 Task
Status

Needs review

Version

1.0

Component

Code

Created by

🇮🇳India arti_parmar

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

Comments & Activities

  • Issue created by @arti_parmar
  • Issue was unassigned.
  • Status changed to Needs review 11 months ago
  • 🇮🇳India arti_parmar

    Kindly review patch.

  • Hii, @arti_parmar
    I have Review your patch.

    These are the steps I followed:

    1. Took clone in version 1.0.x in drupal 10.1.x

    2. Applied patch and ran this command:

    ./vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig modules/contrib/advanced_help_block/

    3. Applied your patch and again ran phpcs command

    But I found errors.

    I have fixed that error with phpcbf.

    Ran this command to fix the errors:

    ./vendor/bin/phpcbf --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,m
    d,yml,twig modules/contrib/advanced_help_block/

    4. Then again checked with phpcs:

    ./vendor/bin/phpcbf --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,m
    d,yml,twig modules/contrib/advanced_help_block/

    Found no errors.

    Needs review.

  • 🇺🇸United States froboy Chicago, IL

    Just a reminder that in addition to the patch review, we'll need someone to test functionality before this patch is merged. Also, work should be done in a Merge Request instead of patches.

Production build 0.69.0 2024