Drupal Coding Standards Issues | phpcs

Created on 6 February 2023, almost 2 years ago
Updated 11 August 2024, 5 months ago

Problem/Motivation

Getting Following errors/warnings

$ phpcs --standard=Drupal devel_ip

FILE: C:\Users\Admin\Desktop\task\devel_ip\css\style.css
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found
   |       |     "\r\n"
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: C:\Users\Admin\Desktop\task\devel_ip\src\Form\DevelIpForm.php
--------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
--------------------------------------------------------------------------------
   1 | ERROR | [x] End of line character is invalid; expected "\n" but found
     |       |     "\r\n"
  12 | ERROR | [ ] Missing short description in doc comment
  87 | ERROR | [ ] Doc comment is empty
  95 | ERROR | [ ] Doc comment is empty
 105 | ERROR | [ ] Doc comment is empty
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: C:\Users\Admin\Desktop\task\devel_ip\src\Form\DevelRangeForm.php
--------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
--------------------------------------------------------------------------------
   1 | ERROR | [x] End of line character is invalid; expected "\n" but found
     |       |     "\r\n"
  12 | ERROR | [ ] Missing short description in doc comment
 111 | ERROR | [ ] Doc comment is empty
 119 | ERROR | [ ] Doc comment is empty
 129 | ERROR | [ ] Doc comment is empty
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: C:\Users\Admin\Desktop\task\devel_ip\src\Routing\RoutingAccess.php
--------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------
  1 | ERROR | [x] End of line character is invalid; expected "\n" but found
    |       |     "\r\n"
 57 | ERROR | [x] Expected 1 newline at end of file; 3 found
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

Time: 522ms; Memory: 8MB

Proposed resolution

Fix the errors and warnings.

šŸ“Œ Task
Status

Needs work

Version

1.0

Component

Code

Created by

šŸ‡®šŸ‡³India jay jangid Jaipur

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

Comments & Activities

  • Issue created by @jay jangid
  • @jay-jangid opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review almost 2 years ago
  • šŸ‡®šŸ‡³India jay jangid Jaipur

    Created MR ,please review.

    Thank you.

  • Status changed to Needs work 5 months ago
  • šŸ‡µšŸ‡­Philippines clarkssquared

    I applied MR !3 and after executing the PHPCS command I can see that there are still many PHPCS issues being reported.

    āžœ  devel_ip git:(8.x-1.x) curl https://git.drupalcode.org/project/devel_ip/-/merge_requests/3.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  3713    0  3713    0     0   7694      0 --:--:-- --:--:-- --:--:--  7984
    patching file 'src/Form/DevelIpForm.php'
    patching file 'src/Form/DevelRangeForm.php'
    patching file 'src/Routing/RoutingAccess.php'
    āžœ  devel_ip git:(8.x-1.x) āœ— ..
    āžœ  drupal_local git:(main) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml devel_ip                   
    
    FILE: /Users/clarksubing-subing/Projects/d10/drupal_local/devel_ip/devel_ip.module
    ---------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    ---------------------------------------------------------------------------------------------------
     27 | ERROR | Doc comment is empty
     30 | ERROR | devel_ip_uninstall() is an installation hook and must be declared in an install file
    ---------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d10/drupal_local/devel_ip/README.md
    ----------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    ----------------------------------------------------------------------------
     13 | WARNING | Line exceeds 80 characters; contains 184 characters
     19 | WARNING | Line exceeds 80 characters; contains 139 characters
    ----------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d10/drupal_local/devel_ip/devel_ip.info.yml
    ----------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------
     5 | WARNING | All dependencies must be prefixed with the project name, for example "drupal:"
    ----------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d10/drupal_local/devel_ip/src/Form/DevelRangeForm.php
    ----------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 6 WARNINGS AFFECTING 6 LINES
    ----------------------------------------------------------------------------------------------------------------------------------------
      39 | WARNING | Unused variable $config.
      44 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
      87 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t()
         |         | instead
      99 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t()
         |         | instead
     126 | WARNING | Unused variable $name_field.
     171 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    ----------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d10/drupal_local/devel_ip/src/Form/DevelIpForm.php
    ----------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 6 WARNINGS AFFECTING 6 LINES
    ----------------------------------------------------------------------------------------------------------------------------------------
      39 | WARNING | Unused variable $config.
      43 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
      67 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t()
         |         | instead
      77 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t()
         |         | instead
     101 | WARNING | Unused variable $name_field.
     167 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    ----------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d10/drupal_local/devel_ip/src/Routing/RoutingAccess.php
    ------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
    ------------------------------------------------------------------------------------------------
     23 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     26 | 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
     33 | WARNING | Unused variable $key.
    ------------------------------------------------------------------------------------------------
    
    Time: 326ms; Memory: 10MB
    
    āžœ  drupal_local git:(main) āœ— 
    
Production build 0.71.5 2024