Fix the issues reported by PHP_CodeSniffer

Created on 27 September 2024, about 2 months ago

Problem/Motivation

FILE: modules\lory\lory.module
------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------
20 | ERROR | All functions defined in a module file must be prefixed with the module's name, found "lory" but expected "lory_lory"
------------------------------------------------------------------------------------------------------------------------------------

FILE: modules\lory\lory.theme.inc
-------------------------------------------------------------------------------------------------------------------------------
FOUND 7 ERRORS AFFECTING 7 LINES
-------------------------------------------------------------------------------------------------------------------------------
9 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Component\Serialization\Json.
18 | ERROR | [x] Use null coalesce operator instead of ternary operator.
19 | ERROR | [x] Use null coalesce operator instead of ternary operator.
20 | ERROR | [x] Use null coalesce operator instead of ternary operator.
83 | ERROR | [x] Use null coalesce operator instead of ternary operator.
86 | ERROR | [x] Use null coalesce operator instead of ternary operator.
117 | ERROR | [x] Use null coalesce operator instead of ternary operator.
-------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------

FILE: modules\lory\modules\example\config\optional\lory.optionset.asnavfor_nav.yml
----------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------
19 | ERROR | [x] Expected 1 newline at end of file; 0 found
----------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------

FILE: modules\lory\modules\ui\src\Controller\LoryListBuilder.php
------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------------------
7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\EntityInterface.
127 | ERROR | [x] Use null coalesce operator instead of ternary operator.
------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------

FILE: modules\lory\modules\ui\src\Form\LoryDeleteForm.php
-------------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------------------------------------------------
6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\EntityConfirmFormBase.
42 | ERROR | [ ] The array declaration extends to column 136 (the limit is 120). The array content should be split up over multiple lines
-------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------------------

FILE: modules\lory\modules\ui\src\Form\LoryForm.php
------------------------------------------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AND 1 WARNING AFFECTING 7 LINES
------------------------------------------------------------------------------------------------------------------------------------
7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\EntityTypeInterface.
274 | ERROR | [x] Use null coalesce operator instead of ternary operator.
275 | ERROR | [x] Use null coalesce operator instead of ternary operator.
286 | WARNING | [x] '@todo: Enable when ready.' should match the format '@todo Fix problem X here.'
296 | ERROR | [x] Use null coalesce operator instead of ternary operator.
298 | ERROR | [x] Use null coalesce operator instead of ternary operator.
341 | ERROR | [x] Use null coalesce operator instead of ternary operator.
------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------

FILE: modules\lory\src\Entity\Lory.php
---------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
---------------------------------------------------------------------------
117 | ERROR | [x] Use null coalesce operator instead of ternary operator.
163 | ERROR | [x] list(...) is forbidden, use [...] instead.
184 | ERROR | [x] Use null coalesce operator instead of ternary operator.
---------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------

FILE: modules\lory\src\Form\LoryAdmin.php
------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 7 ERRORS AFFECTING 7 LINES
------------------------------------------------------------------------------------------------------------------------------------------------
6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\StringTranslation\StringTranslationTrait.
75 | ERROR | [x] Use null coalesce operator instead of ternary operator.
76 | ERROR | [x] Use null coalesce operator instead of ternary operator.
77 | ERROR | [x] Use null coalesce operator instead of ternary operator.
118 | ERROR | [x] Use null coalesce operator instead of ternary operator.
123 | ERROR | [x] Use null coalesce operator instead of ternary operator.
226 | ERROR | [x] Use null coalesce operator instead of ternary operator.
------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------------------

FILE: modules\lory\src\LoryAssetManager.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AND 1 WARNING AFFECTING 6 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
191 | WARNING | [x] '@todo: Supports multiple transitions like random transitions.' should match the format '@todo Fix problem X here.'
192 | ERROR | [x] Use null coalesce operator instead of ternary operator.
195 | ERROR | [x] Use null coalesce operator instead of ternary operator.
203 | ERROR | [x] Use null coalesce operator instead of ternary operator.
206 | ERROR | [x] Use null coalesce operator instead of ternary operator.
230 | ERROR | [x] Use null coalesce operator instead of ternary operator.
-----------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------------------

FILE: modules\lory\src\LoryDefault.php
--------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------
90 | ERROR | [x] Use null coalesce operator instead of ternary operator.
91 | ERROR | [x] Use null coalesce operator instead of ternary operator.
--------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------

FILE: modules\lory\src\LoryFormatter.php
------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------------
6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\blazy\BlazyFormatter.
10 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------

FILE: modules\lory\src\LoryManager.php
----------------------------------------------------------------------------------------------------------------------
FOUND 7 ERRORS AND 1 WARNING AFFECTING 8 LINES
----------------------------------------------------------------------------------------------------------------------
6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\blazy\Blazy.
13 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
74 | ERROR | [x] Use null coalesce operator instead of ternary operator.
88 | ERROR | [x] Use null coalesce operator instead of ternary operator.
108 | ERROR | [x] Use null coalesce operator instead of ternary operator.
151 | ERROR | [x] Use null coalesce operator instead of ternary operator.
172 | ERROR | [x] Use null coalesce operator instead of ternary operator.
213 | ERROR | [x] Use null coalesce operator instead of ternary operator.
----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------

FILE: modules\lory\src\LoryManagerInterface.php
----------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------------
6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\blazy\BlazyManagerInterface.
----------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------

FILE: modules\lory\src\Plugin\Field\FieldFormatter\LoryEntityFormatterBase.php
-----------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------
6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\blazy\Dejavu\BlazyEntityBase.
-----------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------

FILE: modules\lory\src\Plugin\Field\FieldFormatter\LoryFileFormatterBase.php
----------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------
6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Component\Utility\Xss.
----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------

FILE: modules\lory\src\Plugin\Field\FieldFormatter\LoryFormatterTrait.php
-------------------------------------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 4 LINES
-------------------------------------------------------------------------------------------------
65 | ERROR | [x] Use null coalesce operator instead of ternary operator.
67 | ERROR | [x] Use null coalesce operator instead of ternary operator.
68 | ERROR | [x] Use null coalesce operator instead of ternary operator.
69 | ERROR | [x] Use null coalesce operator instead of ternary operator.
-------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------

FILE: modules\lory\src\Plugin\Field\FieldFormatter\LoryTextFormatter.php
----------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------------------
6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Field\FieldItemListInterface.
----------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------

FILE: modules\lory\src\Plugin\views\style\LoryViews.php
-----------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-----------------------------------------------------------------------------------------------------------------------------------
6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\blazy\Dejavu\BlazyStylePluginBase.
39 | ERROR | [x] Use null coalesce operator instead of ternary operator.
-----------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 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
  • šŸ‡®šŸ‡¹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, šŸ‡®šŸ‡¹
  • šŸ‡µšŸ‡­Philippines cleavinjosh
  • šŸ‡µšŸ‡­Philippines cleavinjosh
  • Pipeline finished with Failed
    9 days ago
    Total: 137s
    #336348
  • šŸ‡µšŸ‡­Philippines cleavinjosh

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

  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi @sunil jolapara,

    Thank you for providing an MR. I applied MR!1, it was applied smoothly and fixed most of the phpcs issues.

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

    āžœ  lory git:(8.x-1.x) curl https://git.drupalcode.org/project/lory/-/merge_requests/1.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 23758    0 23758    0     0  53238      0 --:--:-- --:--:-- --:--:-- 53269
    patching file lory.module
    patching file lory.theme.inc
    patching file modules/example/config/optional/lory.optionset.asnavfor_nav.yml
    patching file modules/ui/src/Controller/LoryListBuilder.php
    patching file modules/ui/src/Form/LoryDeleteForm.php
    patching file modules/ui/src/Form/LoryForm.php
    patching file src/Entity/Lory.php
    patching file src/Form/LoryAdmin.php
    patching file src/LoryAssetManager.php
    patching file src/LoryDefault.php
    patching file src/LoryFormatter.php
    patching file src/LoryManager.php
    patching file src/LoryManagerInterface.php
    patching file src/Plugin/Field/FieldFormatter/LoryEntityFormatterBase.php
    patching file src/Plugin/Field/FieldFormatter/LoryFileFormatterBase.php
    patching file src/Plugin/Field/FieldFormatter/LoryFormatterTrait.php
    patching file src/Plugin/Field/FieldFormatter/LoryTextFormatter.php
    patching file src/Plugin/views/style/LoryViews.php
    āžœ  lory git:(8.x-1.x) āœ— ..
    āžœ  contrib git:(main) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml lory
    
    FILE: /Users/interns/Demo-site/drupal_11_test/install-dir/drupal_11_test_site/web/modules/contrib/lory/src/Plugin/Field/FieldFormatter/LoryFileFormatterBase.php
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------
     97 | WARNING | Variable $thumb inside unset call is undefined.
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/interns/Demo-site/drupal_11_test/install-dir/drupal_11_test_site/web/modules/contrib/lory/src/Plugin/Field/FieldFormatter/LoryEntityFormatter.php
    --------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------------------------------------------------------------
     33 | WARNING | Variable $thumb inside unset call is undefined.
    --------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 1.02 secs; Memory: 12MB
    
    āžœ  contrib git:(main) āœ—

    Thank you.

  • Pipeline finished with Failed
    9 days ago
    Total: 136s
    #336384
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹

    avpaderno ā†’ changed the visibility of the branch 3477268-gitlab-ci-reports to hidden.

  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi,

    Please review, check and advise on MR!1.

    Thank you.

  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi @avpaderno,

    I addressed the thread.

    After I reverted the function name, it will display as an error after I ran

    āžœ  contrib git:(main) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml lory
    
    FILE: /Users/interns/Demo-site/drupal_11_test/install-dir/drupal_11_test_site/web/modules/contrib/lory/lory.module
    ------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------------------
     20 | ERROR | All functions defined in a module file must be prefixed with the module's name, found "lory" but expected "lory_lory"
    ------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 1.11 secs; Memory: 12MB
    
    āžœ  contrib git:(main) āœ—

    :

    āžœ  contrib git:(main) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml lory
    
    FILE: /Users/interns/Demo-site/drupal_11_test/install-dir/drupal_11_test_site/web/modules/contrib/lory/lory.module
    ------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------------------
     20 | ERROR | All functions defined in a module file must be prefixed with the module's name, found "lory" but expected "lory_lory"
    ------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 1.11 secs; Memory: 12MB
    
    āžœ  contrib git:(main) āœ—

    Please check and advise.
    Thank you.

Production build 0.71.5 2024