Drupal Coding Standards Issues | phpcs

Created on 24 January 2023, almost 2 years ago
Updated 13 February 2024, 11 months ago

Problem/Motivation

Getting following error/warnings.

FILE: /var/www/html/modules/contrib/simple_user_management/simple_user_management.module
----------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
----------------------------------------------------------------------------------------
16 | WARNING | [ ] Hook implementations should not duplicate @param documentation
16 | ERROR | [ ] Missing parameter type
18 | WARNING | [ ] Hook implementations should not duplicate @param documentation
18 | ERROR | [x] Expected 1 spaces after parameter type; 2 found
18 | ERROR | [x] Tag value indented incorrectly; expected 1 space but found 2
21 | WARNING | [ ] Hook implementations should not duplicate @return documentation
----------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/simple_user_management/README.txt
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
35 | WARNING | Line exceeds 80 characters; contains 85 characters
38 | WARNING | Line exceeds 80 characters; contains 133 characters
----------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/simple_user_management/src/Form/UserApprovalForm.php
------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
------------------------------------------------------------------------------------------------
29 | WARNING | User::load calls should be avoided in classes, use dependency injection instead
67 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
81 | WARNING | User::load calls should be avoided in classes, use dependency injection instead
89 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/simple_user_management/src/Form/UserDeactivateForm.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 6 WARNINGS AFFECTING 6 LINES
------------------------------------------------------------------------------------------------------------------------------------------
30 | WARNING | User::load calls should be avoided in classes, use dependency injection instead
32 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
89 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
104 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
109 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
130 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
------------------------------------------------------------------------------------------------------------------------------------------

Time: 2.13 secs; Memory: 4MB

Steps to reproduce

Run following command

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

Proposed resolution

Above error/warnings need to be fixed.

🐛 Bug report
Status

Fixed

Version

1.5

Component

Code

Created by

🇮🇳India samit.310@gmail.com

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

Production build 0.71.5 2024