Fix the issue reported by phpcs

Created on 27 September 2023, about 1 year ago
Updated 20 August 2024, 3 months ago

Problem/Motivation

Getting following error/warnings:

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\wide_animation_slider\css\style.css
---------------------------------------------------------------------------------------
FOUND 57 ERRORS AFFECTING 57 LINES
---------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
2 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
3 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
4 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
5 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
6 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
7 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
8 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
12 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
13 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
14 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
15 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
16 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
18 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
19 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
20 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
25 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
29 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
32 | ERROR | [x] Expected 1 space before opening brace of class definition; 0 found
33 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
34 | 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 2 spaces, found 4
37 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
38 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
39 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
40 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
41 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
42 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
43 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
44 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
45 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
51 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
52 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
53 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
54 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
55 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
56 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
57 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
58 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
59 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
60 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
61 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
62 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
63 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
64 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
68 | ERROR | [ ] More than 2 empty lines are not allowed
77 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
78 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
87 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
88 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
98 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
99 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
108 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
109 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
118 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
119 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 0
---------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 56 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\wide_animation_slider\README.md
-----------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------
29 | ERROR | [x] Expected 1 newline at end of file; 2 found
-----------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\wide_animation_slider\src\Form\WideSliderForm.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"
7 | WARNING | [x] Unused use statement
8 | WARNING | [x] Unused use statement
46 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
47 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
75 | ERROR | [x] Whitespace found at end of line
-----------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\wide_animation_slider\src\Plugin\Block\WideSliderBlock.php
--------------------------------------------------------------------------------------------------------------
FOUND 35 ERRORS AFFECTING 18 LINES
--------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
3 | ERROR | [x] Namespaced classes, interfaces and traits should not begin with a file doc comment
26 | ERROR | [x] Expected 1 blank line before function; 0 found
41 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
41 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 4
42 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
42 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 4
43 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
43 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found 4
44 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
44 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 3
44 | ERROR | [x] Closing brace indented incorrectly; expected 6 spaces, found 3
52 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
52 | ERROR | [x] Line indented incorrectly; expected at least 4 spaces, found 3
52 | ERROR | [x] Array indentation error, expected 6 spaces but found 3
53 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
53 | ERROR | [x] Line indented incorrectly; expected at least 4 spaces, found 3
53 | ERROR | [x] Array indentation error, expected 6 spaces but found 3
54 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
54 | ERROR | [x] Line indented incorrectly; expected at least 4 spaces, found 3
54 | ERROR | [x] Array indentation error, expected 6 spaces but found 3
55 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
55 | ERROR | [x] Line indented incorrectly; expected at least 4 spaces, found 3
55 | ERROR | [x] Array indentation error, expected 6 spaces but found 3
56 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
56 | ERROR | [x] Line indented incorrectly; expected at least 4 spaces, found 3
56 | ERROR | [x] Array indentation error, expected 6 spaces but found 3
57 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
57 | ERROR | [x] Array indentation error, expected 5 spaces but found 4
58 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
58 | ERROR | [x] Array indentation error, expected 6 spaces but found 5
59 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
60 | ERROR | [x] Array closing indentation error, expected 3 spaces but found 6
62 | ERROR | [x] Expected 1 blank line after function; 0 found
63 | ERROR | [x] The closing brace for the class must have an empty line before it
--------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 35 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\wide_animation_slider\wide_animation_slider.module
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 2 WARNINGS AFFECTING 5 LINES
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
8 | WARNING | [x] Unused use statement
11 | WARNING | [ ] Format should be "* Implements hook_foo().", "* Implements hook_foo_BAR_ID_bar() for xyz_bar().",, "* Implements hook_foo_BAR_ID_bar() for xyz-bar.html.twig.", "* Implements hook_foo_BAR_ID_bar() for
| | xyz-bar.tpl.php.", or "* Implements hook_foo_BAR_ID_bar() for block templates."
19 | ERROR | [x] Expected 1 space after "=>"; 2 found
27 | ERROR | [x] Missing function doc comment
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------------------

Steps to reproduce

Run following command:

phpcbs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml wide_animation_slider/

Proposed resolution

Above error/warnings need to be fixed

Remaining tasks

User interface changes

API changes

Data model changes

šŸ“Œ Task
Status

Needs work

Version

1.0

Component

Code

Created by

šŸ‡®šŸ‡³India arti_parmar

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

Comments & Activities

  • Issue created by @arti_parmar
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • šŸ‡®šŸ‡³India arti_parmar

    Kindly review patch.

  • Status changed to Needs work about 1 year ago
  • šŸ‡®šŸ‡³India Bhupendra_Raykhere indore mp

    Hi @arti_parmar,
    I have tested your patch it is not applied successfully. Please refer screenshot

  • Status changed to Needs review about 1 year ago
  • šŸ‡®šŸ‡³India mrinalini9 New Delhi

    Rerolled patch #2, please review it.

    Thanks!

  • šŸ‡®šŸ‡³India VijaySharma_89

    hello @mrinalini9, I have applied your patch, and your patch is successfully applied. But Some errors also remain. I have fixed the issue and provided an updated patch. and also provide a screenshot for your reference.

  • Status changed to Needs work 3 months ago
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi @VijaySharma_89,

    I applied patch #5, it was applied smoothly and fixed most of the phpcs issues.

    These are the remaining issues after I ran phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml:

    āžœ  wide_animation_slider git:(1.0.x) curl https://www.drupal.org/files/issues/2023-10-04/3390152-updated-patch.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  8777  100  8777    0     0  19214      0 --:--:-- --:--:-- --:--:-- 19247
    patching file README.md
    patching file css/style.css
    patching file src/Form/WideSliderForm.php
    patching file src/Plugin/Block/WideSliderBlock.php
    patching file wide_animation_slider.module
    patching file wide_animation_slider.routing.yml
    āžœ  wide_animation_slider git:(1.0.x) āœ— ..
    āžœ  contrib phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml wide_animation_slider
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/wide_animation_slider/src/Form/WideSliderForm.php
    -----------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
    -----------------------------------------------------------------------------------------------------------------------------------------
     51 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     63 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     69 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     89 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    -----------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/wide_animation_slider/src/Plugin/Block/WideSliderBlock.php
    -------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 7 WARNINGS AFFECTING 7 LINES
    -------------------------------------------------------------------------------------------------------------------------------
     24 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     25 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     28 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     33 | WARNING | Unused variable $wide_title.
     34 | WARNING | Unused variable $wide_link.
     37 | WARNING | File::load calls should be avoided in classes, use dependency injection instead
     39 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    -------------------------------------------------------------------------------------------------------------------------------
    
    Time: 130ms; Memory: 10MB
    
    āžœ  contrib
Production build 0.71.5 2024