Drupal Coding Standards Issues | phpcs

Created on 3 February 2023, about 2 years ago
Updated 30 July 2024, 9 months ago

Problem/Motivation

Getting following error/warnings.

FILE: /var/www/html/modules/contrib/field_formatter_filter/tests/README.md
--------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
--------------------------------------------------------------------------
1 | WARNING | Line exceeds 80 characters; contains 97 characters
23 | WARNING | Line exceeds 80 characters; contains 162 characters
--------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/field_formatter_filter/tests/sample-markup.txt
----------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------
2 | WARNING | Line exceeds 80 characters; contains 132 characters
----------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/field_formatter_filter/tests/src/Functional/FieldUiTest.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AND 11 WARNINGS AFFECTING 14 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
5 | WARNING | [x] Unused use statement
6 | WARNING | [x] Unused use statement
7 | WARNING | [x] Unused use statement
8 | WARNING | [x] Unused use statement
57 | WARNING | [ ] Unused variable $entity_type.
59 | WARNING | [ ] Unused variable $view_mode.
95 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
98 | WARNING | [ ] Line exceeds 80 characters; contains 88 characters
98 | ERROR | [x] Perl-style comments are not allowed; use "// Comment" instead
103 | 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
117 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
121 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
151 | ERROR | [ ] Missing parameter comment
151 | ERROR | [ ] Missing parameter type
152 | ERROR | [x] Separate the @param and @return sections by a blank line.
152 | ERROR | [ ] Description for the @return value is missing
----------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/field_formatter_filter/tests/src/Kernel/NodeFilterTest.php
---------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AND 2 WARNINGS AFFECTING 6 LINES
---------------------------------------------------------------------------------------------------
54 | ERROR | [ ] Parameter $values is not described in comment
71 | ERROR | [ ] Missing parameter comment
71 | ERROR | [ ] Doc comment for parameter $bundle does not match actual variable name $values
86 | ERROR | [ ] Missing parameter comment
87 | ERROR | [x] Separate the @param and @return sections by a blank line.
87 | ERROR | [ ] Description for the @return value is missing
99 | WARNING | [ ] Unused variable $validated.
100 | WARNING | [ ] Unused variable $saved.
---------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/field_formatter_filter/tests/src/Kernel/FieldApiTest.php
---------------------------------------------------------------------------------------------------
FOUND 19 ERRORS AND 3 WARNINGS AFFECTING 19 LINES
---------------------------------------------------------------------------------------------------
102 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
103 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
104 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
105 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
106 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
107 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
108 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
109 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
110 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 10
111 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
112 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 6
114 | ERROR | [x] Line indented incorrectly; expected 5 spaces, found 4
160 | ERROR | [ ] Parameter $values is not described in comment
166 | ERROR | [ ] Missing parameter comment
166 | ERROR | [ ] Doc comment for parameter $bundle does not match actual variable name $values
188 | WARNING | [ ] Line exceeds 80 characters; contains 85 characters
200 | ERROR | [ ] Missing parameter comment
200 | ERROR | [ ] Missing parameter type
201 | ERROR | [x] Separate the @param and @return sections by a blank line.
201 | ERROR | [ ] Description for the @return value is missing
213 | WARNING | [ ] Unused variable $validated.
214 | WARNING | [ ] Unused variable $saved.
---------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 13 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/field_formatter_filter/field_formatter_filter.module
----------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
----------------------------------------------------------------------------------------
39 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
69 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
97 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
----------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------

Time: 1.45 secs; Memory: 6MB

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

Proposed resolution

Above error/warnings need to be fixed.

๐Ÿ“Œ Task
Status

Needs work

Version

2.0

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

Comments & Activities

  • Issue created by @samit.310@gmail.com
  • Issue was unassigned.
  • Status changed to Needs review about 2 years ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia samit.310@gmail.com

    Above error/warnings are fixed.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Charchil Khandelwal

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

  • Assigned to Charchil Khandelwal
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Charchil Khandelwal

    I will review this.

  • @charchil-khandelwal opened merge request.
  • Issue was unassigned.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Charchil Khandelwal

    Patch #2 tested and applied clearly, all the errors and warnings are fixed.
    Created MR !2 for this issue.
    Please review.

    Thank You.

  • Status changed to Needs work 9 months ago
  • Hi @Charchil Khandelwal,

    The changes you made on MR!2 that came from the patch #2 still have errors not fixed. Please see below:

    field_formatter_filter git:(2.0.x) curl https://git.drupalcode.org/project/field_formatter_filter/-/merge_requests/2.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 11911    0 11911    0     0  28259      0 --:--:-- --:--:-- --:--:-- 29193
    patching file field_formatter_filter.module
    patching file tests/README.md
    patching file tests/sample-markup.txt
    patching file tests/src/Functional/FieldUiTest.php
    patching file tests/src/Kernel/FieldApiTest.php
    patching file tests/src/Kernel/NodeFilterTest.php
    โžœ  field_formatter_filter git:(2.0.x) โœ— cd ..
    โžœ  contrib git:(master) โœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig field_formatter_filter
    
    FILE: ...b/modules/contrib/field_formatter_filter/tests/src/Kernel/FieldApiTest.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     8 | ERROR | [x] Use statements should be sorted alphabetically. The first
       |       |     wrong one is Drupal\Core\Entity\Entity\EntityViewDisplay.
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    
    FILE: ...9/web/modules/contrib/field_formatter_filter/field_formatter_filter.module
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     13 | ERROR | [x] Use statements should be sorted alphabetically. The first
        |       |     wrong one is Drupal\Component\Utility\Xss.
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    Time: 283ms; Memory: 10MB

    Kindly check

    Thanks,
    Jake

Production build 0.71.5 2024