Drupal Coding Standards Issues | phpcs

Created on 4 February 2023, almost 2 years ago
Updated 2 June 2023, over 1 year ago

Problem/Motivation

Getting Following errors/warnings

FILE: D:\xampp\htdocs\drupal9.5\modules\confetti\js\confetti.js
--------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
--------------------------------------------------------------------------------
  1 | ERROR | [x] End of line character is invalid; expected "\n" but found
    |       |     "\r\n"
 40 | ERROR | [x] Expected 1 newline at end of file; 2 found
 41 | ERROR | [x] Additional whitespace found at end of file
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------


FILE: ...\xampp\htdocs\drupal9.5\modules\confetti\src\Form\ConfettiSettingsForm.php
--------------------------------------------------------------------------------
FOUND 143 ERRORS AND 1 WARNING AFFECTING 139 LINES
--------------------------------------------------------------------------------
   1 | ERROR   | [x] End of line character is invalid; expected "\n" but found
     |         |     "\r\n"
  13 | WARNING | [ ] The class short comment should describe what the class
     |         |     does and not simply repeat the class name
  16 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
  19 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
  20 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  21 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
  23 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
  26 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
  27 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  28 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
  30 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
  32 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
  35 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
  36 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  37 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  38 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  39 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
  40 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  42 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  43 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
  44 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
  45 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
  46 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
  47 | ERROR   | [x] Array indentation error, expected 14 spaces but found 16
  49 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
  50 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
  51 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
  52 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
  55 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  56 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  57 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  58 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
  59 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 16
  60 | ERROR   | [x] Array indentation error, expected 18 spaces but found 20
  61 | ERROR   | [x] Array indentation error, expected 22 spaces but found 24
  62 | ERROR   | [x] Array indentation error, expected 22 spaces but found 24
  65 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
  66 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  68 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  69 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  70 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
  71 | ERROR   | [x] Array indentation error, expected 14 spaces but found 16
  72 | ERROR   | [x] Array indentation error, expected 18 spaces but found 20
  75 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
  76 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 16
  77 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
  78 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  80 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  81 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
  82 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
  83 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
  84 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
  85 | ERROR   | [x] Array indentation error, expected 14 spaces but found 16
  86 | ERROR   | [x] Array indentation error, expected 14 spaces but found 16
  89 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  90 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  91 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
  92 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
  93 | ERROR   | [x] Array indentation error, expected 10 spaces but found 12
  96 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
  97 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
  97 | ERROR   | [x] Expected 1 blank line after function; 0 found
  98 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
  98 | ERROR   | [x] Missing function doc comment
  99 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 100 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 101 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 102 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 16
 103 | ERROR   | [x] Line indented incorrectly; expected 10 spaces, found 20
 104 | ERROR   | [x] Line indented incorrectly; expected 10 spaces, found 20
 105 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 16
 106 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 107 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 108 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 109 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 110 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 16
 111 | ERROR   | [x] Line indented incorrectly; expected 10 spaces, found 20
 112 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 16
 113 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 16
 114 | ERROR   | [x] Line indented incorrectly; expected 10 spaces, found 20
 114 | ERROR   | [x] Expected 1 space after comma in argument list; 2 found
 114 | ERROR   | [x] Expected one space after the comma, 2 found
 115 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 16
 116 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 117 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 118 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 120 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 123 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 125 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 126 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 127 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 128 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 129 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 130 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 131 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 16
 132 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 16
 133 | ERROR   | [x] Line indented incorrectly; expected 10 spaces, found 20
 134 | ERROR   | [x] Line indented incorrectly; expected 12 spaces, found 24
 135 | ERROR   | [x] Line indented incorrectly; expected 12 spaces, found 24
 136 | ERROR   | [x] Line indented incorrectly; expected 12 spaces, found 24
 137 | ERROR   | [x] Line indented incorrectly; expected 12 spaces, found 24
 138 | ERROR   | [x] Line indented incorrectly; expected 14 spaces, found 28
 139 | ERROR   | [x] Line indented incorrectly; expected 14 spaces, found 28
 140 | ERROR   | [x] Line indented incorrectly; expected 12 spaces, found 24
 141 | ERROR   | [x] Line indented incorrectly; expected 10 spaces, found 20
 142 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 16
 143 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 144 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 145 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 146 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 147 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 16
 148 | ERROR   | [x] Line indented incorrectly; expected 10 spaces, found 20
 149 | ERROR   | [x] Line indented incorrectly; expected 10 spaces, found 20
 150 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 16
 151 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 152 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 153 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 154 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 155 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 156 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 16
 157 | ERROR   | [x] Line indented incorrectly; expected 10 spaces, found 20
 158 | ERROR   | [x] Line indented incorrectly; expected 10 spaces, found 20
 159 | ERROR   | [x] Line indented incorrectly; expected 10 spaces, found 20
 160 | ERROR   | [x] Line indented incorrectly; expected 10 spaces, found 20
 161 | ERROR   | [x] Line indented incorrectly; expected 12 spaces, found 24
 162 | ERROR   | [x] Line indented incorrectly; expected 12 spaces, found 24
 163 | ERROR   | [x] Line indented incorrectly; expected 10 spaces, found 20
 164 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 16
 165 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
 166 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 167 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 168 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 169 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 171 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 174 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 175 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 176 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 177 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 179 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 190 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 191 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
 192 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
 192 | ERROR   | [x] Expected 1 blank line after function; 0 found
 193 | ERROR   | [x] The closing brace for the class must have an empty line
     |         |     before it
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 143 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

Time: 454ms; Memory: 8MB

Proposed resolution

Fix the errors and warnings.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇮🇳India Kamlesh Kishor Jha Jaipur

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

Comments & Activities

  • Issue created by @Kamlesh Kishor Jha
  • @kamlesh-kishor-jha opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review almost 2 years ago
  • 🇮🇳India Kamlesh Kishor Jha Jaipur

    Created mr for this issue.
    Please review this mr.
    Thanks.

  • 🇮🇳India nayana_mvr

    Verified the MR!2 and tested it on Drupal version 9.5.x and Confetti version 1.0.x. The changes were applied cleanly. All the errors mentioned in the ticket are fixed but there are few warning messages as follows:-

    FILE: ../confetti/src/Form/ConfettiSettingsForm.php
    ------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 13 WARNINGS AFFECTING 12 LINES
    ------------------------------------------------------------------------------------------------------------------------------------------
      49 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
      50 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
      50 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
      55 | WARNING | Unused variable $rows.
      58 | WARNING | Unused variable $key.
      76 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     110 | WARNING | Unused variable $key.
     120 | WARNING | Unused variable $url.
     145 | WARNING | Node::load calls should be avoided in classes, use dependency injection instead
     148 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     155 | WARNING | Unused variable $key.
     168 | WARNING | Node::load calls should be avoided in classes, use dependency injection instead
     171 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    ------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 122ms; Memory: 10MB
    
  • First commit to issue fork.
  • 🇵🇹Portugal guilherme-lima-almeida Lisbon

    Hi Kamlesh Kishor Jha,

    I'm still getting these errors with the PHPCS. I'll fix this on your fork and approve the merge request.

    ---------------------------------------------------------------------------------------
    FOUND 14 ERRORS AFFECTING 14 LINES
    ---------------------------------------------------------------------------------------
      1 | ERROR | [x] Missing file doc comment
      5 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 1
      6 | ERROR | [x] Expected 2 space(s) before asterisk; 1 found
      7 | ERROR | [x] Expected 2 space(s) before asterisk; 1 found
     24 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
     26 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
     27 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
     28 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
     30 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
     31 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
     32 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
     33 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 12
     34 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 8
     35 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
    ---------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 14 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------
    
    Time: 78ms; Memory: 8MB
  • Status changed to Fixed over 1 year ago
  • 🇵🇹Portugal guilherme-lima-almeida Lisbon

    Sorry nayana_mvr,

    I was using Drupal Standard on PHPCS and not DrupalPractice. I've already made the changes pointed out by DrupalPractice.

    Thanks for the help, everyone.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024