[meta] Drupal 8/9 Coding Standards

Created on 24 September 2022, about 2 years ago
Updated 31 August 2024, 4 months ago

Drupal Coding Standards

Following are the issues :-

FILE: /home/sagar/Downloads/fivestar-8.x-1.0-alpha2/fivestar/src/VoteResultManager.php
--------------------------------------------------------------------------------------
FOUND 6 ERRORS AFFECTING 6 LINES
--------------------------------------------------------------------------------------
 33 | ERROR | Missing parameter comment
 34 | ERROR | Missing parameter comment
 36 | ERROR | Description for the @return value is missing
 50 | ERROR | Missing parameter comment
 52 | ERROR | Description for the @return value is missing
 85 | ERROR | Missing parameter comment
--------------------------------------------------------------------------------------


FILE: /home/sagar/Downloads/fivestar-8.x-1.0-alpha2/fivestar/src/Element/Fivestar.php
-------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-------------------------------------------------------------------------------------
 203 | ERROR | Description for the @return value is missing
 257 | ERROR | Description for the @return value is missing
-------------------------------------------------------------------------------------


FILE: /home/sagar/Downloads/fivestar-8.x-1.0-alpha2/fivestar/src/Plugin/Field/FieldWidget/StarsWidget.php
---------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------
 44 | WARNING | Line exceeds 80 characters; contains 104 characters
---------------------------------------------------------------------------------------------------------


FILE: /home/sagar/Downloads/fivestar-8.x-1.0-alpha2/fivestar/src/Plugin/Field/FieldFormatter/RatingFormatter.php
----------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------
 36 | WARNING | Unused variable $delta.
----------------------------------------------------------------------------------------------------------------


FILE: /home/sagar/Downloads/fivestar-8.x-1.0-alpha2/fivestar/src/Plugin/Field/FieldFormatter/FivestarFormatterBase.php
----------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------
 82 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------------------------------


FILE: /home/sagar/Downloads/fivestar-8.x-1.0-alpha2/fivestar/src/Plugin/Field/FieldFormatter/PercentageFormatter.php
--------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------
 36 | WARNING | Unused variable $delta.
--------------------------------------------------------------------------------------------------------------------


FILE: /home/sagar/Downloads/fivestar-8.x-1.0-alpha2/fivestar/src/Plugin/Field/FieldType/FivestarItem.php
--------------------------------------------------------------------------------------------------------
FOUND 4 ERRORS AND 2 WARNINGS AFFECTING 6 LINES
--------------------------------------------------------------------------------------------------------
 147 | WARNING | [ ] #options values usually have to run through t() for translation
 148 | WARNING | [ ] #options values usually have to run through t() for translation
 290 | ERROR   | [ ] Missing parameter comment
 291 | ERROR   | [ ] Missing parameter comment
 293 | ERROR   | [ ] Description for the @return value is missing
 369 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 6
--------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------


FILE: /home/sagar/Downloads/fivestar-8.x-1.0-alpha2/fivestar/src/VoteManager.php
--------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
--------------------------------------------------------------------------------
 70 | ERROR | Missing parameter comment
 71 | ERROR | Missing parameter comment
 72 | ERROR | Missing parameter comment
 73 | ERROR | Missing parameter comment
 75 | ERROR | Description for the @return value is missing
--------------------------------------------------------------------------------

Time: 339ms; Memory: 12MB
📌 Task
Status

Closed: outdated

Version

1.0

Component

Code

Created by

🇮🇳India sagar25

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.

  • 🇮🇳India ayush.khare

    Fixed #2.

  • Status changed to Needs work almost 2 years ago
  • 🇮🇳India Charchil Khandelwal

    The patch #6 has been reviewed and applied cleanly, but there are some errors and warnings.

    FILE: ...p\htdocs\abc\drupal\modules\fivestar\includes\fivestar.theme.inc
    ----------------------------------------------------------------------
    FOUND 2 ERRORS AND 2 WARNINGS AFFECTING 4 LINES
    ----------------------------------------------------------------------
    1 | ERROR | [x] End of line character is invalid; expected "\n"
    | | but found "\r\n"
    8 | WARNING | [x] Unused use statement
    9 | WARNING | [x] Unused use statement
    11 | ERROR | [ ] Doc comment is empty
    ----------------------------------------------------------------------
    PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------

    FILE: ...ampp\htdocs\abc\drupal\modules\fivestar\src\Element\Fivestar.php
    ----------------------------------------------------------------------
    FOUND 7 ERRORS AFFECTING 7 LINES
    ----------------------------------------------------------------------
    1 | ERROR | [x] End of line character is invalid; expected "\n"
    | | but found "\r\n"
    96 | ERROR | [x] Use null coalesce operator instead of ternary
    | | operator.
    152 | ERROR | [x] Use null coalesce operator instead of ternary
    | | operator.
    153 | ERROR | [x] Use null coalesce operator instead of ternary
    | | operator.
    213 | ERROR | [x] Use null coalesce operator instead of ternary
    | | operator.
    268 | ERROR | [x] Use null coalesce operator instead of ternary
    | | operator.
    269 | ERROR | [x] Use null coalesce operator instead of ternary
    | | operator.
    ----------------------------------------------------------------------
    PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------

    FILE: ...vestar\src\Plugin\Field\FieldFormatter\FivestarFormatterBase.php
    ----------------------------------------------------------------------
    FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES
    ----------------------------------------------------------------------
    1 | ERROR | [x] End of line character is invalid; expected "\n"
    | | but found "\r\n"
    92 | ERROR | [x] Expected 1 space before "=>"; 0 found
    94 | WARNING | [x] A comma should follow the last multiline array
    | | item. Found: ]
    ----------------------------------------------------------------------
    PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------

    FILE: ...l\modules\fivestar\src\Plugin\Field\FieldWidget\SelectWidget.php
    ----------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    ----------------------------------------------------------------------
    1 | ERROR | [x] End of line character is invalid; expected "\n" but
    | | found "\r\n"
    47 | ERROR | [x] Use null coalesce operator instead of ternary
    | | operator.
    ----------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------

    FILE: ...al\modules\fivestar\src\Plugin\Field\FieldWidget\StarsWidget.php
    ----------------------------------------------------------------------
    FOUND 4 ERRORS AND 1 WARNING AFFECTING 5 LINES
    ----------------------------------------------------------------------
    1 | ERROR | [x] End of line character is invalid; expected "\n"
    | | but found "\r\n"
    21 | ERROR | [x] Expected 1 space before opening brace; found 2
    95 | ERROR | [x] Expected 1 space before "=>"; 0 found
    97 | WARNING | [x] A comma should follow the last multiline array
    | | item. Found: ]
    127 | ERROR | [x] Use null coalesce operator instead of ternary
    | | operator.
    ----------------------------------------------------------------------
    PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------

    FILE: ...:\xampp\htdocs\abc\drupal\modules\fivestar\src\WidgetManager.php
    ----------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    ----------------------------------------------------------------------
    1 | ERROR | [x] End of line character is invalid; expected "\n" but
    | | found "\r\n"
    64 | ERROR | [x] Use null coalesce operator instead of ternary
    | | operator.
    ----------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------

    FILE: ...xampp\htdocs\abc\drupal\modules\fivestar\test\fivestar.base.test
    ----------------------------------------------------------------------
    FOUND 11 ERRORS AND 1 WARNING AFFECTING 11 LINES
    ----------------------------------------------------------------------
    1 | ERROR | [x] End of line character is invalid; expected "\n"
    | | but found "\r\n"
    8 | ERROR | [ ] Doc comment is empty
    13 | ERROR | [ ] Missing short description in doc comment
    15 | ERROR | [ ] Missing @var tag in member variable comment
    20 | ERROR | [ ] Missing @var tag in member variable comment
    21 | ERROR | [ ] Class property $admin_user should use lowerCamel
    | | naming without underscores
    22 | ERROR | [ ] Missing member variable doc comment
    24 | ERROR | [ ] Doc comment is empty
    30 | WARNING | [ ] Unused variable $type.
    30 | ERROR | [ ] The array declaration extends to column 99 (the
    | | limit is 80). The array content should be split
    | | up over multiple lines
    31 | ERROR | [ ] The array declaration extends to column 97 (the
    | | limit is 80). The array content should be split
    | | up over multiple lines
    38 | ERROR | [ ] Missing parameter type
    ----------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------

    FILE: ...ampp\htdocs\abc\drupal\modules\fivestar\test\fivestar.field.test
    ----------------------------------------------------------------------
    FOUND 4 ERRORS AND 7 WARNINGS AFFECTING 11 LINES
    ----------------------------------------------------------------------
    1 | ERROR | [x] End of line character is invalid; expected "\n"
    | | but found "\r\n"
    8 | ERROR | [ ] Doc comment is empty
    13 | ERROR | [ ] Doc comment is empty
    38 | WARNING | [ ] t() calls should be avoided in classes, use
    | | \Drupal\Core\StringTranslation\StringTranslationTrait
    | | and $this->t() instead
    39 | WARNING | [ ] t() calls should be avoided in classes, use
    | | \Drupal\Core\StringTranslation\StringTranslationTrait
    | | and $this->t() instead
    54 | WARNING | [ ] t() calls should be avoided in classes, use
    | | \Drupal\Core\StringTranslation\StringTranslationTrait
    | | and $this->t() instead
    58 | WARNING | [ ] t() calls should be avoided in classes, use
    | | \Drupal\Core\StringTranslation\StringTranslationTrait
    | | and $this->t() instead
    60 | WARNING | [ ] Line exceeds 80 characters; contains 92
    | | characters
    88 | WARNING | [x] 'TODO: we should text the data being returned.'
    | | should match the format '@todo Fix problem X
    | | here.'
    95 | ERROR | [ ] Doc comment short description must be on a
    | | single line, further text should be a separate
    | | paragraph
    128 | WARNING | [ ] t() calls should be avoided in classes, use
    | | \Drupal\Core\StringTranslation\StringTranslationTrait
    | | and $this->t() instead
    ----------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------

  • Assigned to himanshu_jhaloya
  • 🇮🇳India himanshu_jhaloya Indore

    I will continue.

  • Issue was unassigned.
  • Status changed to Needs review almost 2 years ago
  • 🇮🇳India himanshu_jhaloya Indore

    All issues are resolved adding the patch please review

  • Status changed to RTBC almost 2 years ago
  • 🇮🇳India Charchil Khandelwal

    Patch #9 applied cleanly, and all errors and warnings are fixed.
    So moving it to RTBC.
    Thanks

  • Status changed to Needs work almost 2 years ago
  • 🇺🇸United States tr Cascadia

    The .test files are Drupal 7 code that has not been ported to Drupal 8+ yet. These need to be ported, and should NOT be changed otherwise because that is just useless work that will be thrown away after the port. Likewise, t() should not be used in any test cases, and adding a t() method to make the coding standards warnings go away is just wrong.

    This patch tries to do too much. Some of it is right and some of it is wrong. This patch is even adding errors that didn't exist before.

    With coding standards especially, I prefer to do ONE thing at a time so that it is easier to review and correct.

    So please make a patch that addresses just one thing. Null coalesce, for example. Then when that is fixed we can move on to missing documentation comments.

    But again the important thing here is what the testbot reports when running PHPCS on drupal.org. Running PHPCS on your own local site seems to bring up many wrong results such as "1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"". That is wrong - there is no \r\n in this code base.

  • Status changed to Active almost 2 years ago
  • 🇺🇸United States tr Cascadia

    I'm turning this into a meta because there are too many unrelated things that this issue is trying to handle and because the current approach is getting nowhere.

    Like I said, each issue should be handled separately. I'll start with the null coalesce issue, and I've opened up a child issue for that: 📌 Coding standards: null coalesce Fixed

    Likewise, other issues should have their own child issue.

    No further patches will be accepted here in this issue - this is now only for tracking the related coding standards issues.

  • 🇺🇸United States tr Cascadia
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 5.6
    last update about 1 year ago
    Patch Failed to Apply
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update about 1 year ago
    Patch Failed to Apply
  • Status changed to Closed: outdated 4 months ago
  • 🇺🇸United States tr Cascadia
Production build 0.71.5 2024