Fix the issues reported by phpcs

Created on 29 June 2023, over 1 year ago
Updated 29 September 2023, about 1 year ago

Problem/Motivation

There are some issues which are reported by PHP code sniffer within the module.

FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------
8 | WARNING | All dependencies must be prefixed with the project name, for example "drupal:"
----------------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\know-how\modules\custom\operations\modules\site\site.install
----------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------
95 | WARNING | There must be no blank line following an inline comment
----------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\know-how\modules\custom\operations\modules\site\src\Controller\SiteStatusController.php
-------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 6 WARNINGS AFFECTING 6 LINES
-------------------------------------------------------------------------------------------------------------
35 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
80 | WARNING | Unused variable $title.
85 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
88 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
89 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
108 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
-------------------------------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\know-how\modules\custom\operations\modules\site\src\Entity\SiteDefinition.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
------------------------------------------------------------------------------------------------------------------------------------------
169 | WARNING | There must be no blank line following an inline comment
174 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
188 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-------------------------------------------------------------------------------------------------------------------------------
FILE: D:\xampp\htdocs\know-how\modules\custom\operations\modules\site\src\Entity\SiteEntity.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
-------------------------------------------------------------------------------------------------------------------------------
168 | WARNING | There must be no blank line following an inline comment
535 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
548 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
554 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-------------------------------------------------------------------------------------------------------------------------------
FILE: D:\xampp\htdocs\know-how\modules\custom\operations\modules\site\src\EventSubscriber\SiteStateSubscriber.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 7 WARNINGS AFFECTING 7 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
40 | WARNING | There must be no blank line following an inline comment
48 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
65 | WARNING | Unused variable $score_each.
73 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
76 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
83 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
93 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
-------------------------------------------------------------------------------------------------------------------------------
FILE: D:\xampp\htdocs\know-how\modules\custom\operations\modules\site\src\Form\SiteDefinitionForm.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 8 WARNINGS AFFECTING 8 LINES
------------------------------------------------------------------------------------------------------------------------------------------
67 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
138 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
139 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
144 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
145 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
152 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
153 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
211 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
-------------------------------------------------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\know-how\modules\custom\operations\modules\site\src\Form\SiteForm.php
---------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------
21 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
---------------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\know-how\modules\custom\operations\modules\site_manager\site_manager.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:"
---------------------------------------------------------------------------------------------------

Proposed resolution

Need to fix the following issues using the php code standard commands.

📌 Task
Status

Needs work

Version

2.0

Component

Code

Created by

🇮🇳India Prachi6824

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 @Prachi6824
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India Prachi6824

    Hello,

    I have created a patch to solve all the errors related to phpcs within the module

    Please review and apply it .

  • Status changed to Needs work over 1 year ago
  • 🇵🇭Philippines kenyoOwen

    Hi prachi6824

    After applying your patch#2 there are still errors remaining after running the:
    phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml operations

    Please see the screenshots attached.

    Thank you.

  • Assigned to nitin_lama
  • 🇮🇳India nitin_lama India

    Fixed most of the errors/warning.

    Issues remaining:

    FILE: /home/system/Documents/contribution/operations/modules/site/site.install
    ------------------------------------------------------------------------------
    FOUND 3 ERRORS AFFECTING 3 LINES
    ------------------------------------------------------------------------------
     88 | ERROR | Comment indentation error, expected only 1 spaces
     89 | ERROR | Comment indentation error, expected only 2 spaces
     91 | ERROR | Comment indentation error, expected only 4 spaces
    ------------------------------------------------------------------------------
    
    
    FILE: /home/system/Documents/contribution/operations/modules/site/README.md
    ---------------------------------------------------------------------------
    FOUND 0 ERRORS AND 13 WARNINGS AFFECTING 13 LINES
    ---------------------------------------------------------------------------
      7 | WARNING | Line exceeds 80 characters; contains 119 characters
     10 | WARNING | Line exceeds 80 characters; contains 113 characters
     29 | WARNING | Line exceeds 80 characters; contains 104 characters
     33 | WARNING | Line exceeds 80 characters; contains 119 characters
     35 | WARNING | Line exceeds 80 characters; contains 106 characters
     37 | WARNING | Line exceeds 80 characters; contains 96 characters
     39 | WARNING | Line exceeds 80 characters; contains 90 characters
     41 | WARNING | Line exceeds 80 characters; contains 104 characters
     49 | WARNING | Line exceeds 80 characters; contains 95 characters
     51 | WARNING | Line exceeds 80 characters; contains 81 characters
     53 | WARNING | Line exceeds 80 characters; contains 104 characters
     57 | WARNING | Line exceeds 80 characters; contains 99 characters
     59 | WARNING | Line exceeds 80 characters; contains 115 characters
    ---------------------------------------------------------------------------
    
    
    FILE: /home/system/Documents/contribution/operations/modules/site/src/Entity/SiteDefinition.php
    ---------------------------------------------------------------------------------------------------------------------
    FOUND 13 ERRORS AND 2 WARNINGS AFFECTING 12 LINES
    ---------------------------------------------------------------------------------------------------------------------
      78 | ERROR   | Missing short description in doc comment
      85 | ERROR   | Doc comment short description must end with a full stop
      85 | ERROR   | Doc comment short description must be on a single line, further text should be a separate paragraph
      94 | ERROR   | Doc comment is empty
     108 | WARNING | Line exceeds 80 characters; contains 103 characters
     110 | ERROR   | If there is no return value for a function, there must not be a @return tag.
     110 | ERROR   | Description for the @return value is missing
     121 | WARNING | Line exceeds 80 characters; contains 106 characters
     123 | ERROR   | If there is no return value for a function, there must not be a @return tag.
     123 | ERROR   | Description for the @return value is missing
     148 | ERROR   | Description for the @return value is missing
     157 | ERROR   | Description for the @return value is missing
     226 | ERROR   | Description for the @return value is missing
     243 | ERROR   | Doc comment is empty
     254 | ERROR   | Description for the @return value is missing
    ---------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /home/system/Documents/contribution/operations/modules/site/src/Entity/SiteEntity.php
    --------------------------------------------------------------------------------------------
    FOUND 6 ERRORS AFFECTING 5 LINES
    --------------------------------------------------------------------------------------------
     203 | ERROR | Comment indentation error, expected only 1 spaces
     218 | ERROR | Comment indentation error, expected only 1 spaces
     250 | ERROR | Comment indentation error, expected only 1 spaces
     273 | ERROR | Comment indentation error, expected only 1 spaces
     459 | ERROR | If there is no return value for a function, there must not be a @return tag.
     459 | ERROR | Description for the @return value is missing
    --------------------------------------------------------------------------------------------
    
    
    FILE: /home/system/Documents/contribution/operations/modules/site/src/Controller/SiteStatusController.php
    ---------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------
     47 | ERROR | If there is no return value for a function, there must not be a @return tag.
     47 | ERROR | Description for the @return value is missing
    ---------------------------------------------------------------------------------------------------------
    
    
    FILE: /home/system/Documents/contribution/operations/modules/site/src/Controller/SiteController.php
    ---------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------
     25 | ERROR | Doc comment is empty
    ---------------------------------------------------------------------------------------------------
    
    
    FILE: /home/system/Documents/contribution/operations/modules/site/src/Form/SiteDefinitionForm.php
    ---------------------------------------------------------------------------------------------------------------------------------------
    FOUND 4 ERRORS AFFECTING 4 LINES
    ---------------------------------------------------------------------------------------------------------------------------------------
     135 | ERROR | The array declaration extends to column 128 (the limit is 80). The array content should be split up over multiple lines
     172 | ERROR | Doc comment is empty
     177 | ERROR | The array declaration extends to column 95 (the limit is 80). The array content should be split up over multiple lines
     190 | ERROR | Doc comment is empty
    ---------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /home/system/Documents/contribution/operations/modules/site/src/Form/SiteForm.php
    ---------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------
     14 | ERROR | Doc comment is empty
    ---------------------------------------------------------------------------------------
    
    
    FILE: /home/system/Documents/contribution/operations/modules/site/src/SiteEntityInterface.php
    ---------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------
     11 | WARNING | Line exceeds 80 characters; contains 83 characters
    ---------------------------------------------------------------------------------------------
    
    
    FILE: /home/system/Documents/contribution/operations/modules/site/src/SiteInterface.php
    ---------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------
     6 | WARNING | Line exceeds 80 characters; contains 83 characters
    ---------------------------------------------------------------------------------------
    
    
    FILE: /home/system/Documents/contribution/operations/modules/site/src/Plugin/rest/resource/SiteApiResource.php
    --------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------------
     81 | WARNING | Line exceeds 80 characters; contains 81 characters
    --------------------------------------------------------------------------------------------------------------
    
    
    FILE: /home/system/Documents/contribution/operations/modules/site/src/Event/SiteGetState.php
    --------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------
     15 | ERROR | Missing member variable doc comment
    --------------------------------------------------------------------------------------------
    
    
    FILE: /home/system/Documents/contribution/operations/modules/site/src/SiteDefinitionInterface.php
    -------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------
     8 | WARNING | Line exceeds 80 characters; contains 83 characters
    -------------------------------------------------------------------------------------------------
    
    
    FILE: /home/system/Documents/contribution/operations/modules/site/src/SiteEntityTrait.php
    ---------------------------------------------------------------------------------------------------------
    FOUND 16 ERRORS AND 1 WARNING AFFECTING 16 LINES
    ---------------------------------------------------------------------------------------------------------
      15 | ERROR   | Class property $site_title should use lowerCamel naming without underscores
      22 | ERROR   | Class property $site_uuid should use lowerCamel naming without underscores
      29 | ERROR   | Class property $site_uri should use lowerCamel naming without underscores
      36 | ERROR   | Class property $canonical_uri should use lowerCamel naming without underscores
      43 | ERROR   | Class property $git_remote should use lowerCamel naming without underscores
      50 | ERROR   | Class property $git_reference should use lowerCamel naming without underscores
      57 | ERROR   | Class property $configs_load should use lowerCamel naming without underscores
      63 | WARNING | Line exceeds 80 characters; contains 81 characters
      68 | ERROR   | Class property $configs_allow_override should use lowerCamel naming without underscores
      75 | ERROR   | Class property $states_load should use lowerCamel naming without underscores
      82 | ERROR   | Class property $states_allow_override should use lowerCamel naming without underscores
     103 | ERROR   | Class property $state_factors should use lowerCamel naming without underscores
     119 | ERROR   | Missing short description in doc comment
     120 | ERROR   | Missing parameter comment
     120 | ERROR   | Missing parameter type
     121 | ERROR   | Description for the @return value is missing
     130 | ERROR   | Description for the @return value is missing
    ---------------------------------------------------------------------------------------------------------
    
    
    FILE: /home/system/Documents/contribution/operations/modules/site/site.module
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 4 ERRORS AND 19 WARNINGS AFFECTING 21 LINES
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      97 | WARNING | Code after the RETURN statement on line 92 cannot be executed
      98 | WARNING | Code after the RETURN statement on line 92 cannot be executed
      99 | WARNING | Code after the RETURN statement on line 92 cannot be executed
     100 | WARNING | Code after the RETURN statement on line 92 cannot be executed
     101 | WARNING | Code after the RETURN statement on line 92 cannot be executed
     102 | WARNING | Code after the RETURN statement on line 92 cannot be executed
     105 | WARNING | Code after the RETURN statement on line 92 cannot be executed
     106 | WARNING | Code after the RETURN statement on line 92 cannot be executed
     107 | WARNING | Code after the RETURN statement on line 92 cannot be executed
     108 | WARNING | Code after the RETURN statement on line 92 cannot be executed
     109 | WARNING | Code after the RETURN statement on line 92 cannot be executed
     110 | WARNING | Code after the RETURN statement on line 92 cannot be executed
     112 | WARNING | Code after the RETURN statement on line 92 cannot be executed
     113 | WARNING | Code after the RETURN statement on line 92 cannot be executed
     114 | WARNING | Code after the RETURN statement on line 92 cannot be executed
     115 | WARNING | Code after the RETURN statement on line 92 cannot be executed
     116 | WARNING | Code after the RETURN statement on line 92 cannot be executed
     117 | WARNING | Code after the RETURN statement on line 92 cannot be executed
     122 | 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."
     124 | ERROR   | Missing parameter comment
     124 | ERROR   | Missing parameter type
     126 | ERROR   | If there is no return value for a function, there must not be a @return tag.
     126 | ERROR   | Description for the @return value is missing
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /home/system/Documents/contribution/operations/operations.install
    -----------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------
     3 | ERROR | Missing short description in doc comment
    -----------------------------------------------------------------------
    
    Time: 250ms; Memory: 12MB
    
    
  • Issue was unassigned.
  • Assigned to subhashuyadav
  • 🇺🇸United States Jon Pugh Newburgh, NY
  • First commit to issue fork.
  • Assigned to Neha-Verma
  • 🇺🇸United States Jon Pugh Newburgh, NY

    Please create an issue fork and submit a Merge Request to receive credit for resolving these issues.

  • Issue was unassigned.
  • First commit to issue fork.
  • Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 8
    36:05
    36:05
    Queueing
  • @bharath-kondeti opened merge request.
  • 🇺🇸United States Jon Pugh Newburgh, NY

    2.x is the new branch. Please rebase the MR.

  • Assigned to thakurnishant_06
  • 🇺🇸United States Jon Pugh Newburgh, NY

    In order for this to be accepted, please include changes to automated tests to check for additional violations.

  • Hello Jon Pugh,

    I hope you are doing well. I am currently trying to perform a local rebase, but I am encountering an "invalid reference" error. Could you please provide assistance with this? Alternatively, if it's possible, could you please change the default branch from "1.x" to "2.x"?

    Thank you.

Production build 0.71.5 2024