Drupal Coding Standards Issues | phpcs

Created on 22 December 2022, over 1 year ago
Updated 18 January 2023, over 1 year ago

Problem/Motivation

Getting following error/warnings

FILE: /app/modules/contrib/collapsiblock/collapsiblock.info.yml
-----------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------
1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
-----------------------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/collapsiblock/collapsiblock.module
-------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-------------------------------------------------------------------------------------
15 | WARNING | Global constants should not be used, move it to a class or interface
-------------------------------------------------------------------------------------

FILE: /app/modules/contrib/collapsiblock/src/Form/CollapsiblockGlobalSettings.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 5 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
12 | WARNING | The class short comment should describe what the class does and not simply repeat the class name
47 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
53 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
69 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
71 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/collapsiblock/tests/src/Functional/BlockInstanceTest.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------
58 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/collapsiblock/tests/src/Functional/GlobalConfigurationTest.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------
68 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------

Time: 380ms; Memory: 12MB

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/collapsiblock/

Proposed resolution

Above error/warnings need to be fixed

Note:

I have removed COLLAPSIBLOCK_ACTION_OPTIONS constant variable in collapsiblock.module file, as it is not used any where. Code is following. Please let me know if it required.

// Scalar (JSON) constant for php 5.*.
define('COLLAPSIBLOCK_ACTION_OPTIONS', serialize([
  1 => t('None.'),
  2 => t('Collapsible, expanded by default.'),
  3 => t('Collapsible, collapsed by default.'),
  5 => t('Collapsible, expanded all the time.'),
  4 => t('Collapsible, collapsed all the time.'),
]));
🐛 Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

🇮🇳India samit.310@gmail.com

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.

  • Status changed to Needs review over 1 year ago
  • Assigned to Sonal Gyanani
  • Issue was unassigned.
  • Status changed to RTBC over 1 year ago
  • Status changed to Fixed over 1 year ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024