Fix the issues reported by PHP_CodeSniffer

Created on 26 September 2024, about 2 months ago

Problem/Motivation

FILE: lazy_service\lazy_service.info.yml
-------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------
1 | WARNING | Remove "project" from the info file, it will be added by drupal.org packaging automatically
1 | WARNING | Remove "datestamp" from the info file, it will be added by drupal.org packaging automatically
1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
-------------------------------------------------------------------------------------------------------------

FILE: lazy_service\lazy_service_example\lazy_service_example.info.yml
-------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------
1 | WARNING | Remove "project" from the info file, it will be added by drupal.org packaging automatically
1 | WARNING | Remove "datestamp" from the info file, it will be added by drupal.org packaging automatically
1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
-------------------------------------------------------------------------------------------------------------

FILE: lazy_service\lazy_service_example\src\EventSubscriber\LazyServiceSubscriber.php
-------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------
17 | ERROR | [x] Expected 1 blank line after function; 0 found
-------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------

FILE: lazy_service\lazy_service_example\src\EventSubscriber\myLazyInterface.php
-------------------------------------------------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 3 LINES
-------------------------------------------------------------------------------------------------------------
3 | ERROR | [x] There must be one blank line after the namespace declaration
6 | ERROR | [x] Missing interface doc comment
6 | ERROR | [ ] Interface name must begin with a capital letter
8 | ERROR | [x] Missing function doc comment
-------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------

FILE: lazy_service\lazy_service_example\src\myLazy.php
------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
------------------------------------------------------------------------------------
11 | ERROR | [ ] Class name must begin with a capital letter
17 | ERROR | [x] Missing function doc comment
------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------

FILE: lazy_service\README.txt
------------------------------------------------------------------------
FOUND 1 ERROR AND 11 WARNINGS AFFECTING 11 LINES
------------------------------------------------------------------------
12 | WARNING | [ ] Line exceeds 80 characters; contains 377 characters
13 | WARNING | [ ] Line exceeds 80 characters; contains 421 characters
19 | WARNING | [ ] Line exceeds 80 characters; contains 433 characters
21 | WARNING | [ ] Line exceeds 80 characters; contains 422 characters
25 | WARNING | [ ] Line exceeds 80 characters; contains 206 characters
32 | WARNING | [ ] Line exceeds 80 characters; contains 128 characters
34 | WARNING | [ ] Line exceeds 80 characters; contains 157 characters
35 | WARNING | [ ] Line exceeds 80 characters; contains 243 characters
37 | WARNING | [ ] Line exceeds 80 characters; contains 181 characters
39 | WARNING | [ ] Line exceeds 80 characters; contains 273 characters
41 | WARNING | [ ] Line exceeds 80 characters; contains 96 characters
41 | ERROR | [x] Expected 1 newline at end of file; 2 found
------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------

FILE: lazy_service\src\LazyServiceServiceProvider.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 8 ERRORS AND 3 WARNINGS AFFECTING 10 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
11 | ERROR | [x] Missing class doc comment
15 | ERROR | [x] Missing function doc comment
32 | WARNING | [x] 'TODO: Make all this recursive.' should match the format '@todo Fix problem X here.'
36 | ERROR | [x] There should be no white space after an opening "("
53 | WARNING | [x] 'TODO: Check class has not been already generated.' should match the format '@todo Fix problem X here.'
57 | WARNING | [x] 'TODO' should match the format '@todo Fix problem X here.'
57 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
78 | ERROR | [x] Missing function doc comment
104 | ERROR | [ ] The array declaration extends to column 174 (the limit is 120). The array content should be split up over multiple lines
113 | ERROR | [x] Expected 1 blank line after function; 0 found
114 | ERROR | [x] The closing brace for the class must have an empty line before it
----------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 10 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------

Steps to reproduce

Run phpcs command to get the drupal coding standard issues.

Proposed resolution

Many of the issues can be fixed by running the phpcbf command. For the remaining ones, we will need to manually address and then commit these changes before pushing them.

šŸ“Œ Task
Status

Needs work

Version

1.0

Component

Code

Created by

šŸ‡ŗšŸ‡øUnited States sunil jolapara 3265 Summitrun Drive, Independence, KY, 41051

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

Merge Requests

Comments & Activities

  • Issue created by @sunil jolapara
  • šŸ‡ŗšŸ‡øUnited States sunil jolapara 3265 Summitrun Drive, Independence, KY, 41051
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi @sunil jolapara,

    Thank you for providing an MR. I applied MR!3, 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:

    āžœ  lazy_service git:(1.0.0-alpha1) curl https://git.drupalcode.org/project/lazy_service/-/merge_requests/3.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 13661    0 13661    0     0  29852      0 --:--:-- --:--:-- --:--:-- 29827
    patching file README.txt
    patching file lazy_service_example/src/EventSubscriber/LazyServiceSubscriber.php
    patching file lazy_service_example/src/EventSubscriber/myLazyInterface.php
    patching file lazy_service_example/src/myLazy.php
    patching file src/LazyServiceServiceProvider.php
    āžœ  lazy_service git:(1.0.0-alpha1) āœ— ..
    āžœ  contrib git:(main) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml lazy_service
    
    FILE: /Users/interns/Demo-site/drupal_11_test/install-dir/drupal_11_test_site/web/modules/contrib/lazy_service/lazy_service_example/src/myLazy.php
    --------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------------------------------------------------
     11 | ERROR | Class name doesn't match filename; expected "class myLazy"
    --------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal_11_test/install-dir/drupal_11_test_site/web/modules/contrib/lazy_service/lazy_service_example/src/EventSubscriber/myLazyInterface.php
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     8 | ERROR | Interface name doesn't match filename; expected "interface myLazyInterface"
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 123ms; Memory: 10MB
    
    āžœ  contrib git:(main) āœ—

    Thank you.

  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹

    The issue summary for PHP_CodeSniffer issues should always show the report given from PHP_CodeSniffer and the arguments passed to phpcs.

    Furthermore, since GitLab CI is now enabled for all the projects, GitLab CI should be used to get PHP_CodeSniffer errors/warnings.

  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • Pipeline finished with Success
    15 days ago
    Total: 151s
    #330960
  • šŸ‡µšŸ‡­Philippines cleavinjosh
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    My Apologies @kul.pratap. I forgot to assign the issue to myself.

  • Pipeline finished with Success
    15 days ago
    #331035
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi,

    Please review, check and advise on MR!3.

    Thank you.

Production build 0.71.5 2024