Fix the issues reported by phpcs

Created on 3 July 2024, 7 months ago
Updated 17 July 2024, 7 months ago

Problem/Motivation

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

FILE: /var/www/html/drupal-contri-d10/modules/contrib/survey_ai/src/Form/SurveyForm.php
----------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
----------------------------------------------------------------------------------------------
 116 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 133 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 144 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------


FILE: /var/www/html/drupal-contri-d10/modules/contrib/survey_ai/src/Controller/SurveyResultController.php
---------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
---------------------------------------------------------------------------------------------------------
  64 | WARNING | Unused variable $answer.
 134 | WARNING | Node::load calls should be avoided in classes, use dependency injection instead
 143 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
---------------------------------------------------------------------------------------------------------


FILE: /var/www/html/drupal-contri-d10/modules/contrib/survey_ai/src/Controller/SurveyController.php
--------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
--------------------------------------------------------------------------------------------------------
 22 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 27 | WARNING | Node::loadMultiple calls should be avoided in classes, use dependency injection instead
--------------------------------------------------------------------------------------------------------


FILE: /var/www/html/drupal-contri-d10/modules/contrib/survey_ai/src/Plugin/Block/SurveyFormBlock.php
----------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------------------------------------
 72 | WARNING | Node::load calls should be avoided in classes, use dependency injection instead
 92 | WARNING | Node::load calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------------


FILE: /var/www/html/drupal-contri-d10/modules/contrib/survey_ai/survey.module
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 97 ERRORS AND 12 WARNINGS AFFECTING 81 LINES
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   1 | ERROR   | [x] Missing file doc comment
   3 | WARNING | [x] Unused use statement
   4 | WARNING | [x] Unused use statement
   5 | WARNING | [x] Unused use statement
   6 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Form\FormStateInterface.
  10 | WARNING | [x] Unused use statement
  12 | WARNING | [x] Unused use statement
  13 | WARNING | [x] Unused use statement
  18 | ERROR   | [ ] survey_install() is an installation hook and must be declared in an install file
  20 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
  21 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
  22 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
  24 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
  24 | ERROR   | [x] Namespaced classes/interfaces/traits should be referenced with use statements
  25 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
  25 | ERROR   | [x] Namespaced classes/interfaces/traits should be referenced with use statements
  26 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
  26 | ERROR   | [x] Namespaced classes/interfaces/traits should be referenced with use statements
  27 | ERROR   | [x] Expected 1 blank line after function; 2 found
  31 | 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."
  34 | ERROR   | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
  36 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
  38 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  40 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  41 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
  42 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
  43 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
  44 | ERROR   | [x] Array indentation error, expected 14 spaces but found 16
  45 | ERROR   | [x] Array indentation error, expected 14 spaces but found 16
  46 | ERROR   | [x] Array indentation error, expected 14 spaces but found 16
  48 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
  49 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
  52 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  53 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
  54 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
  57 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  58 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  58 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
  59 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
  73 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
  74 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  75 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  75 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
  76 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  77 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
  78 | ERROR   | [x] Array indentation error, expected 14 spaces but found 16
  79 | ERROR   | [x] Array indentation error, expected 14 spaces but found 16
  81 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
  82 | ERROR   | [x] Array indentation error, expected 14 spaces but found 16
  83 | ERROR   | [x] Array indentation error, expected 14 spaces but found 16
  85 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
  89 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 8
  89 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
  91 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 8
  93 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 8
  94 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 12
  95 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 12
  95 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
  96 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 12
  96 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
  96 | ERROR   | [x] Comments may not appear after statements
  97 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 12
  97 | WARNING | [ ] Line exceeds 80 characters; contains 112 characters
  97 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
  97 | ERROR   | [x] Comments may not appear after statements
  98 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 12
  98 | WARNING | [ ] Line exceeds 80 characters; contains 118 characters
  98 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
  98 | ERROR   | [x] Comments may not appear after statements
  99 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 12
  99 | WARNING | [ ] Line exceeds 80 characters; contains 97 characters
  99 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
  99 | ERROR   | [x] Comments may not appear after statements
 100 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 12
 100 | WARNING | [ ] Line exceeds 80 characters; contains 88 characters
 100 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 100 | ERROR   | [x] Comments may not appear after statements
 101 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 8
 101 | ERROR   | [x] Expected newline after closing brace
 102 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 12
 102 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 102 | ERROR   | [x] Comments may not appear after statements
 103 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 8
 104 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 104 | ERROR   | [x] Expected newline after closing brace
 105 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 106 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 108 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 109 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 115 | ERROR   | [ ] survey_uninstall() is an installation hook and must be declared in an install file
 116 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 116 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 117 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 118 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 119 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 120 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 121 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 122 | ERROR   | [x] Object operator not indented correctly; expected 14 spaces but found 16
 124 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 126 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 126 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 127 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 127 | ERROR   | [x] Namespaced classes/interfaces/traits should be referenced with use statements
 128 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 129 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 16
 130 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 132 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 133 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 134 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 102 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/drupal-contri-d10/modules/contrib/survey_ai/README.md
-------------------------------------------------------------------------
FOUND 1 ERROR AND 6 WARNINGS AFFECTING 7 LINES
-------------------------------------------------------------------------
  8 | WARNING | [ ] Line exceeds 80 characters; contains 225 characters
 43 | WARNING | [ ] Line exceeds 80 characters; contains 122 characters
 45 | WARNING | [ ] Line exceeds 80 characters; contains 118 characters
 59 | WARNING | [ ] Line exceeds 80 characters; contains 89 characters
 60 | WARNING | [ ] Line exceeds 80 characters; contains 112 characters
 63 | WARNING | [ ] Line exceeds 80 characters; contains 108 characters
 67 | ERROR   | [x] Expected 1 newline at end of file; 0 found
-------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------


FILE: /var/www/html/drupal-contri-d10/modules/contrib/survey_ai/survey.libraries.yml
------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------
 28 | ERROR | [x] Expected 1 newline at end of file; 2 found
------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------


FILE: /var/www/html/drupal-contri-d10/modules/contrib/survey_ai/survey.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
 11 | WARNING | All dependencies must be prefixed with the project name, for example "drupal:"
--------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/drupal-contri-d10/modules/contrib/survey_ai/survey.install
------------------------------------------------------------------------------
FOUND 39 ERRORS AFFECTING 39 LINES
------------------------------------------------------------------------------
  1 | ERROR | [x] Missing file doc comment
  7 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
  8 | ERROR | [x] Array indentation error, expected 6 spaces but found 8
  9 | ERROR | [x] Array indentation error, expected 6 spaces but found 8
 10 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 11 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 12 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 13 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 14 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 16 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 17 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 18 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 19 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 20 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 22 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 23 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 24 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 25 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 26 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 28 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 29 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 30 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 31 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 32 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 34 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 35 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 36 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 37 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 38 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 40 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 41 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 42 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 43 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 44 | ERROR | [x] Array indentation error, expected 14 spaces but found 16
 47 | ERROR | [x] Array indentation error, expected 6 spaces but found 8
 48 | ERROR | [x] Array indentation error, expected 6 spaces but found 8
 49 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 50 | ERROR | [x] Array indentation error, expected 10 spaces but found 12
 54 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
------------------------------------------------------------------------------
PHPCBF CAN FIX THE 39 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------


FILE: /var/www/html/drupal-contri-d10/modules/contrib/survey_ai/survey.links.menu.yml
-------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------
 14 | ERROR | [x] Expected 1 newline at end of file; 0 found
-------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------

Time: 242ms; Memory: 10MB

Steps to reproduce

Run PHPCS on Config Pages module.

Proposed resolution

Fixed the coding standards.

Remaining tasks

Submit the patch either MR.

📌 Task
Status

RTBC

Version

1.0

Component

Code

Created by

🇮🇳India bhaveshdas

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 @bhaveshdas
  • Issue was unassigned.
  • Status changed to Needs work 7 months ago
  • 🇮🇳India bhaveshdas

    I have solved all issues. But still there are some issues left.
    Please have a look.

    Thankyou !

    FILE: /var/www/html/drupal-contri-d10/modules/custom/survey_ai-3458776/survey.module
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 3 ERRORS AND 1 WARNING AFFECTING 4 LINES
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    3 | ERROR | Missing short description in doc comment
    20 | ERROR | survey_install() is an installation hook and must be declared in an install file
    32 | 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."
    123 | ERROR | survey_uninstall() is an installation hook and must be declared in an install file
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Time: 246ms; Memory: 10MB

  • Assigned to dev2.addweb
  • Issue was unassigned.
  • Status changed to Needs review 7 months ago
  • 🇮🇳India dev2.addweb

    Hello,

    I have resolved all the issues mentioned above. Kindly check.

  • Status changed to RTBC 7 months ago
  • 🇮🇳India bhaveshdas

    Hi,

    I have verified the PHPCS issue with the MR!1 applied cleanly in the Drupal 10 version.

    Testing Steps:
    -> Install the Drupal 10 version.
    -> Open the command line and run PHPCS on this module.
    -> Check for errors and warnings.

    Testing Results:
    Showing no errors and warnings.

    Attached the after screenshots. Based on these results, the issue can be moved to RTBC.

    RTBC+1

Production build 0.71.5 2024