GitlabCI: Fix PHPCS and PHPStan validation errors

Created on 27 December 2023, 11 months ago
Updated 16 August 2024, 3 months ago

Problem/Motivation

Steps to reproduce

Running phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig shows the following warnings/errors, which should be fixed.

Result:

FILE: ...toolbar/admin_toolbar_tools/src/Plugin/Derivative/ExtraLinks.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\Core\Config\ConfigFactoryInterface.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ...toolbar/admin_toolbar_tools/src/Controller/ToolbarController.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 17 | ERROR | [x] Use statements should be sorted alphabetically. The
    |       |     first wrong one is
    |       |     Drupal\Core\Template\TwigEnvironment.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ...m/admin_toolbar/admin_toolbar_search/admin_toolbar_search.module
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 9 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\Core\Routing\RouteMatchInterface.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: /app/web/modules/custom/admin_toolbar/admin_toolbar.module
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
 11 | ERROR | [x] Use statements should be sorted alphabetically. The
    |       |     first wrong one is Drupal\Component\Utility\Html.
 60 | ERROR | [ ] All functions defined in a module file must be
    |       |     prefixed with the module's name, found
    |       |     "toolbar_tools_menu_navigation_links" but expected
    |       |     "admin_toolbar_toolbar_tools_menu_navigation_links"
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ...bar_links_access_filter/admin_toolbar_links_access_filter.module
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 11 | ERROR | [x] Use statements should be sorted alphabetically. The
    |       |     first wrong one is
    |       |     Drupal\Core\Routing\RouteMatchInterface.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

šŸ“Œ Task
Status

Fixed

Version

3.0

Component

Code

Created by

šŸ‡®šŸ‡³India Tirupati_Singh

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

Merge Requests

Comments & Activities

  • Issue created by @Tirupati_Singh
  • Open on Drupal.org ā†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 8
    last update 11 months ago
    Waiting for branch to pass
  • Issue was unassigned.
  • Status changed to Needs review 11 months ago
  • šŸ‡®šŸ‡³India Tirupati_Singh

    I've fixed phpcs issues please review.

  • šŸ‡µšŸ‡­Philippines clarkssquared

    Hi

    I confirmed that your MR !66 fixes most of the issues but I will retain the status to needs review because there is still a PHPCS warnings flagged in the module so that others can review and give feedback if the warnings needs to be fixed or can be ignored.

    āžœ  admin_toolbar git:(master) āœ— curl https://git.drupalcode.org/project/admin_toolbar/-/merge_requests/66.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  5437    0  5437    0     0  10558      0 --:--:-- --:--:-- --:--:-- 10681
    patching file admin_toolbar.module
    patching file 'admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.module'
    patching file 'admin_toolbar_search/admin_toolbar_search.module'
    patching file 'admin_toolbar_tools/src/Controller/ToolbarController.php'
    patching file 'admin_toolbar_tools/src/Plugin/Derivative/ExtraLinks.php'
    patching file 'src/Render/Element/AdminToolbar.php'
    āžœ  admin_toolbar git:(master) āœ— ..
    āžœ  contrib git:(master) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml admin_toolbar 
    
    FILE: ...bing-subing/Projects/d9/d9-local/web/modules/contrib/admin_toolbar/admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.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: /Users/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/admin_toolbar/admin_toolbar_search/admin_toolbar_search.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: /Users/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.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: /Users/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/admin_toolbar/admin_toolbar.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
    -------------------------------------------------------------------------------------------------------------
    
    Time: 937ms; Memory: 16MB
    
    āžœ  contrib git:(master) āœ— 
    
    
  • šŸ‡®šŸ‡³India Tirupati_Singh

    Hi @clarkssquared, I've run the phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig command but didn't get any mentioned warnings. Attaching the screenshot for your reference.

  • šŸ‡®šŸ‡³India dev16.addweb

    After applying patch, I'm still receiving several phpcs problems.

    FILE: /home/addweb/Drupal8-vagrant/web/web/drupal_10_2_6/web/modules/contrib/admin_toolbar/admin_toolbar_search/admin_toolbar_search.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: /home/addweb/Drupal8-vagrant/web/web/drupal_10_2_6/web/modules/contrib/admin_toolbar/admin_toolbar.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: /home/addweb/Drupal8-vagrant/web/web/drupal_10_2_6/web/modules/contrib/admin_toolbar/PATCHES.txt
    ------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
    ------------------------------------------------------------------------------------------------------
     1 | WARNING | [ ] Line exceeds 80 characters; contains 104 characters
     5 | ERROR   | [x] Expected 1 newline at end of file; 3 found
    ------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------
    
    
    FILE: /home/addweb/Drupal8-vagrant/web/web/drupal_10_2_6/web/modules/contrib/admin_toolbar/admin_toolbar_tools/admin_toolbar_tools.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: /home/addweb/Drupal8-vagrant/web/web/drupal_10_2_6/web/modules/contrib/admin_toolbar/admin_toolbar_links_access_filter/admin_toolbar_links_access_filter.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
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
  • Open on Drupal.org ā†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 8
    last update 6 months ago
    Waiting for branch to pass
  • šŸ‡®šŸ‡³India Tirupati_Singh

    @silvi.addweb, I've fixed the phpcs issues. Please apply the patch again and verify the changes.

  • Status changed to RTBC 6 months ago
  • šŸ‡®šŸ‡³India dev16.addweb

    Hii,
    Yes, I've checked and all phpcs issues are resolved now.

  • First commit to issue fork.
  • šŸ‡®šŸ‡³India rajeshreeputra Pune

    Changes looks good, CI passing, can we get it merged? this will unblock the Drupal 11 compatibility issue - šŸ“Œ Add Drupal 11 support Needs review .
    Thanks!

  • Pipeline finished with Failed
    4 months ago
    Total: 964s
    #241905
  • Pipeline finished with Failed
    4 months ago
    Total: 504s
    #241924
  • Pipeline finished with Failed
    4 months ago
    Total: 369s
    #241935
  • Pipeline finished with Failed
    4 months ago
    Total: 331s
    #241966
  • Pipeline finished with Success
    4 months ago
    Total: 374s
    #241969
  • Status changed to Needs review 4 months ago
  • šŸ‡«šŸ‡·France dydave

    Rebased MR!66 on 3.x with gitlabci tests and required phpcs and phpstan jobs to pass.

    āœ… Merge request seems to complete successfully with all PHPCS and PHPSTAN validation errors fixed, see:

     
    Back to Needs review for more reviews, testing and feedback.
    Thanks!

  • First commit to issue fork.
  • Pipeline finished with Success
    4 months ago
    Total: 426s
    #242227
  • šŸ‡«šŸ‡·France dydave

    Thanks Jakob (@japerry)!

    Ticket's merge request MR!66 should be completing successfully with PHPCS and PHPStan jobs passing šŸŸ¢

    Everything is green except ESLint:
    https://git.drupalcode.org/issue/admin_toolbar-3411005/-/pipelines/242227

    Hope we could get this one in as well!
    Thanks in advance!

  • Pipeline finished with Skipped
    4 months ago
    #242254
  • Status changed to Fixed 4 months ago
  • šŸ‡ŗšŸ‡øUnited States japerry KVUO
  • šŸ‡ŗšŸ‡øUnited States japerry KVUO

    Made PHPstan optional as its more likely to change due to no fault of the module.

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

Production build 0.71.5 2024