Phpcs Drupal coding standard issue

Created on 14 December 2022, almost 2 years ago
Updated 5 June 2024, 6 months ago

$ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,yaml,feature,js,json,ts,tsx,feature,twig timetrack/

FILE: C:\xampp\htdocs\drupal-9\web\modules\contrib\timetrack\src\Controller\ProjectsController.php
--------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
--------------------------------------------------------------------------------------------------
24 | ERROR | Missing short description in doc comment
64 | WARNING | Unused variable $key.
--------------------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\drupal-9\web\modules\contrib\timetrack\src\Form\DeleteFavoriteProjectForm.php
---------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 6 WARNINGS AFFECTING 8 LINES
---------------------------------------------------------------------------------------------------
29 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
30 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
73 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
74 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
75 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
77 | WARNING | Empty return statement not required here
80 | ERROR | Missing short description in doc comment
81 | ERROR | Description for the @return value is missing
---------------------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\drupal-9\web\modules\contrib\timetrack\src\Form\FavoriteProjectForm.php
----------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 8 WARNINGS AFFECTING 6 LINES
----------------------------------------------------------------------------------------------
27 | WARNING | Unused variable $year.
27 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
28 | WARNING | Unused variable $week.
28 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
169 | WARNING | Unused variable $favorite_project.
172 | WARNING | Line exceeds 80 characters; contains 106 characters
182 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
184 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\drupal-9\web\modules\contrib\timetrack\src\Form\ProjectForm.php
----------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 9 WARNINGS AFFECTING 9 LINES
----------------------------------------------------------------------------------------------
28 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
29 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
55 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
69 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
87 | WARNING | #options values usually have to run through t() for translation
88 | WARNING | #options values usually have to run through t() for translation
89 | WARNING | #options values usually have to run through t() for translation
147 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
149 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\drupal-9\web\modules\contrib\timetrack\src\Form\TestForm.php
----------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 12 WARNINGS AFFECTING 8 LINES
----------------------------------------------------------------------------------------------
24 | WARNING | Unused variable $uid.
24 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
32 | WARNING | Unused variable $year.
32 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
33 | WARNING | Unused variable $week.
33 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
35 | WARNING | Line exceeds 80 characters; contains 95 characters
256 | WARNING | Unused variable $timeEntry.
259 | WARNING | Line exceeds 80 characters; contains 103 characters
269 | WARNING | Unused variable $uid.
269 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
272 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\drupal-9\web\modules\contrib\timetrack\src\Form\TimeTrackingForm.php
----------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 11 WARNINGS AFFECTING 11 LINES
----------------------------------------------------------------------------------------------
27 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
38 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
39 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
40 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
42 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
272 | WARNING | Unused variable $timeEntry.
275 | WARNING | Line exceeds 80 characters; contains 103 characters
285 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
289 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
290 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
292 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\drupal-9\web\modules\contrib\timetrack\src\Services\ProjectService.php
----------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 3 WARNINGS AFFECTING 4 LINES
----------------------------------------------------------------------------------------------
24 | ERROR | Missing short description in doc comment
62 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
223 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
267 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------

FILE: C:\xampp\htdocs\drupal-9\web\modules\contrib\timetrack\src\Services\TimeEntryService.php
-----------------------------------------------------------------------------------------------
FOUND 7 ERRORS AND 1 WARNING AFFECTING 7 LINES
-----------------------------------------------------------------------------------------------
26 | ERROR | Missing short description in doc comment
26 | ERROR | Parameter $ps is not described in comment
29 | ERROR | Missing parameter name
85 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
104 | ERROR | Doc comment for parameter $uid does not match actual variable name $timeData
106 | ERROR | Doc comment for parameter $year does not match actual variable name $timeData
108 | ERROR | Superfluous parameter comment
110 | ERROR | Superfluous parameter comment
-----------------------------------------------------------------------------------------------

๐Ÿ› Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia anoopsingh92 Rajasthan, India

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia spriya2896

    I will work on remaining issues.

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia spriya2896

    Hi,
    I have created an MR, Please verify. After running phpcs command it is showing 1 error, and suggesting to remove use statement, but i think it is required so kept it.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia arpitk

    HI I reviewed the MR!1 no phpcs errors/warnings are produced. However one error as mentioned in the #7 thrown. But its an important use statement to keep. I ran phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml .

    Thanks!

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia aman1248

    Amandeep123 โ†’ changed the visibility of the branch 3327126-phpcs-drupal-coding to hidden.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia aman1248

    Amandeep123 โ†’ changed the visibility of the branch 3327126-phpcs-drupal-coding to active.

  • Status changed to Needs work 6 months ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines paraderojether

    Hi

    I reviewed MR!1, it is applied cleanly however there are phpcs issues shown below:

    FILE: /Users/jetherparadero/d_o/drupal-issues/web/modules/contrib/timetrack/src/Form/FavoriteProjectForm.php
    ----------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------------------------------------
     9 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\timetrack\Services\ProjectService.
    ----------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/jetherparadero/d_o/drupal-issues/web/modules/contrib/timetrack/src/Form/ProjectForm.php
    ---------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------------------------
     9 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\EntityTypeManagerInterface.
    ---------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/jetherparadero/d_o/drupal-issues/web/modules/contrib/timetrack/src/Form/TimeTrackingForm.php
    ---------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------------------
     8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Routing\RouteMatchInterface.
    ---------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/jetherparadero/d_o/drupal-issues/web/modules/contrib/timetrack/src/Services/ProjectService.php
    ---------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------------------
     8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Component\Datetime\TimeInterface.
    ---------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/jetherparadero/d_o/drupal-issues/web/modules/contrib/timetrack/src/Services/TimeEntryService.php
    -----------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
    -----------------------------------------------------------------------------------------------------------------------------------
     6 | WARNING | [x] Unused use statement
     7 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Component\Datetime\TimeInterface.
    -----------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------
    
    Time: 420ms; Memory: 12MB
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia dev16.addweb

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

  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 6 months ago
    Waiting for branch to pass
  • First commit to issue fork.
  • Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 6 months ago
    Waiting for branch to pass
Production build 0.71.5 2024