Drupal Coding Standards Issues | phpcs

Created on 6 February 2023, about 2 years ago

Problem/Motivation

FILE: /Users/sahil.goyal/Documents/MySites/10.1.x/drupal/modules/contrib/cer/cer.module
------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------
 28 | ERROR | [x] Namespaced classes/interfaces/traits should be referenced with use statements
------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------


FILE: /Users/sahil.goyal/Documents/MySites/10.1.x/drupal/modules/contrib/cer/cer.api.php
----------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 3 WARNINGS AFFECTING 5 LINES
----------------------------------------------------------------------------------------
  5 | WARNING | [ ] Line exceeds 80 characters; contains 88 characters
  8 | WARNING | [x] Unused use statement
 11 | ERROR   | [x] Doc comment short description must end with a full stop
 16 | WARNING | [ ] Line exceeds 80 characters; contains 84 characters
 23 | ERROR   | [x] Multi-line function declarations must define one parameter per line
----------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------


FILE: /Users/sahil.goyal/Documents/MySites/10.1.x/drupal/modules/contrib/cer/README.md
--------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 10 WARNINGS AFFECTING 10 LINES
--------------------------------------------------------------------------------------
  5 | WARNING | Line exceeds 80 characters; contains 81 characters
 32 | WARNING | Line exceeds 80 characters; contains 84 characters
 37 | WARNING | Line exceeds 80 characters; contains 82 characters
 38 | WARNING | Line exceeds 80 characters; contains 85 characters
 39 | WARNING | Line exceeds 80 characters; contains 91 characters
 41 | WARNING | Line exceeds 80 characters; contains 88 characters
 42 | WARNING | Line exceeds 80 characters; contains 87 characters
 43 | WARNING | Line exceeds 80 characters; contains 91 characters
 48 | WARNING | Line exceeds 80 characters; contains 91 characters
 56 | WARNING | Line exceeds 80 characters; contains 81 characters
--------------------------------------------------------------------------------------


FILE: /Users/sahil.goyal/Documents/MySites/10.1.x/drupal/modules/contrib/cer/src/Form/CorrespondingReferenceSyncForm.php
------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 2 WARNINGS AFFECTING 4 LINES
------------------------------------------------------------------------------------------------------------------------
 19 | WARNING | [x] A comma should follow the last multiline array item. Found: )
 44 | WARNING | [x] A comma should follow the last multiline array item. Found: )
 46 | ERROR   | [x] Expected 1 blank line after function; 0 found
 47 | ERROR   | [x] The closing brace for the class must have an empty line before it
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------


FILE: /Users/sahil.goyal/Documents/MySites/10.1.x/drupal/modules/contrib/cer/src/Form/CorrespondingReferenceDeleteForm.php
--------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 2 WARNINGS AFFECTING 4 LINES
--------------------------------------------------------------------------------------------------------------------------
 19 | WARNING | [x] A comma should follow the last multiline array item. Found: )
 44 | WARNING | [x] A comma should follow the last multiline array item. Found: )
 48 | ERROR   | [x] Expected 1 blank line after function; 0 found
 49 | ERROR   | [x] The closing brace for the class must have an empty line before it
--------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------


FILE: /Users/sahil.goyal/Documents/MySites/10.1.x/drupal/modules/contrib/cer/src/Form/CorrespondingReferenceForm.php
-------------------------------------------------------------------------------------------------------------------------------------------
FOUND 20 ERRORS AND 3 WARNINGS AFFECTING 17 LINES
-------------------------------------------------------------------------------------------------------------------------------------------
  11 | WARNING | [x] Unused use statement
  19 | ERROR   | [x] The open comment tag must be the only content on the line
  19 | ERROR   | [ ] Missing short description in doc comment
  19 | ERROR   | [x] Data types in @var tags need to be fully namespaced
  19 | ERROR   | [x] Expected "EntityTypeManagerInterface" but found "EntityTypeManagerInterface " for @var tag in member variable comment
  22 | ERROR   | [x] The open comment tag must be the only content on the line
  22 | ERROR   | [ ] Missing short description in doc comment
  22 | ERROR   | [x] Data types in @var tags need to be fully namespaced
  22 | ERROR   | [x] Expected "EntityFieldManager" but found "EntityFieldManager " for @var tag in member variable comment
  28 | ERROR   | [ ] Missing parameter comment
  41 | ERROR   | [x] Data types in @var tags need to be fully namespaced
  44 | ERROR   | [x] Data types in @var tags need to be fully namespaced
  59 | ERROR   | [x] Data types in @var tags need to be fully namespaced
 131 | ERROR   | [x] Data types in @var tags need to be fully namespaced
 151 | WARNING | [ ] Line exceeds 80 characters; contains 92 characters
 182 | WARNING | [ ] Unused variable $entityType.
 202 | ERROR   | [x] Data types in @var tags need to be fully namespaced
 241 | ERROR   | [x] Expected "array|null" but found "array|NULL" for parameter type
 264 | ERROR   | [x] Expected "array|null" but found "array|NULL" for parameter type
 275 | ERROR   | [x] list(...) is forbidden, use [...] instead.
 302 | ERROR   | [x] Data types in @var tags need to be fully namespaced
 310 | ERROR   | [x] Expected 1 blank line after function; 0 found
 311 | ERROR   | [x] The closing brace for the class must have an empty line before it
-------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 18 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------------------


FILE: /Users/sahil.goyal/Documents/MySites/10.1.x/drupal/modules/contrib/cer/src/Entity/CorrespondingReferenceInterface.php
---------------------------------------------------------------------------------------------------------------------------
FOUND 7 ERRORS AND 3 WARNINGS AFFECTING 8 LINES
---------------------------------------------------------------------------------------------------------------------------
  89 | WARNING | [ ] Line exceeds 80 characters; contains 82 characters
  97 | WARNING | [ ] Line exceeds 80 characters; contains 82 characters
  97 | ERROR   | [ ] Parameter comment must start with a capital letter
 150 | ERROR   | [x] Missing parameter type
 170 | WARNING | [ ] Line exceeds 80 characters; contains 87 characters
 196 | ERROR   | [ ] Parameter tags must be grouped together in a doc comment
 199 | ERROR   | [ ] Parameter tags must be grouped together in a doc comment
 199 | ERROR   | [ ] Missing parameter type
 202 | ERROR   | [x] Expected 1 blank line after function; 0 found
 203 | ERROR   | [x] The closing brace for the interface must have an empty line before it
---------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------


FILE: /Users/sahil.goyal/Documents/MySites/10.1.x/drupal/modules/contrib/cer/src/Entity/CorrespondingReference.php
------------------------------------------------------------------------------------------------------------------
FOUND 7 ERRORS AND 1 WARNING AFFECTING 8 LINES
------------------------------------------------------------------------------------------------------------------
   7 | WARNING | [x] Unused use statement
 282 | ERROR   | [x] Data types in @var tags need to be fully namespaced
 377 | ERROR   | [x] Case breaking statements must be followed by a single blank line
 414 | ERROR   | [x] Data types in @var tags need to be fully namespaced
 415 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
 430 | ERROR   | [x] Data types in @var tags need to be fully namespaced
 487 | ERROR   | [x] Expected 1 blank line after function; 0 found
 488 | ERROR   | [x] The closing brace for the class must have an empty line before it
------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------


FILE: /Users/sahil.goyal/Documents/MySites/10.1.x/drupal/modules/contrib/cer/src/CorrespondingReferenceStorageInterface.php
---------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES
---------------------------------------------------------------------------------------------------------------------------
 14 | WARNING | [ ] Line exceeds 80 characters; contains 82 characters
 22 | ERROR   | [x] Expected 1 blank line after function; 0 found
 23 | ERROR   | [x] The closing brace for the interface must have an empty line before it
---------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------


FILE: /Users/sahil.goyal/Documents/MySites/10.1.x/drupal/modules/contrib/cer/src/CorrespondingReferenceOperations.php
---------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------
 12 | ERROR | [x] The closing brace for the class must have an empty line before it
---------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------


FILE: /Users/sahil.goyal/Documents/MySites/10.1.x/drupal/modules/contrib/cer/src/CorrespondingReferenceStorage.php
------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------
 27 | ERROR | [x] Expected 1 blank line after function; 0 found
 28 | ERROR | [x] The closing brace for the class must have an empty line before it
------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------


FILE: /Users/sahil.goyal/Documents/MySites/10.1.x/drupal/modules/contrib/cer/src/EventSubscriber/CerSubscriber.php
-----------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 4 WARNINGS AFFECTING 3 LINES
-----------------------------------------------------------------------------------------------------------------------------------------------------------
 18 | WARNING | [ ] Line exceeds 80 characters; contains 92 characters
 18 | WARNING | [x] 'TODO: Register event to update corresponding references when entity types are updated' should match the format '@todo Fix problem X
    |         |     here.'
 18 | WARNING | [x] There must be no blank line following an inline comment
 18 | WARNING | [ ] There must be no blank line following an inline comment
 18 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 21 | ERROR   | [x] Expected 1 blank line after function; 0 found
 22 | ERROR   | [x] The closing brace for the class must have an empty line before it
-----------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------------------------------------


FILE: /Users/sahil.goyal/Documents/MySites/10.1.x/drupal/modules/contrib/cer/src/CorrespondingReferenceListBuilder.php
----------------------------------------------------------------------------------------------------------------------
FOUND 7 ERRORS AFFECTING 6 LINES
----------------------------------------------------------------------------------------------------------------------
 13 | ERROR | [x] Missing function doc comment
 13 | ERROR | [x] Expected 1 blank line before function; 0 found
 25 | ERROR | [x] Missing function doc comment
 26 | ERROR | [x] Data types in @var tags need to be fully namespaced
 39 | ERROR | [x] Missing function doc comment
 49 | ERROR | [x] Expected 1 blank line after function; 0 found
 50 | ERROR | [x] The closing brace for the class must have an empty line before it
----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------

Time: 195ms; Memory: 12MB

Steps to reproduce

Run the following command : phpcs --standard="Drupal,DrupalPractice" --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml /10.1.x/drupal/modules/contrib/cer

Proposed resolution

Fix all the PHP coding standard issues and warnings.

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ› Bug report
Status

Needs work

Version

5.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia sahil.goyal

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @sahil.goyal
  • Status changed to Needs review about 2 years ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sahil.goyal

    Fixing all the php coding standard issues and warnings in this patch. Please Review.

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

    I will review this.

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

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

    Thanks.

  • Issue was unassigned.
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Status changed to Needs work almost 2 years ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
     /**
      * @file
    - * Describes hooks and plugins provided by the Corresponding entities references module.
    + * Corresponding entities module offers hooks & plugins for references.
      */

    The correct short description for those files is Describes hooks provided by the [module name] module.

    - *   Differences arrary calculated by CorrespondingReference::calculateDifferences()
    + *   Diff. arrary calculated by CorrespondingReference::calculateDifferences()

    The existing description is correct, except for a typo.

    function hook_cer_differences_alter(\Drupal\Core\Entity\ContentEntityInterface $entity,
    -  array &$differences, $correspondingField) {
    +  array &$differences,
    + $correspondingField) {

    As per Drupal coding standards, function declarations are written in a single line.

    +  /**
    +   * Builds the header row for the entity listing.
    +   */
       public function buildHeader() {

    The return value is not documented.

    +  /**
    +   * Builds the row for the entity listing.
    +   */
       public function buildRow(EntityInterface $entity) {

    Parameters and return value descriptions are missing.

  • bindu r โ†’ made their first commit to this issueโ€™s fork.

  • First commit to issue fork.
  • First commit to issue fork.
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.2.1 + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    2 pass
  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sakthi_dev

    Addressed the comment #7. Please review.

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

    Your changes on the MR !9 was applied not-so successfully and errors were reported. Please see below:

     cer git:(5.x) curl https://git.drupalcode.org/project/cer/-/merge_requests/9.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 21604    0 21604    0     0  45057      0 --:--:-- --:--:-- --:--:-- 46560
    patching file README.md
    patching file cer.api.php
    patching file cer.module
    patching file src/CorrespondingReferenceListBuilder.php
    patching file src/CorrespondingReferenceOperations.php
    patching file src/CorrespondingReferenceStorage.php
    patching file src/CorrespondingReferenceStorageInterface.php
    patching file src/Entity/CorrespondingReference.php
    patching file src/Entity/CorrespondingReferenceInterface.php
    patching file src/EventSubscriber/CerSubscriber.php
    patching file src/Form/CorrespondingReferenceDeleteForm.php
    patching file src/Form/CorrespondingReferenceForm.php
    Hunk #7 succeeded at 186 (offset 1 line).
    Hunk #8 succeeded at 206 (offset 1 line).
    Hunk #9 succeeded at 245 (offset 1 line).
    Hunk #10 succeeded at 268 (offset 1 line).
    Hunk #11 succeeded at 279 (offset 1 line).
    Hunk #12 succeeded at 306 (offset 1 line).
    Hunk #13 succeeded at 315 (offset 1 line).
    patching file src/Form/CorrespondingReferenceSyncForm.php
    โžœ  cer git:(5.x) โœ— cd ..
    โžœ  contrib git:(master) โœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig cer
    
    FILE: ...etInterns/Demo-site/drupal-orgissue-v9/web/modules/contrib/cer/cer.api.php
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     14 | WARNING | Line exceeds 80 characters; contains 83 characters
    --------------------------------------------------------------------------------
    
    
    FILE: ...-orgissue-v9/web/modules/contrib/cer/src/Entity/CorrespondingReference.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     7 | ERROR | [x] Use statements should be sorted alphabetically. The first
       |       |     wrong one is Drupal\cer\CorrespondingReferenceOperations.
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    
    FILE: ...issue-v9/web/modules/contrib/cer/src/CorrespondingReferenceListBuilder.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     7 | ERROR | [x] Use statements should be sorted alphabetically. The first
       |       |     wrong one is
       |       |     Drupal\cer\Entity\CorrespondingReferenceInterface.
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    Time: 545ms; Memory: 12MB

    Kindly check

    Thanks,
    Jake

  • First commit to issue fork.
  • Merge request !16Issue #3339494: Fixed phpcs issues. โ†’ (Merged) created by Unnamed author
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    apaderno โ†’ changed the visibility of the branch 3339496-drupal-coding-standards to hidden.

  • Pipeline finished with Success
    9 months ago
    Total: 185s
    #221626
  • Pipeline finished with Success
    9 months ago
    Total: 190s
    #221628
  • Pipeline finished with Success
    9 months ago
    Total: 162s
    #221629
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Status changed to RTBC 9 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • First commit to issue fork.
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Grevil

    PHPCS doesn't complain any more. Thanks all!

    Merging.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Grevil
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024