Fix the errors/warnings reported by Php_CodeSniffer

Created on 5 July 2023, over 1 year ago
Updated 6 March 2024, 9 months ago

Problem/Motivation

PHPCS gives the following errors:

phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig extended_html_filter
FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\extended_html_filter\extended_html_filter.module
------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
------------------------------------------------------------------------------------------------------------
  1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
 11 | ERROR | [x] Missing function doc comment
 12 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\extended_html_filter\src\Form\ExtendedHTMLFilterSettingsForm.php
---------------------------------------------------------------------------------------------------------------------------------------------
FOUND 4 ERRORS AND 3 WARNINGS AFFECTING 7 LINES
---------------------------------------------------------------------------------------------------------------------------------------------
  1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
  7 | WARNING | [x] Unused use statement
 11 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
 57 | ERROR   | [x] Doc comment short description must end with a full stop
 59 | ERROR   | [x] Data types in @return tags need to be fully namespaced
 62 | ERROR   | [x] Expected 1 space before opening brace; found 0
 63 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
---------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\extended_html_filter\src\Plugin\Filter\ExtendedHTMLFilter.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 6 WARNINGS AFFECTING 8 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
   1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
   8 | WARNING | [x] Unused use statement
  13 | WARNING | [ ] Line exceeds 80 characters; contains 92 characters
  24 | WARNING | [ ] Line exceeds 80 characters; contains 193 characters
  43 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  44 | WARNING | [x] A comma should follow the last multiline array item. Found: )
  66 | ERROR   | [ ] Public method name "ExtendedHTMLFilter::getHTMLRestrictions" is not in lowerCamel format
 109 | WARNING | [ ] Unused bound variable $star_protector.
----------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\extended_html_filter\src\Utility\ExtendedHTMLFilterStandard.php
---------------------------------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AFFECTING 3 LINES
---------------------------------------------------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
 7 | ERROR | [x] Missing class doc comment
 7 | ERROR | [x] Expected 1 space before opening brace; found 0
 8 | ERROR | [x] Missing function doc comment
 8 | ERROR | [x] Expected 1 blank line before function; 0 found
 8 | ERROR | [x] Expected 1 space before opening brace; found 0
---------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\extended_html_filter\src\Utility\ExtendedHTMLFilterXss.php
-------------------------------------------------------------------------------------------------------------------------------
FOUND 4 ERRORS AND 1 WARNING AFFECTING 5 LINES
-------------------------------------------------------------------------------------------------------------------------------
   1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
  23 | ERROR   | [x] Expected 1 blank line before function; 0 found
  59 | WARNING | [x] A comma should follow the last multiline array item. Found: 'property'
 183 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 186 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
-------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------

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

1.0

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 over 1 year ago
  • 🇮🇳India sidharth_soman Bangalore

    I have fixed all issues except for those related to filling out or editing documentation. This should ideally be done by the maintainers instead.

    Please review the MR

  • Status changed to Needs work 9 months ago
  • 🇮🇳India Ashutosh Ahirwal India

    Hi, I reviewed the MR1 it resolve the issues but still there are so many issue found.
    moving to need work to get noticed.

    Used command:- ./vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,css,js,yml web/modules/custom/extended_html_filter

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/extended_html_filter/extended_html_filter.info.yml
    ---------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------------
    7 | WARNING | All dependencies must be prefixed with the project name, for example "drupal:"
    ---------------------------------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/extended_html_filter/src/Form/ExtendedHTMLFilterSettingsForm.php
    -----------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------------
    11 | WARNING | The class short comment should describe what the class does and not simply repeat the class name
    -----------------------------------------------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/extended_html_filter/src/Plugin/Filter/ExtendedHTMLFilter.php
    --------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AND 3 WARNINGS AFFECTING 5 LINES
    --------------------------------------------------------------------------------------------------------------------------------------------------
    10 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\StringTranslation\StringTranslationTrait.
    13 | WARNING | [ ] Line exceeds 80 characters; contains 92 characters
    24 | WARNING | [ ] Line exceeds 80 characters; contains 193 characters
    69 | ERROR | [ ] Public method name "ExtendedHTMLFilter::getHTMLRestrictions" is not in lowerCamel format
    112 | WARNING | [ ] Unused bound variable $star_protector.
    --------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/extended_html_filter/src/Utility/ExtendedHTMLFilterStandard.php
    ----------------------------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    ----------------------------------------------------------------------------------------------------------------------------------------
    7 | ERROR | Doc comment is empty
    12 | ERROR | Doc comment is empty
    ----------------------------------------------------------------------------------------------------------------------------------------

    Time: 165ms; Memory: 12MB

  • First commit to issue fork.
  • 🇮🇳India sakthi_dev

    Fixed the remaining issues just keeping the function name to keep it backward compatible in other modules. Please review.

Production build 0.71.5 2024