Fix the warnings/errors reported by PHP_CodeSniffer

Created on 28 June 2023, over 1 year ago
Updated 3 July 2023, over 1 year ago

Fix all the issue found by phpcs

Use below command with arguments:-
phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,css,js,yml web/modules/custom/taxonomy_sitemap_xml

FILE: ...\htdocs\sonam\web\modules\taxonomy_sitemap_xml\taxonomy_sitemap_xml.module
--------------------------------------------------------------------------------
FOUND 7 ERRORS AND 1 WARNING AFFECTING 8 LINES
--------------------------------------------------------------------------------
  1 | ERROR   | [x] Missing file doc comment
  3 | ERROR   | [x] Missing function doc comment
 13 | ERROR   | [x] Whitespace found at end of line
 30 | ERROR   | [x] Whitespace found at end of line
 39 | ERROR   | [x] Whitespace found at end of line
 48 | ERROR   | [x] Whitespace found at end of line
 49 | WARNING | [x] There must be no blank line following an inline comment
 50 | ERROR   | [x] Whitespace found at end of line
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...web\modules\taxonomy_sitemap_xml\src\Controller\SitemapIndexController.php
--------------------------------------------------------------------------------
FOUND 32 ERRORS AFFECTING 25 LINES
--------------------------------------------------------------------------------
  9 | ERROR | [ ] Class name doesn't match filename; expected "class
    |       |     SitemapIndexController"
  9 | ERROR | [x] Missing class doc comment
 11 | ERROR | [x] Missing function doc comment
 16 | ERROR | [x] Whitespace found at end of line
 21 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 4
 21 | ERROR | [x] Object operator not indented correctly; expected 6 spaces but
    |       |     found 4
 22 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 4
 26 | ERROR | [x] Expected 1 space after FOREACH keyword; 0 found
 27 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 27 | ERROR | [x] Expected 1 space after IF keyword; 0 found
 28 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 12
 29 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 30 | ERROR | [x] Whitespace found at end of line
 35 | ERROR | [x] Functions must not contain multiple empty lines in a row;
    |       |     found 2 empty lines
 40 | ERROR | [x] Functions must not contain multiple empty lines in a row;
    |       |     found 2 empty lines
 48 | ERROR | [x] Array indentation error, expected 6 spaces but found 8
 49 | ERROR | [x] Array indentation error, expected 6 spaces but found 8
 50 | ERROR | [x] Whitespace found at end of line
 51 | ERROR | [x] Whitespace found at end of line
 52 | ERROR | [x] Inline comments must start with a capital letter
 52 | ERROR | [x] Inline comments must end in full-stops, exclamation marks,
    |       |     question marks, colons, or closing parentheses
 52 | ERROR | [x] Whitespace found at end of line
 54 | ERROR | [x] Whitespace found at end of line
 57 | ERROR | [x] Whitespace found at end of line
 71 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 4
 71 | ERROR | [x] Object operator not indented correctly; expected 6 spaces but
    |       |     found 4
 72 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 4
 74 | ERROR | [x] Expected 1 space after FOREACH keyword; 0 found
 74 | ERROR | [x] Whitespace found at end of line
 75 | ERROR | [x] Expected 1 space after IF keyword; 0 found
 76 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 10
 88 | ERROR | [x] Expected 1 newline at end of file; 0 found
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 31 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...\modules\taxonomy_sitemap_xml\src\Controller\TaxonomySitemapController.php
--------------------------------------------------------------------------------
FOUND 11 ERRORS AND 2 WARNINGS AFFECTING 10 LINES
--------------------------------------------------------------------------------
  8 | WARNING | [x] Unused use statement
 12 | WARNING | [x] Unused use statement
 14 | ERROR   | [x] Missing class doc comment
 42 | ERROR   | [x] Missing function doc comment
 42 | ERROR   | [ ] Public method name
    |         |     "TaxonomySitemapController::TaxonomySitemapXml" is not in
    |         |     lowerCamel format
 49 | ERROR   | [x] Expected newline after closing brace
 68 | ERROR   | [x] Whitespace found at end of line
 79 | ERROR   | [x] Concat operator must be surrounded by a single space
 79 | ERROR   | [x] Whitespace found at end of line
 91 | ERROR   | [x] Whitespace found at end of line
 92 | ERROR   | [x] Whitespace found at end of line
 93 | ERROR   | [x] Expected 1 newline at end of file; 0 found
 93 | ERROR   | [x] The closing brace for the class must have an empty line
    |         |     before it
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 12 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...les\taxonomy_sitemap_xml\src\Controller\TaxonomySitemapIndexController.php
--------------------------------------------------------------------------------
FOUND 32 ERRORS AFFECTING 25 LINES
--------------------------------------------------------------------------------
  9 | ERROR | [x] Missing class doc comment
 11 | ERROR | [x] Missing function doc comment
 11 | ERROR | [ ] Public method name
    |       |     "TaxonomySitemapIndexController::TaxonomySitemapIndexXml" is
    |       |     not in lowerCamel format
 16 | ERROR | [x] Whitespace found at end of line
 21 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 4
 21 | ERROR | [x] Object operator not indented correctly; expected 6 spaces but
    |       |     found 4
 22 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 4
 26 | ERROR | [x] Expected 1 space after FOREACH keyword; 0 found
 27 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 27 | ERROR | [x] Expected 1 space after IF keyword; 0 found
 28 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 12
 29 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 8
 30 | ERROR | [x] Whitespace found at end of line
 35 | ERROR | [x] Functions must not contain multiple empty lines in a row;
    |       |     found 2 empty lines
 40 | ERROR | [x] Functions must not contain multiple empty lines in a row;
    |       |     found 2 empty lines
 48 | ERROR | [x] Array indentation error, expected 6 spaces but found 8
 49 | ERROR | [x] Array indentation error, expected 6 spaces but found 8
 50 | ERROR | [x] Whitespace found at end of line
 51 | ERROR | [x] Whitespace found at end of line
 52 | ERROR | [x] Inline comments must start with a capital letter
 52 | ERROR | [x] Inline comments must end in full-stops, exclamation marks,
    |       |     question marks, colons, or closing parentheses
 52 | ERROR | [x] Whitespace found at end of line
 54 | ERROR | [x] Whitespace found at end of line
 57 | ERROR | [x] Whitespace found at end of line
 71 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 4
 71 | ERROR | [x] Object operator not indented correctly; expected 6 spaces but
    |       |     found 4
 72 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 4
 74 | ERROR | [x] Expected 1 space after FOREACH keyword; 0 found
 74 | ERROR | [x] Whitespace found at end of line
 75 | ERROR | [x] Expected 1 space after IF keyword; 0 found
 76 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 10
 88 | ERROR | [x] Expected 1 newline at end of file; 0 found
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 31 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...ules\taxonomy_sitemap_xml\src\Form\TaxonomySitemapVocabularyConfigForm.php
--------------------------------------------------------------------------------
FOUND 6 ERRORS AND 1 WARNING AFFECTING 5 LINES
--------------------------------------------------------------------------------
  7 | WARNING | [x] Unused use statement
  9 | ERROR   | [x] Missing class doc comment
 60 | ERROR   | [x] Concat operator must be surrounded by a single space
 66 | ERROR   | [x] Concat operator must be surrounded by a single space
 66 | ERROR   | [x] Concat operator must be surrounded by a single space
 87 | ERROR   | [x] Expected 1 newline at end of file; 0 found
 87 | ERROR   | [x] The closing brace for the class must have an empty line
    |         |     before it
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

📌 Task
Status

Needs review

Version

1.0

Component

Code

Created by

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

Comments & Activities

  • Issue created by @sonam_sharma
  • Status changed to Needs work over 1 year ago
  • 🇵🇭Philippines paraderojether

    Hi @sonam_sharma

    I reviewed patch #2, and there still remaining issues reported by phpcs after applying the patch.

    Command used: phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig

    FILE: /Users/studenttrainees/Drupal/drupalorg-issues-site/docroot/modules/contrib/taxonomy_sitemap_xml/taxonomy_sitemap_xml.info.yml
    ------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------------------
     8 | WARNING | All dependencies must be prefixed with the project name, for example "drupal:"
    ------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/studenttrainees/Drupal/drupalorg-issues-site/docroot/modules/contrib/taxonomy_sitemap_xml/Readme.md
    ----------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 8 WARNINGS AFFECTING 8 LINES
    ----------------------------------------------------------------------------------------------------------------
      4 | WARNING | Line exceeds 80 characters; contains 205 characters
      7 | WARNING | Line exceeds 80 characters; contains 93 characters
      9 | WARNING | Line exceeds 80 characters; contains 121 characters
     15 | WARNING | Line exceeds 80 characters; contains 108 characters
     16 | WARNING | Line exceeds 80 characters; contains 141 characters
     17 | WARNING | Line exceeds 80 characters; contains 125 characters
     25 | WARNING | Line exceeds 80 characters; contains 163 characters
     28 | WARNING | Line exceeds 80 characters; contains 142 characters
    ----------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/studenttrainees/Drupal/drupalorg-issues-site/docroot/modules/contrib/taxonomy_sitemap_xml/templates/taxonomy-sitemap-index.html.twig
    -------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
    -------------------------------------------------------------------------------------------------------------------------------------------------
     1 | WARNING | [ ] Possible use of short open tags detected; found: <?xml version="1.0" encoding="UTF-8"?>
       |         |
     8 | ERROR   | [x] Expected 1 newline at end of file; 2 found
    -------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/studenttrainees/Drupal/drupalorg-issues-site/docroot/modules/contrib/taxonomy_sitemap_xml/templates/taxonomy-sitemap-xml.html.twig
    -----------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
    -----------------------------------------------------------------------------------------------------------------------------------------------
      1 | WARNING | [ ] Possible use of short open tags detected; found: <?xml version="1.0" encoding="UTF-8"?>
        |         |
     13 | ERROR   | [x] Expected 1 newline at end of file; 3 found
    -----------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/studenttrainees/Drupal/drupalorg-issues-site/docroot/modules/contrib/taxonomy_sitemap_xml/src/Form/TaxonomySitemapVocabularyConfigForm.php
    -------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------------------------------------
     35 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    -------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/studenttrainees/Drupal/drupalorg-issues-site/docroot/modules/contrib/taxonomy_sitemap_xml/src/Controller/SitemapIndexController.php
    ------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 14 WARNINGS AFFECTING 11 LINES
    ------------------------------------------------------------------------------------------------------------------------------------------------
     18 | WARNING | Unused variable $current_language.
     18 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     20 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     25 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     26 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     30 | WARNING | Unused variable $host.
     30 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     46 | WARNING | Unused variable $host.
     46 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     69 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     70 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     73 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     74 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     84 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    ------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/studenttrainees/Drupal/drupalorg-issues-site/docroot/modules/contrib/taxonomy_sitemap_xml/src/Controller/TaxonomySitemapController.php
    ---------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 5 LINES
    ---------------------------------------------------------------------------------------------------------------------------------------------------
     47 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     56 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     68 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     74 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     79 | WARNING | Unused variable $url.
    ---------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/studenttrainees/Drupal/drupalorg-issues-site/docroot/modules/contrib/taxonomy_sitemap_xml/src/Controller/TaxonomySitemapIndexController.php
    --------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 14 WARNINGS AFFECTING 11 LINES
    --------------------------------------------------------------------------------------------------------------------------------------------------------
     18 | WARNING | Unused variable $current_language.
     18 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     20 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     25 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     26 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     30 | WARNING | Unused variable $host.
     30 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     46 | WARNING | Unused variable $host.
     46 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     69 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     70 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     73 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     74 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     84 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    --------------------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 363ms; Memory: 10MB

    Better to fix remaining errors/warnings in this issue since it is also related to phpcs.
    Thank you.

  • 🇮🇳India Ashutosh Ahirwal India

    Issue summary updated

  • Assigned to thakurnishant_06
  • I will work on this
    Thank you :)

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • Hello Everyone,
    Hope you are doing well, created a patch to fix all errors and some warnings related to coding standards.
    Kindly review the patch.
    Thank you for your support.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
Production build 0.71.5 2024