Fix the issues reported by phpcs

Created on 10 November 2021, over 2 years ago
Updated 14 March 2024, 3 months ago

Steps to reproduce

phpcs --standard="Drupal,DrupalPractice" --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml .
FILE: C:\xampp7\htdocs\drupal-9.2.1\modules\contrib\memcache_storage\memcache_storage.install
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
  27 | ERROR   | The array declaration extends to column 118 (the limit is 80). The array content should be split up over multiple lines
  30 | WARNING | Avoid backslash escaping in translatable strings when possible, use "" quotes instead
 105 | ERROR   | The array declaration extends to column 97 (the limit is 80). The array content should be split up over multiple lines
-----------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp7\htdocs\drupal-9.2.1\modules\contrib\memcache_storage\memcache_storage.module
--------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 2 WARNINGS AFFECTING 3 LINES
--------------------------------------------------------------------------------------------
 4 | ERROR   | [x] The second line in the file doc comment must be "@file"
 6 | WARNING | [ ] Global constants should not be used, move it to a class or interface
 7 | WARNING | [ ] Global constants should not be used, move it to a class or interface
--------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------


FILE: C:\xampp7\htdocs\drupal-9.2.1\modules\contrib\memcache_storage\README.txt
-------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
-------------------------------------------------------------------------------
 12 | WARNING | Line exceeds 80 characters; contains 84 characters
 13 | WARNING | Line exceeds 80 characters; contains 82 characters
-------------------------------------------------------------------------------


FILE: C:\xampp7\htdocs\drupal-9.2.1\modules\contrib\memcache_storage\src\Controller\MemcachedStatistics.php
---------------------------------------------------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AND 9 WARNINGS AFFECTING 13 LINES
---------------------------------------------------------------------------------------------------------------------------------------------
  8 | ERROR   | [x] There must be one blank line after the last USE statement; 2 found;
 11 | ERROR   | [x] Missing class doc comment
 13 | ERROR   | [x] Missing function doc comment
 26 | WARNING | [x] 'TODO: Switch to services.' should match the format '@todo Fix problem X here.'
 36 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 37 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 37 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 37 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 38 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 56 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 57 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 70 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 74 | ERROR   | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
 77 | ERROR   | [x] Expected 1 blank line after function; 0 found
 78 | ERROR   | [x] The closing brace for the class must have an empty line before it
---------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp7\htdocs\drupal-9.2.1\modules\contrib\memcache_storage\src\DrupalMemcache.php
------------------------------------------------------------------------------------------------------
FOUND 9 ERRORS AFFECTING 9 LINES
------------------------------------------------------------------------------------------------------
  8 | ERROR | [x] Doc comment short description must end with a full stop
 25 | ERROR | [x] There must be exactly one blank line before the tags in a doc comment
 27 | ERROR | [ ] The @var tag must be the first tag in a member variable comment
 33 | ERROR | [x] There must be exactly one blank line before the tags in a doc comment
 35 | ERROR | [ ] The @var tag must be the first tag in a member variable comment
 41 | ERROR | [x] There must be exactly one blank line before the tags in a doc comment
 43 | ERROR | [ ] The @var tag must be the first tag in a member variable comment
 47 | ERROR | [ ] Missing short description in doc comment
 48 | ERROR | [x] Expected "\Memcache" but found "\Memcache." for @var tag in member variable comment
------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------


FILE: C:\xampp7\htdocs\drupal-9.2.1\modules\contrib\memcache_storage\src\DrupalMemcached.php
----------------------------------------------------------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 4 LINES
----------------------------------------------------------------------------------------------------------------------
  8 | ERROR | [x] Doc comment short description must end with a full stop
 39 | ERROR | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
 51 | ERROR | [x] Expected "\Memcached" but found "\Memcached." for @var tag in member variable comment
 63 | ERROR | [x] Expected 1 space after "?"; 2 found
----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp7\htdocs\drupal-9.2.1\modules\contrib\memcache_storage\src\DrupalMemcachedBase.php
-----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 17 ERRORS AND 1 WARNING AFFECTING 16 LINES
-----------------------------------------------------------------------------------------------------------------------------------------------
   8 | ERROR   | [x] Doc comment short description must end with a full stop
  17 | ERROR   | [ ] Missing short description in doc comment
  18 | ERROR   | [x] Expected "\Memcachedor\Memcacheobject" but found "\Memcached or \Memcache object" for @var tag in member variable comment
  39 | ERROR   | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
  47 | ERROR   | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
  91 | ERROR   | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
  95 | ERROR   | [ ] Class property $bin_indexes should use lowerCamel naming without underscores
 174 | ERROR   | [ ] sizeof() is a function name alias, use count() instead
 174 | ERROR   | [ ] sizeof() is a function name alias, use count() instead
 231 | ERROR   | [ ] Missing parameter type
 234 | ERROR   | [ ] Parameter tags must be grouped together in a doc comment
 234 | ERROR   | [ ] Missing parameter type
 261 | ERROR   | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
 263 | ERROR   | [ ] Missing parameter type
 270 | WARNING | [x] 'TODO: Lock this operation to avoid race conditions?' should match the format '@todo Fix problem X here.'
 288 | ERROR   | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
 290 | ERROR   | [ ] Missing parameter type
 310 | ERROR   | [x] Comments may not appear after statements
-----------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp7\htdocs\drupal-9.2.1\modules\contrib\memcache_storage\src\DrupalMemcachedDebug.php
-------------------------------------------------------------------------------------------------------------------------
FOUND 22 ERRORS AND 3 WARNINGS AFFECTING 21 LINES
-------------------------------------------------------------------------------------------------------------------------
   8 | ERROR   | [x] Doc comment short description must end with a full stop
   9 | ERROR   | [x] There must be exactly one blank line before the tags in a doc comment
  10 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
  29 | ERROR   | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
  31 | ERROR   | [ ] Description for the @return value is missing
  45 | ERROR   | [x] Equals sign not aligned with surrounding assignments; expected 1 space but found 2 spaces
  53 | ERROR   | [x] Expected 1 space before "-"; 0 found
  53 | ERROR   | [x] Expected 1 space after "-"; 0 found
  54 | ERROR   | [x] Expected 1 space before "-"; 0 found
  54 | ERROR   | [x] Expected 1 space after "-"; 0 found
  55 | ERROR   | [x] Expected 1 space before "-"; 0 found
  55 | ERROR   | [x] Expected 1 space after "-"; 0 found
  64 | ERROR   | [x] Concat operator must be surrounded by a single space
  64 | ERROR   | [x] Expected 1 space before "/"; 2 found
  74 | WARNING | [x] A comma should follow the last multiline array item. Found: )
  84 | ERROR   | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
  86 | ERROR   | [ ] Description for the @return value is missing
 112 | WARNING | [x] A comma should follow the last multiline array item. Found: )
 129 | ERROR   | [ ] Missing short description in doc comment
 130 | ERROR   | [ ] Missing parameter type
 133 | ERROR   | [ ] Missing parameter type
 136 | ERROR   | [ ] Missing parameter type
 140 | ERROR   | [ ] Missing parameter type
 143 | ERROR   | [ ] Missing parameter type
 150 | ERROR   | [ ] sizeof() is a function name alias, use count() instead
-------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 13 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp7\htdocs\drupal-9.2.1\modules\contrib\memcache_storage\src\DrupalMemcachedFactory.php
-------------------------------------------------------------------------------------------------------------------------------------------
FOUND 9 ERRORS AND 1 WARNING AFFECTING 8 LINES
-------------------------------------------------------------------------------------------------------------------------------------------
  7 | ERROR   | [ ] Class name doesn't match filename; expected "class DrupalMemcachedFactory"
  7 | ERROR   | [x] Missing class doc comment
  7 | ERROR   | [ ] Closing class brace must be on a line by itself
  9 | ERROR   | [x] Missing class doc comment
 20 | ERROR   | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
 31 | ERROR   | [ ] Class property $bins_clusters should use lowerCamel naming without underscores
 52 | ERROR   | [ ] The array declaration extends to column 96 (the limit is 80). The array content should be split up over multiple lines
 67 | ERROR   | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
 69 | ERROR   | [ ] Missing parameter type
 84 | WARNING | [x] 'TODO: Switch to services.' should match the format '@todo Fix problem X here.'
-------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp7\htdocs\drupal-9.2.1\modules\contrib\memcache_storage\src\DrupalMemcachedInterface.php
-----------------------------------------------------------------------------------------------------
FOUND 20 ERRORS AFFECTING 17 LINES
-----------------------------------------------------------------------------------------------------
   5 | ERROR | [x] Missing interface doc comment
  13 | ERROR | [ ] Parameter tags must be grouped together in a doc comment
  13 | ERROR | [ ] Missing parameter type
  19 | ERROR | [ ] Missing short description in doc comment
  20 | ERROR | [ ] Missing parameter type
  31 | ERROR | [ ] Missing parameter type
  37 | ERROR | [ ] Parameter tags must be grouped together in a doc comment
  37 | ERROR | [ ] Missing parameter type
  54 | ERROR | [ ] Missing parameter type
  57 | ERROR | [ ] Parameter tags must be grouped together in a doc comment
  57 | ERROR | [ ] Missing parameter type
  60 | ERROR | [ ] Parameter tags must be grouped together in a doc comment
  64 | ERROR | [ ] Parameter tags must be grouped together in a doc comment
  75 | ERROR | [ ] Parameter tags must be grouped together in a doc comment
  83 | ERROR | [ ] Missing parameter type
  86 | ERROR | [ ] Parameter tags must be grouped together in a doc comment
 100 | ERROR | [ ] Parameter tags must be grouped together in a doc comment
 111 | ERROR | [ ] Missing parameter type
 114 | ERROR | [ ] Parameter tags must be grouped together in a doc comment
 125 | ERROR | [ ] Parameter tags must be grouped together in a doc comment
-----------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------


FILE: C:\xampp7\htdocs\drupal-9.2.1\modules\contrib\memcache_storage\src\DrupalMemcachedUtils.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 14 ERRORS AFFECTING 10 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
  7 | ERROR | [x] Missing class doc comment
 12 | ERROR | [x] Missing parameter type
 62 | ERROR | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
 64 | ERROR | [ ] Missing parameter type
 67 | ERROR | [ ] Parameter tags must be grouped together in a doc comment
 67 | ERROR | [ ] Missing parameter type
 70 | ERROR | [ ] Parameter tags must be grouped together in a doc comment
 70 | ERROR | [ ] Missing parameter type
 74 | ERROR | [ ] The array declaration extends to column 95 (the limit is 80). The array content should be split up over multiple lines
 80 | ERROR | [ ] Missing parameter type
 83 | ERROR | [ ] Parameter tags must be grouped together in a doc comment
 83 | ERROR | [ ] Missing parameter type
 86 | ERROR | [ ] Parameter tags must be grouped together in a doc comment
 86 | ERROR | [ ] Missing parameter type
-----------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp7\htdocs\drupal-9.2.1\modules\contrib\memcache_storage\src\MemcachedBackend.php
-------------------------------------------------------------------------------------------------------------------------
FOUND 8 ERRORS AND 1 WARNING AFFECTING 9 LINES
-------------------------------------------------------------------------------------------------------------------------
  12 | ERROR   | [x] Missing class doc comment
  23 | ERROR   | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
  53 | ERROR   | [ ] Missing parameter type
  56 | ERROR   | [ ] Parameter tags must be grouped together in a doc comment
  60 | ERROR   | [ ] Parameter tags must be grouped together in a doc comment
  63 | ERROR   | [ ] Parameter tags must be grouped together in a doc comment
  66 | ERROR   | [ ] Parameter tags must be grouped together in a doc comment
 133 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
 231 | ERROR   | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
-------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp7\htdocs\drupal-9.2.1\modules\contrib\memcache_storage\src\MemcachedBackendFactory.php
---------------------------------------------------------------------------------------------------------
FOUND 10 ERRORS AFFECTING 9 LINES
---------------------------------------------------------------------------------------------------------
  9 | ERROR | [x] Missing class doc comment
 11 | ERROR | [ ] Missing short description in doc comment
 16 | ERROR | [ ] Missing short description in doc comment
 21 | ERROR | [ ] Missing short description in doc comment
 36 | ERROR | [ ] Missing parameter comment
 37 | ERROR | [ ] Missing parameter comment
 37 | ERROR | [ ] Doc comment for parameter $memcached_factory does not match actual variable name $time
 38 | ERROR | [ ] Missing parameter comment
 42 | ERROR | [x] Visibility must be declared on method "__construct"
 52 | ERROR | [ ] Missing parameter type
---------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------

Time: 4.74 secs; Memory: 10MB

๐Ÿ“Œ Task
Status

Needs work

Version

2.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia Rajeshreeputra Pune

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

Not all content is available!

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

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    The issue summary should always describe what the issue is trying to fix and, in the case, of coding standards issues, show which command has been used, which arguments have been used, and which report that command shown.

  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia imustakim Ahmedabad

    Issue summary updated.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    -  if (empty($pecl_extension) || !class_exists($pecl_extension) || !in_array($pecl_extension, ['Memcache', 'Memcached'])) {
    +  if (empty($pecl_extension) || !class_exists($pecl_extension) || !in_array($pecl_extension, [
    +    'Memcache',
    +    'Memcached',
    +  ])) {

    Control structure conditions may exceed 80 characters, if they are simple to read and understand โ†’ . In this case, the code is more readable as it is.

         $requirements['memcache_storage_cluster_' . $memcached_server]['title'] =
           t('Memcache Storage: %cluster cluster (%server)',
    -        ['%server' => Html::escape($memcached_server), '%cluster' => Html::escape($cluster_name)]);
    +        [
    +          '%server' => Html::escape($memcached_server),
    +          '%cluster' => Html::escape($cluster_name),
    +        ]);

    Even in this case, the code is more readable as it is.

     /**
    - * Constant definitions.
    + * @file
    + * Provides integration between Drupal and Memcached daemon.
      */

    The short description for a module is Hook implementations for the [module name] module. where [module name] is indeed replaced by the module name (not its machine name).

    +/**
    + * The MemcachedStatistics class.
    + *
    + * @package Drupal\memcache_storage
    + */
     class MemcachedStatistics extends ControllerBase {

    The class short description must not repeat the class name.

    +  /**
    +   * Builds the content.
    +   *
    +   * @return array
    +   *   Returns an array $build.
    +   */
       public function content() {

    The return value description must not start with Returns (nor Return). It must not contain any variable name.

     /**
    - * Class DrupalMemcache
    + * Class DrupalMemcache.
      *
    - *  * Contains integration for Drupal & PECL Memcache extension.
    + * Contains integration for Drupal & PECL Memcache extension.
      *
      * @package Drupal\memcache_storage
      */

    The short description must not contain the class name nor start with Class.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Yashaswi18

    Created a patch by addressing the above comments. Please review.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Shank115

    I tested the patch, it applies cleanly.

    Checking patch README.txt...
    Checking patch css/memcache-storage.css...
    Checking patch memcache_storage.install...
    Checking patch memcache_storage.links.menu.yml...
    Checking patch memcache_storage.module...
    Checking patch src/Controller/MemcachedStatistics.php...
    Checking patch src/DrupalMemcache.php...
    Checking patch src/DrupalMemcached.php...
    Checking patch src/DrupalMemcachedBase.php...
    Checking patch src/DrupalMemcachedDebug.php...
    Checking patch src/DrupalMemcachedFactory.php...
    Checking patch src/DrupalMemcachedInterface.php...
    Checking patch src/DrupalMemcachedUtils.php...
    Checking patch src/MemcachedBackend.php...
    Checking patch src/MemcachedBackendFactory.php...
    Applied patch README.txt cleanly.
    Applied patch css/memcache-storage.css cleanly.
    Applied patch memcache_storage.install cleanly.
    Applied patch memcache_storage.links.menu.yml cleanly.
    Applied patch memcache_storage.module cleanly.
    Applied patch src/Controller/MemcachedStatistics.php cleanly.
    Applied patch src/DrupalMemcache.php cleanly.
    Applied patch src/DrupalMemcached.php cleanly.
    Applied patch src/DrupalMemcachedBase.php cleanly.
    Applied patch src/DrupalMemcachedDebug.php cleanly.
    Applied patch src/DrupalMemcachedFactory.php cleanly.
    Applied patch src/DrupalMemcachedInterface.php cleanly.
    Applied patch src/DrupalMemcachedUtils.php cleanly.
    Applied patch src/MemcachedBackend.php cleanly.
    Applied patch src/MemcachedBackendFactory.php cleanly.
    
  • First commit to issue fork.
  • Assigned to nitin_lama
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama

    Providing updated patch.

  • Merge request !14#3248598: MR for the changes. โ†’ (Open) created by nitin_lama
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama

    Please review. Thanks.

  • Issue was unassigned.
  • Status changed to Needs review 3 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Preethy_ray

    pray_12 โ†’ made their first commit to this issueโ€™s fork.

  • Status changed to Needs work 3 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Preethy_ray

    Hi,
    Remaining errors and warnings that need to be addressed are:

    FILE: /memcache_storage/memcache_storage.install
    ---------------------------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    ---------------------------------------------------------------------------------------------------------------------------------------
      27 | ERROR | The array declaration extends to column 118 (the limit is 80). The array content should be split up over multiple lines
     107 | ERROR | The array declaration extends to column 97 (the limit is 80). The array content should be split up over multiple lines
    ---------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /memcache_storage/memcache_storage.module
    ----------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    ----------------------------------------------------------------------------------------------------
     8 | WARNING | Global constants should not be used, move it to a class or interface
     9 | WARNING | Global constants should not be used, move it to a class or interface
    ----------------------------------------------------------------------------------------------------
    
  • Pipeline finished with Failed
    3 months ago
    Total: 144s
    #119216
Production build 0.69.0 2024