Fix the issues reported by phpcs

Created on 21 April 2023, about 1 year ago
Updated 11 June 2024, 16 days ago

vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig web/modules/contrib/views_add_button/

FILE: /var/www/html/drupalvb/web/modules/contrib/views_add_button/src/ViewsAddButtonUtilities.php
---------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 4 WARNINGS AFFECTING 7 LINES
---------------------------------------------------------------------------------------------------------------------
6 | WARNING | [x] Unused use statement
7 | WARNING | [x] Unused use statement
9 | WARNING | [x] Unused use statement
12 | ERROR | [x] Doc comment short description must end with a full stop
13 | ERROR | [x] There must be exactly one blank line before the tags in a doc comment
14 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
74 | ERROR | [x] Expected 1 newline at end of file; 0 found
---------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/drupalvb/web/modules/contrib/views_add_button/src/Controller/ViewsAddButtonController.php
-------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------
23 | ERROR | Class property $ViewsAddButtonManager should use lowerCamel naming without underscores
-------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/drupalvb/web/modules/contrib/views_add_button/src/Plugin/views/field/ViewsAddButtonField.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 10 ERRORS AND 22 WARNINGS AFFECTING 31 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
47 | ERROR | [ ] The array declaration extends to column 87 (the limit is 80). The array content should be split up over multiple lines
47 | ERROR | [ ] The array declaration extends to column 86 (the limit is 80). The array content should be split up over multiple lines
65 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
74 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
75 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
84 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
85 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
94 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
95 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
102 | 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
109 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
110 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
116 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
122 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
123 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
131 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
132 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
140 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
141 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
149 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
150 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
158 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
159 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
196 | ERROR | [x] Missing function doc comment
227 | ERROR | [x] Use null coalesce operator instead of ternary operator.
274 | ERROR | [x] Expected one space after the comma, 0 found
278 | ERROR | [x] Expected one space after the comma, 0 found
294 | ERROR | [x] Expected one space after the comma, 0 found
301 | ERROR | [x] Expected one space after the comma, 0 found
317 | ERROR | [x] Expected one space after the comma, 0 found
322 | ERROR | [x] Expected one space after the comma, 0 found
----------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/drupalvb/web/modules/contrib/views_add_button/src/Plugin/views/ViewsAddButtonTrait.php
----------------------------------------------------------------------------------------------------------
FOUND 8 ERRORS AFFECTING 8 LINES
----------------------------------------------------------------------------------------------------------
5 | ERROR | [x] Missing trait doc comment
7 | ERROR | [x] Missing function doc comment
9 | ERROR | [x] Line indented incorrectly; expected 5 spaces, found 7
10 | ERROR | [x] Line indented incorrectly; expected 5 spaces, found 7
11 | ERROR | [x] Line indented incorrectly; expected 5 spaces, found 7
12 | ERROR | [x] Line indented incorrectly; expected 5 spaces, found 7
17 | ERROR | [x] Missing function doc comment
41 | ERROR | [x] Expected 1 newline at end of file; 0 found
----------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------

FILE: /var/www/html/drupalvb/web/modules/contrib/views_add_button/src/Plugin/views/area/ViewsAddButtonArea.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AND 27 WARNINGS AFFECTING 30 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
5 | WARNING | [x] Unused use statement
9 | WARNING | [x] Unused use statement
49 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
105 | ERROR | [ ] The array declaration extends to column 87 (the limit is 80). The array content should be split up over multiple lines
105 | ERROR | [ ] The array declaration extends to column 86 (the limit is 80). The array content should be split up over multiple lines
121 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
130 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
131 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
140 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
141 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
150 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
151 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
158 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
159 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
165 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
166 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
173 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
179 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
180 | 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
189 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
197 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
198 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
206 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
207 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
215 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
222 | ERROR | [x] Missing function doc comment
253 | ERROR | [x] Use null coalesce operator instead of ternary operator.
291 | ERROR | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
331 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
331 | WARNING | [ ] Only string literals should be passed to t() where possible
335 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
----------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/drupalvb/web/modules/contrib/views_add_button/src/Plugin/views_add_button/ViewsAddButtonDefault.php
-----------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-----------------------------------------------------------------------------------------------------------------------
67 | ERROR | [ ] Missing parameter type
69 | ERROR | [x] Data types in @param tags need to be fully namespaced
-----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/drupalvb/web/modules/contrib/views_add_button/src/Plugin/views_add_button/ViewsAddButtonNode.php
--------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------
38 | ERROR | [x] Parameter comment must end with a full stop
--------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/drupalvb/web/modules/contrib/views_add_button/src/Plugin/views_add_button/ViewsAddButtonTaxonomy.php
------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------
38 | ERROR | [x] Parameter comment must end with a full stop
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/drupalvb/web/modules/contrib/views_add_button/src/Plugin/views_add_button/ViewsAddButtonUser.php
--------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------
38 | ERROR | [x] Parameter comment must end with a full stop
--------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/drupalvb/web/modules/contrib/views_add_button/views_add_button.info.yml
-------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------
1 | WARNING | Remove "project" from the info file, it will be added by drupal.org packaging automatically
1 | WARNING | Remove "datestamp" from the info file, it will be added by drupal.org packaging automatically
1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
-------------------------------------------------------------------------------------------------------------

Time: 1.44 secs; Memory: 14MB

๐Ÿ“Œ Task
Status

Closed: outdated

Version

1.0

Component

Code: General

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia dineshkumarbollu

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

  • Issue created by @dineshkumarbollu
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Nishant

    @dineshkumarbollu I have applied your patch and most of error was fixed but I got one error that I have fixed and sharing patch.
    Module version - 8.x-1.x-dev.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    I am reviewing the patch in comment #2.

     /**
    - * Class ViewsAddButtonController.
    + * Defines ViewsAddButtonController class.
      *
      * Provides the route and API controller for views_add_button.
      *

    Just use the existing short description. The added one just reports the class name.

    +/**
    + * {@inheritdoc}
    + */
     trait ViewsAddButtonTrait {

    {@inheritdoc} is not used as document comment for a class, a trait, not an interface.

    +  /**
    +   * {@inheritdoc}
    +   */
       public function getQueryString($values = NULL) {

    {@inheritdoc} cannot be used for a method defined in a trait that does not have any parent class, nor does it implement an interface.

     /**
    - * Class ViewsAddButtonUtilities
    + * Defines ViewsAddButtonUtilities class.
    + *

    It is not sufficient to report the class name in the documentation comment for a class.

     # Information added by Drupal.org packaging script on 2021-02-25
    -version: '8.x-1.7'
    -project: 'views_add_button'
    -datestamp: 1614239756
    

    Also the comment needs to be removed.

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

    I have updated the patch with fixes.
    please review.

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    +  /**
    +   * Function of Views Add Button Cleanup Special Characters.
    +   */
       public function viewsAddButtonCleanupSpecialCharacters($str = '') {

    The description does not describe the method purpose.
    The parameter and the return value descriptions are missing.

       public function viewsAddButtonCleanupSpecialCharacters($str = '') {
         /*
    -       * Perform bracket and special character replacement.
    -       * For security reasons, we are not opening this to most characters.
    -       * @see https://www.drupal.org/project/views_add_button/issues/3095849
    -       */
    +     * Perform bracket and special character replacement.
    +     * For security reasons, we are not opening this to most characters.
    +     * @see https://www.drupal.org/project/views_add_button/issues/3095849
    +     */
         $replace = ['%5B' => '[', '%5D' => ']', '&' => '&'];

    Inside a function/method, the comment delimiter used is //.

    -      $text = t($text);
    +      $text = $this->t('@text', ['@text' => $text]);

    Those lines are not equivalent, since t($text) could translate the content of $text, but $this->t('@text', ['@text' => $text]) does not translate the content of $text. t($text) is allowed, under some conditions, which PHP_CodeSniffer is not able to verify.

    -   *   Entity context string
    +   *   Entity context string.

    A definite article is missing.

     /**
    - * Class ViewsAddButtonUtilities
    + * Class to provide functionality for ViewsAddButtonUtilities.
    + *
      * @package Drupal\views_add_button
      */
     class ViewsAddButtonUtilities {

    No, ViewsAddButtonUtilities does not provide functionality for ViewsAddButtonUtilities.

    (Then, changing the code to follow the Drupal coding standards is a task, not a bug.)

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia AkashKumar07

    This patch addresses the first 3 points of #7 and also removes the whitespace errors.
    Thanks!

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    +   /**
    +-   * Function of Views Add Button Cleanup Special Characters.
    ++   * Function to cleanup special characters from query string.
    ++   *
    ++   * @param string $str
    ++   *   The query string.
    ++   *
    ++   * @return string
    ++   *   The query string after cleanup.
    +    */
    +   public function viewsAddButtonCleanupSpecialCharacters($str = '') {
    +-    /*
    +-     * Perform bracket and special character replacement.
    +-     * For security reasons, we are not opening this to most characters.
    +-     * @see https://www.drupal.org/project/views_add_button/issues/3095849
    +-     */
    ++    // Perform bracket and special character replacement.
    ++    // For security reasons, we are not opening this to most characters.
    ++    // @see https://www.drupal.org/project/views_add_button/issues/3095849
    +     $replace = ['%5B' => '[', '%5D' => ']', '&' => '&'];
    +     return strtr($str, $replace);

    The patch adds plus and minus characters on random lines.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia AkashKumar07

    I have updated my last patch. Thanks!

  • Status changed to Needs review 5 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia dev16.addweb

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

  • Merge request !6Fixed phpcs issues. โ†’ (Open) created by Unnamed author
  • Status changed to RTBC 17 days ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia dev16.addweb

    I've tested patch #10, and no phpcs error/warning was found. I Also raised MR for the same.

    Thanks

  • Status changed to Closed: outdated 16 days ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    The 8.x-1.x branch is no longer supported. Issues like this needs to be opened for the 2.0.x branch.

Production build 0.69.0 2024