Fix the issues reported by phpcs

Created on 27 January 2023, almost 2 years ago
Updated 15 August 2024, 3 months ago

Problem/Motivation

Get the following phpcs errors/warnings

FILE: ...google_analytics_reports/.gitlab/issue_templates/default.md
----------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------------------------------------
 39 | ERROR | [x] Expected 1 newline at end of file; 0 found
----------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------------


FILE: ...google_analytics_reports/README.md
---------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 13 WARNINGS AFFECTING 13 LINES
---------------------------------------------------------------------------------------------------------------------------
  23 | WARNING | Line exceeds 80 characters; contains 85 characters
  29 | WARNING | Line exceeds 80 characters; contains 124 characters
  59 | WARNING | Line exceeds 80 characters; contains 139 characters
  65 | WARNING | Line exceeds 80 characters; contains 92 characters
  89 | WARNING | Line exceeds 80 characters; contains 82 characters
  94 | WARNING | Line exceeds 80 characters; contains 128 characters
  95 | WARNING | Line exceeds 80 characters; contains 259 characters
  99 | WARNING | Line exceeds 80 characters; contains 193 characters
 100 | WARNING | Line exceeds 80 characters; contains 248 characters
 101 | WARNING | Line exceeds 80 characters; contains 207 characters
 105 | WARNING | Line exceeds 80 characters; contains 153 characters
 107 | WARNING | Line exceeds 80 characters; contains 151 characters
 111 | WARNING | Line exceeds 80 characters; contains 141 characters
---------------------------------------------------------------------------------------------------------------------------


FILE: ...google_analytics_reports/modules/google_analytics_reports_api/tests/src/Unit/GoogleAnalyticsReportsApiFeedTest.php
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 12 ERRORS AND 2 WARNINGS AFFECTING 8 LINES
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 34 | WARNING | [ ] Line exceeds 80 characters; contains 88 characters
 39 | ERROR   | [ ] Parameter tags must be defined first in a doc comment
 39 | ERROR   | [ ] Missing parameter comment
 39 | ERROR   | [ ] Missing parameter type
 40 | ERROR   | [ ] Missing parameter comment
 40 | ERROR   | [ ] Missing parameter type
 64 | ERROR   | [x] Array closing indentation error, expected 6 spaces but found 0
 69 | WARNING | [ ] Line exceeds 80 characters; contains 121 characters
 70 | ERROR   | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
 75 | ERROR   | [ ] Parameter tags must be defined first in a doc comment
 75 | ERROR   | [ ] Missing parameter comment
 75 | ERROR   | [ ] Missing parameter type
 76 | ERROR   | [ ] Missing parameter comment
 76 | ERROR   | [ ] Missing parameter type
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


FILE: ...google_analytics_reports/modules/google_analytics_reports_api/tests/src/mock.php
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 14 ERRORS AFFECTING 14 LINES
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  3 | ERROR | [ ] Missing short description in doc comment
 14 | ERROR | [x] Missing function doc comment
 29 | ERROR | [x] Array indentation error, expected 6 spaces but found 4
 30 | ERROR | [x] Array closing indentation error, expected 4 spaces but found 0
 34 | ERROR | [x] Array indentation error, expected 6 spaces but found 4
 35 | ERROR | [x] Array closing indentation error, expected 4 spaces but found 0
 39 | ERROR | [x] Array indentation error, expected 6 spaces but found 4
 40 | ERROR | [x] Array closing indentation error, expected 4 spaces but found 0
 52 | ERROR | [x] Array indentation error, expected 6 spaces but found 4
 53 | ERROR | [x] Array closing indentation error, expected 4 spaces but found 0
 57 | ERROR | [x] Array indentation error, expected 6 spaces but found 4
 62 | ERROR | [x] Array indentation error, expected 6 spaces but found 4
 63 | ERROR | [x] Array closing indentation error, expected 4 spaces but found 0
 69 | ERROR | [x] Missing function doc comment
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 13 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------


FILE: ...google_analytics_reports/modules/google_analytics_reports_api/src/GoogleAnalyticsReportsApiFeed.php
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 3 WARNINGS AFFECTING 5 LINES
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 130 | WARNING | [ ] Line exceeds 80 characters; contains 117 characters
 131 | WARNING | [ ] Line exceeds 80 characters; contains 84 characters
 131 | ERROR   | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
 135 | WARNING | [ ] Line exceeds 80 characters; contains 84 characters
 188 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 227 | ERROR   | [ ] Public method name "GoogleAnalyticsReportsApiFeed::google_analytics_reports_api_cache_time" is not in lowerCamel format
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


FILE: ...google_analytics_reports/src/Form/GoogleAnalyticsReportsAdminSettingsForm.php
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 2 WARNINGS AFFECTING 5 LINES
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
  5 | WARNING | [x] Unused use statement
 10 | WARNING | [x] Unused use statement
 19 | ERROR   | [x] Expected 1 blank line before function; 0 found
 63 | ERROR   | [x] Expected 1 blank line after function; 0 found
 64 | ERROR   | [x] The closing brace for the class must have an empty line before it
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------------------------------

Time: 538ms; Memory: 14MB

Steps to reproduce

Run the following command from the module folder.

phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml .

Proposed resolution

Fix the errors and warnings.

Remaining tasks

  • โœ… File an issue
  • โž– Addition/Change/Update/Fix
  • โž– Testing to ensure no regression
  • โž– Automated unit testing coverage
  • โž– Automated functional testing coverage
  • โž– UX/UI designer responsibilities
  • โž– Readability
  • โž– Accessibility
  • โž– Performance
  • โž– Security
  • โž– Documentation
  • โž– Code review by maintainers
  • โž– Full testing and approval
  • โž– Credit contributors
  • โž– Review with the product owner
  • โž– Release notes snippet
  • โŒ Release
๐Ÿ“Œ Task
Status

Needs review

Version

4.0

Component

All modules

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia arisen Goa

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

Merge Requests

Comments & Activities

  • Issue created by @arisen
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia arisen Goa
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia arisen Goa
  • Issue was unassigned.
  • Status changed to Needs review almost 2 years ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia arisen Goa

    Created a MR for code standards fix.
    Please review.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nayana_mvr

    Verified the MR and tested it on Drupal version 10.1.x and Google Analytics Reports version 3.x. The patch applied cleanly but I am getting few more errors as follows:

    FILE: .../google_analytics_reports/google_analytics_reports.views.inc
    -----------------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    -----------------------------------------------------------------------------------------------------------------------------
     117 | ERROR | [x] Array indentation error, expected 10 spaces but found 8
     118 | ERROR | [x] Array indentation error, expected 10 spaces but found 8
    -----------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: .../google_analytics_reports/modules/google_analytics_reports_api/google_analytics_reports_api.module
    --------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    --------------------------------------------------------------------------------------------------------------------------------------------------------------
     11 | ERROR | All functions defined in a module file must be prefixed with the module's name, found "_to_array" but expected
        |       | "google_analytics_reports_api__to_array"
     26 | ERROR | All functions defined in a module file must be prefixed with the module's name, found "_ga_convert_dimentrics" but expected
        |       | "google_analytics_reports_api__ga_convert_dimentrics"
    --------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: .../google_analytics_reports/src/Plugin/views/filter/GoogleAnalyticsNumeric.php
    ---------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    ---------------------------------------------------------------------------------------------------------------------------------------------
     260 | ERROR | [x] Array indentation error, expected 10 spaces but found 8
     261 | ERROR | [x] Array indentation error, expected 10 spaces but found 8
    ---------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: .../google_analytics_reports/src/Plugin/views/query/GoogleAnalyticsQuery.php
    ------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------------------------
     420 | ERROR | [x] Use null coalesce operator instead of ternary operator.
    ------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 510ms; Memory: 14MB
  • Assigned to arisen
  • Status changed to Needs work almost 2 years ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia arisen Goa
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia rassoni Bangalore

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

  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia rassoni Bangalore
  • Issue was unassigned.
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Status changed to Needs work 3 months ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines cleavinjosh

    Hi @Rassoni,

    I applied MR!10, it was not applied smoothly.

    These are the issues I encountered after I applied the MR and run phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml.

    โžœ  google_analytics_reports git:(4.0.x) curl https://git.drupalcode.org/project/google_analytics_reports/-/merge_requests/10.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 16185    0 16185    0     0  28623      0 --:--:-- --:--:-- --:--:-- 28646
    patching file .gitlab/issue_templates/default.md
    patching file README.md
    patching file google_analytics_reports.views.inc
    patching file modules/google_analytics_reports_api/google_analytics_reports_api.module
    patching file modules/google_analytics_reports_api/src/GoogleAnalyticsReportsApiFeed.php
    Hunk #1 succeeded at 134 (offset 7 lines).
    Hunk #2 succeeded at 191 (offset 7 lines).
    Hunk #3 succeeded at 230 (offset 7 lines).
    Hunk #4 succeeded at 260 (offset 7 lines).
    patching file modules/google_analytics_reports_api/tests/src/Unit/GoogleAnalyticsReportsApiFeedTest.php
    patching file modules/google_analytics_reports_api/tests/src/mock.php
    patching file src/Form/GoogleAnalyticsReportsAdminSettingsForm.php
    Reversed (or previously applied) patch detected!  Assume -R? [n]
    Apply anyway? [n]
    Skipping patch.
    2 out of 2 hunks ignored -- saving rejects to file src/Form/GoogleAnalyticsReportsAdminSettingsForm.php.rej
    patching file src/Plugin/views/filter/GoogleAnalyticsNumeric.php
    patching file src/Plugin/views/query/GoogleAnalyticsQuery.php
    โžœ  google_analytics_reports git:(4.0.x) โœ— ..
    โžœ  contrib phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml google_analytics_reports
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/google_analytics_reports/google_analytics_reports.module
    -----------------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    -----------------------------------------------------------------------------------------------------------------------------
     31 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
     44 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
    -----------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/google_analytics_reports/modules/google_analytics_reports_api/tests/src/Unit/GoogleAnalyticsReportsApiFeedTest.php
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      6 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\google_analytics_reports_api\GoogleAnalyticsReportsApiFeed.
     88 | WARNING | [ ] Unused variable $result.
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/google_analytics_reports/modules/google_analytics_reports_api/google_analytics_reports_api.api.php
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
     25 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/google_analytics_reports/modules/google_analytics_reports_api/src/Form/GoogleAnalyticsReportsApiAdminSettingsForm.php
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 3 ERRORS AFFECTING 3 LINES
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      13 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\EntityTypeManagerInterface.
      75 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
     102 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/google_analytics_reports/modules/google_analytics_reports_api/src/GoogleAnalyticsReportsApiFeed.php
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 3 ERRORS AFFECTING 3 LINES
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      14 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Messenger\MessengerInterface.
      53 | ERROR | [x] Whitespace found at end of line
     117 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/google_analytics_reports/src/Plugin/views/argument_default/GoogleAnalyticsPath.php
    -------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    -------------------------------------------------------------------------------------------------------------------------------------------------------
     36 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
     49 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
    -------------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/google_analytics_reports/src/Plugin/views/query/GoogleAnalyticsQuery.php
    -------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 5 ERRORS AFFECTING 5 LINES
    -------------------------------------------------------------------------------------------------------------------------------------------------------------
      28 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\google_analytics_reports_api\GoogleAnalyticsReportsApiFeed.
     125 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
     224 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
     296 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
     446 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
    -------------------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/google_analytics_reports/src/GoogleAnalyticsReports.php
    -----------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------------------------------
     6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\google_analytics_reports_api\GoogleAnalyticsReportsApiFeed.
    -----------------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 884ms; Memory: 14MB
    
    โžœ  contrib

    Thank you.

  • Pipeline finished with Success
    3 months ago
    Total: 157s
    #255082
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Status changed to Needs review 3 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Pipeline finished with Success
    3 months ago
    Total: 140s
    #255092
Production build 0.71.5 2024