Fix the issues reported by PHP_CodeSniffer

Created on 24 September 2024, about 2 months ago

Problem/Motivation

FILE: modules\condition_pack\condition_pack_date\src\Plugin\Condition\DateBeforeCondition.php
---------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 5 WARNINGS AFFECTING 5 LINES
---------------------------------------------------------------------------------------------------------------------------------------------
6 | WARNING | [x] Unused use statement
7 | WARNING | [x] Unused use statement
9 | WARNING | [x] Unused use statement
10 | WARNING | [x] Unused use statement
10 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\condition_pack_date\Plugin\Condition\Date.
15 | WARNING | [ ] Line exceeds 80 characters; contains 83 characters
---------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------

FILE: modules\condition_pack\condition_pack_date\tests\src\Functional\DateBeforeConditionTest.php
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------
6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Tests\block\Traits\BlockCreationTrait.
--------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------------

FILE: modules\condition_pack\condition_pack_date\tests\src\Functional\DateConditionTest.php
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------
6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Tests\block\Traits\BlockCreationTrait.
--------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------------

FILE: modules\condition_pack\condition_pack_time\src\Plugin\Condition\TimeCondition.php
-----------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------
99 | WARNING | [x] '@TODO: fancier / longer caching based on settings.' should match the format '@todo Fix problem X here.'
-----------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------

FILE: modules\condition_pack\README.md
-----------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
-----------------------------------------------------------------------
3 | WARNING | [ ] Line exceeds 80 characters; contains 83 characters
14 | ERROR | [x] Expected 1 newline at end of file; 2 found
-----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 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

2.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
  • šŸ‡®šŸ‡¹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.

  • šŸ‡µšŸ‡­Philippines cleavinjosh
  • šŸ‡µšŸ‡­Philippines cleavinjosh
  • šŸ‡µšŸ‡­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. However, I still encountered some issues after I ran phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml:

    āžœ  condition_pack git:(2.0.x) curl https://git.drupalcode.org/project/condition_pack/-/merge_requests/3.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  3686    0  3686    0     0   8918      0 --:--:-- --:--:-- --:--:--  8903
    patching file README.md
    patching file condition_pack_date/src/Plugin/Condition/DateBeforeCondition.php
    patching file condition_pack_date/tests/src/Functional/DateBeforeConditionTest.php
    patching file condition_pack_date/tests/src/Functional/DateConditionTest.php
    patching file condition_pack_time/src/Plugin/Condition/TimeCondition.php
    āžœ  condition_pack git:(2.0.x) āœ— ..
    āžœ  contrib git:(main) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml condition_pack
    
    FILE: /Users/interns/Demo-site/drupal_11_test/install-dir/drupal_11_test_site/web/modules/contrib/condition_pack/condition_pack_ab/condition_pack_ab.info.yml
    -------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------------------------------------------
     1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
    -------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal_11_test/install-dir/drupal_11_test_site/web/modules/contrib/condition_pack/condition_pack_date/condition_pack_date.info.yml
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------
     1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal_11_test/install-dir/drupal_11_test_site/web/modules/contrib/condition_pack/condition_pack_time/condition_pack_time.info.yml
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------
     1 | WARNING | Remove "version" from the info file, it will be added by drupal.org packaging automatically
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 241ms; Memory: 10MB
    
    āžœ  contrib git:(main) āœ—

    Thank you.

  • šŸ‡µšŸ‡­Philippines cleavinjosh

    cleavinjosh ā†’ changed the visibility of the branch 3476335-phpcs-issues to hidden.

  • šŸ‡µšŸ‡­Philippines cleavinjosh
Production build 0.71.5 2024