Fix the issues reported by phpcs

Created on 12 May 2023, about 1 year ago
Updated 21 June 2024, 7 days ago

Problem/Motivation

Module's code contains several Drupal Coding Standards issues. This task is created to fix them.

Steps to reproduce

Run the command:

phpcs --standard=Drupal
/web/modules/contrib/eventarc/

Proposed resolution

Fix the following coding standards issues and upload the patch or create an MR with fixes.
FILE: \modules\contrib\eventarc\src\Controller\EventarcController.php
----------------------------------------------------------------------------------------------------------------------
FOUND 4 ERRORS AND 2 WARNINGS AFFECTING 6 LINES
----------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
25 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
30 | ERROR | [ ] Missing member variable doc comment
154 | WARNING | [ ] Line exceeds 80 characters; contains 112 characters
194 | ERROR | [ ] Doc comment is empty
197 | ERROR | [ ] Public method name "EventarcController::getGoogleJWKs" is not in lowerCamel format
----------------------------------------------------------------------------------------------------------------------

FILE: \modules\contrib\eventarc\src\Event\CloudStorageEvents.php
--------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 4 WARNINGS AFFECTING 6 LINES
--------------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
5 | ERROR | [ ] Doc comment is empty
11 | WARNING | [ ] Line exceeds 80 characters; contains 92 characters
13 | WARNING | [ ] Line exceeds 80 characters; contains 89 characters
25 | WARNING | [ ] Line exceeds 80 characters; contains 91 characters
27 | WARNING | [ ] Line exceeds 80 characters; contains 88 characters
--------------------------------------------------------------------------------------------------------

FILE: \modules\contrib\eventarc\src\Event\EventarcEvent.php
---------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
---------------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
31 | ERROR | [ ] Doc comment is empty
----------------------------------------------------------------------------------------------------------

FILE: \modules\contrib\eventarc\src\Form\ConfigForm.php
----------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
----------------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
10 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
-----------------------------------------------------------------------------------------------------------

FILE: \modules\contrib\eventarc\tests\Controller\EventarcControllerTest.php
-----------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
-----------------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
26 | WARNING | [ ] Possible useless method overriding detected
-----------------------------------------------------------------------------------------------------------

šŸ“Œ Task
Status

Needs review

Version

1.0

Component

Code

Created by

šŸ‡®šŸ‡³India Shanu Chouhan

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 @Shanu Chouhan
  • Issue was unassigned.
  • šŸ‡®šŸ‡³India Shanu Chouhan

    Fixed some PHPCS issues.

  • Status changed to Needs work about 1 year ago
  • šŸ‡®šŸ‡¹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.

    The command shown in the issue summary does not use the correct value for --standard.

  • Status changed to Active about 1 year ago
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹

    Why is only the Drupal ruleset used? There are two rulesets for Drupal coding standards: Drupal and DrupalPractice.

  • Assigned to PrabuEla
  • šŸ‡®šŸ‡³India PrabuEla chennai
  • šŸ‡®šŸ‡³India PrabuEla chennai
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • šŸ‡®šŸ‡³India PrabuEla chennai
  • Status changed to Needs work 21 days ago
  • Hi @everyone,

    Applied patch #2 and patch #5, both applied successfully patch #2 has lesser errors than patch #5

    Patch #2

    eventarc git:(1.0.x) curl https://www.drupal.org/files/issues/2023-05-12/3359957-2.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  2049  100  2049    0     0   4869      0 --:--:-- --:--:-- --:--:--  5034
    patching file src/Controller/EventarcController.php
    patching file src/Event/CloudStorageEvents.php
    patching file src/Event/EventarcEvent.php
    patching file src/Form/ConfigForm.php
    āžœ  eventarc git:(1.0.x) āœ— cd ..
    āžœ  contrib git:(master) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig eventarc
    
    FILE: ...9/web/modules/contrib/eventarc/tests/Controller/EventarcControllerTest.php
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     26 | WARNING | Possible useless method overriding detected
    --------------------------------------------------------------------------------
    
    
    FILE: ...-site/drupal-orgissue-v9/web/modules/contrib/eventarc/eventarc.routing.yml
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     14 | WARNING | The administration page callback should probably use
        |         | "administer site configuration" - which implies the user can
        |         | change something - rather than "access administration pages"
        |         | which is about viewing but not changing configurations.
    --------------------------------------------------------------------------------
    
    
    FILE: ...te/drupal-orgissue-v9/web/modules/contrib/eventarc/src/Form/ConfigForm.php
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     43 | WARNING | Unused variable $name_field.
    --------------------------------------------------------------------------------
    
    
    FILE: ...ssue-v9/web/modules/contrib/eventarc/src/Controller/EventarcController.php
    --------------------------------------------------------------------------------
    FOUND 4 ERRORS AND 2 WARNINGS AFFECTING 5 LINES
    --------------------------------------------------------------------------------
       7 | ERROR   | [x] Use statements should be sorted alphabetically. The first
         |         |     wrong one is Drupal\Core\Access\AccessResult.
      99 | ERROR   | [x] Multi-line function declarations must have a trailing
         |         |     comma after the last parameter
      99 | ERROR   | [x] The closing parenthesis of a multi-line function
         |         |     declaration must be on a new line
     166 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency
         |         |     injection instead
     188 | WARNING | [ ] t() calls should be avoided in classes, use
         |         |     \Drupal\Core\StringTranslation\StringTranslationTrait and
         |         |     $this->t() instead
     202 | ERROR   | [ ] Public method name "EventarcController::getGoogleJWKs" is
         |         |     not in lowerCamel format
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    
    FILE: ...-orgissue-v9/web/modules/contrib/eventarc/src/Event/CloudStorageEvents.php
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
    --------------------------------------------------------------------------------
     11 | WARNING | Line exceeds 80 characters; contains 92 characters
     13 | WARNING | Line exceeds 80 characters; contains 89 characters
     25 | WARNING | Line exceeds 80 characters; contains 91 characters
     27 | WARNING | Line exceeds 80 characters; contains 88 characters
    --------------------------------------------------------------------------------
    
    Time: 220ms; Memory: 10MB

    Patch #5

    eventarc git:(1.0.x) curl https://www.drupal.org/files/issues/2023-05-26/best_practice_issue_fixed_3073778_6_0.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  3741  100  3741    0     0  10690      0 --:--:-- --:--:-- --:--:-- 11133
    patching file eventarc.routing.yml
    patching file src/Controller/EventarcController.php
    patching file src/Form/ConfigForm.php
    āžœ  eventarc git:(1.0.x) āœ— cd ..
    āžœ  contrib git:(master) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig eventarc
    
    FILE: ...9/web/modules/contrib/eventarc/tests/Controller/EventarcControllerTest.php
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     26 | WARNING | Possible useless method overriding detected
    --------------------------------------------------------------------------------
    
    
    FILE: ...te/drupal-orgissue-v9/web/modules/contrib/eventarc/src/Form/ConfigForm.php
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     10 | WARNING | The class short comment should describe what the class does and
        |         | not simply repeat the class name
    --------------------------------------------------------------------------------
    
    
    FILE: ...ssue-v9/web/modules/contrib/eventarc/src/Controller/EventarcController.php
    --------------------------------------------------------------------------------
    FOUND 8 ERRORS AND 2 WARNINGS AFFECTING 10 LINES
    --------------------------------------------------------------------------------
       7 | ERROR   | [x] Use statements should be sorted alphabetically. The first
         |         |     wrong one is Drupal\Core\Access\AccessResult.
      26 | WARNING | [ ] The class short comment should describe what the class
         |         |     does and not simply repeat the class name
      31 | ERROR   | [ ] Missing member variable doc comment
      83 | ERROR   | [ ] Parameter $requestStack is not described in comment
      96 | ERROR   | [ ] Missing parameter name
     105 | ERROR   | [x] Multi-line function declarations must have a trailing
         |         |     comma after the last parameter
     106 | ERROR   | [x] Multi-line function declaration not indented correctly;
         |         |     expected 2 spaces but found 4
     168 | WARNING | [ ] Line exceeds 80 characters; contains 112 characters
     208 | ERROR   | [ ] Doc comment is empty
     211 | ERROR   | [ ] Public method name "EventarcController::getGoogleJWKs" is
         |         |     not in lowerCamel format
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    
    FILE: ...-orgissue-v9/web/modules/contrib/eventarc/src/Event/CloudStorageEvents.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AND 4 WARNINGS AFFECTING 5 LINES
    --------------------------------------------------------------------------------
      5 | ERROR   | Doc comment is empty
     11 | WARNING | Line exceeds 80 characters; contains 92 characters
     13 | WARNING | Line exceeds 80 characters; contains 89 characters
     25 | WARNING | Line exceeds 80 characters; contains 91 characters
     27 | WARNING | Line exceeds 80 characters; contains 88 characters
    --------------------------------------------------------------------------------
    
    
    FILE: ...rupal-orgissue-v9/web/modules/contrib/eventarc/src/Event/EventarcEvent.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     31 | ERROR | Doc comment is empty
    --------------------------------------------------------------------------------
    
    Time: 231ms; Memory: 10MB

    Kindly check

    Thanks,
    Jake

  • Assigned to priyanka_chauhan31
  • Issue was unassigned.
  • Status changed to Needs review 7 days ago
  • šŸ‡®šŸ‡³India priyanka_chauhan31 Noida

    Please review the patch.

Production build 0.69.0 2024