Coding standards and best practices

Created on 9 December 2022, over 2 years ago
Updated 26 January 2023, over 2 years ago

Hi, While reviewing the module for best practices and standards. I have found this with the help of PHPCS and fixed it:

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

FILE: /var/www/html/dContri/gin_login/gin_login.module
-----------------------------------------------------------------------------
FOUND 4 ERRORS AND 3 WARNINGS AFFECTING 6 LINES
-----------------------------------------------------------------------------
 170 | ERROR   | [ ] Comment indentation error, expected only 1 spaces
 173 | WARNING | [ ] Line exceeds 80 characters; contains 101 characters
 173 | ERROR   | [ ] Comment indentation error, expected only 1 spaces
 175 | ERROR   | [ ] Comment indentation error, expected only 3 spaces
 179 | WARNING | [ ] There must be no blank line following an inline comment
 190 | WARNING | [ ] Unused variable $darkmode.
 215 | ERROR   | [x] Expected newline after closing brace
-----------------------------------------------------------------------------


FILE: /var/www/html/dContri/gin_login/src/Form/GinLoginConfigurationForm.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 14 WARNINGS AFFECTING 14 LINES
------------------------------------------------------------------------------------------------------------------------------------------
  38 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  43 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  59 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  64 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  66 | 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
  81 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  96 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 101 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 103 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/dContri/gin_login/src/Theme/ThemeNegotiator.php
----------------------------------------------------------------------------------------------------------------------------------
FOUND 14 ERRORS AND 1 WARNING AFFECTING 11 LINES
----------------------------------------------------------------------------------------------------------------------------------
 11 | WARNING | [ ] Line exceeds 80 characters; contains 88 characters
 11 | ERROR   | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
 15 | ERROR   | [x] The open comment tag must be the only content on the line
 15 | ERROR   | [ ] Missing short description in doc comment
 15 | ERROR   | [x] Data types in @var tags need to be fully namespaced
 15 | ERROR   | [x] Expected "ConfigFactoryInterface" but found "ConfigFactoryInterface " for @var tag in member variable comment
 18 | ERROR   | [x] Missing function doc comment
 24 | ERROR   | [ ] Missing short description in doc comment
 25 | ERROR   | [ ] Missing parameter comment
 26 | ERROR   | [ ] Description for the @return value is missing
 32 | ERROR   | [ ] Missing short description in doc comment
 33 | ERROR   | [ ] Missing parameter comment
 34 | ERROR   | [ ] Description for the @return value is missing
 43 | ERROR   | [ ] Missing parameter comment
 45 | ERROR   | [ ] Description for the @return value is missing
----------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/dContri/gin_login/dist/css/login.css
--------------------------------------------------------------------------
FOUND 7 ERRORS AFFECTING 7 LINES
--------------------------------------------------------------------------
  72 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 10
  74 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 10
  76 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 10
  78 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 10
 101 | ERROR | [x] Multiple selectors should each be on a single line
 104 | ERROR | [x] Multiple selectors should each be on a single line
 108 | ERROR | [x] Multiple selectors should each be on a single line
--------------------------------------------------------------------------

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇮🇳India akshay.singh Noida

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024