Fix issues reported by phpcs

Created on 25 May 2023, over 1 year ago
Updated 14 August 2024, 3 months ago

Problem/Motivation

Running phpcs returns following results:

FILE: /home/arpitkayare/drupal_9.5/web/modules/contrib/menu_admin_per_menu/src/Routing/RouteSubscriber.php
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------
22 | ERROR | The array declaration extends to column 176 (the limit is 80). The array content should be split up over multiple lines
--------------------------------------------------------------------------------------------------------------------------------------

FILE: /home/arpitkayare/drupal_9.5/web/modules/contrib/menu_admin_per_menu/src/Access/MenuAdminPerMenuAccess.php
----------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------------------------------------------------
26 | WARNING | Menu::loadMultiple calls should be avoided in classes, use dependency injection instead
35 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------------------------

FILE: /home/arpitkayare/drupal_9.5/web/modules/contrib/menu_admin_per_menu/tests/src/Kernel/MenuAdminPerMenuAccessTest.php
--------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------
17 | WARNING | The class short comment should describe what the class does and not simply repeat the class name
--------------------------------------------------------------------------------------------------------------------------

FILE: /home/arpitkayare/drupal_9.5/web/modules/contrib/menu_admin_per_menu/tests/src/Kernel/MenuAdminPerMenuPermissionsTest.php
-------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------------------
14 | WARNING | The class short comment should describe what the class does and not simply repeat the class name
-------------------------------------------------------------------------------------------------------------------------------

FILE: /home/arpitkayare/drupal_9.5/web/modules/contrib/menu_admin_per_menu/README.md
------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
------------------------------------------------------------------------------------
11 | WARNING | [ ] Line exceeds 80 characters; contains 192 characters
30 | ERROR | [x] Expected 1 newline at end of file; 6 found
------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------

Steps to reproduce

Run phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml . inside module folder.

Proposed resolution

Work on fixing errors/warnings. Create a patch.
Some issue have been taken care here https://www.drupal.org/project/menu_admin_per_menu/issues/3362741 šŸ“Œ Drupal calls should be avoided in classes, use dependency injection instead Needs review

Remaining tasks

User interface changes

NA

API changes

NA

Data model changes

NA

šŸ“Œ Task
Status

Needs review

Version

1.0

Component

Code

Created by

šŸ‡®šŸ‡³India arpitk

Live updates comments and jobs are added and updated live.
  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @arpitk
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • Open in Jenkins ā†’ Open on Drupal.org ā†’
    Core: 9.5.5 + Environment: PHP 7.3 & MySQL 5.7
    last update over 1 year ago
    15 pass
  • šŸ‡®šŸ‡³India arpitk

    Here is the patch please review.

    Thanks!

  • Status changed to Needs work over 1 year ago
  • šŸ‡µšŸ‡­Philippines kenyoOwen

    Hi arpitk

    After I applied your patch and there are still errors.

    phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml menu_admin_per_menu

    FILE: /Users/studenttrainees/Project10/drupalorg10/docroot/modules/contrib/menu_admin_per_menu/tests/src/Kernel/MenuAdminPerMenuAccessTest.php
    ----------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------------------------------------------------
    17 | WARNING | The class short comment should describe what the class does and not simply repeat the class name
    ----------------------------------------------------------------------------------------------------------------------------------------------

    FILE: /Users/studenttrainees/Project10/drupalorg10/docroot/modules/contrib/menu_admin_per_menu/tests/src/Kernel/MenuAdminPerMenuPermissionsTest.php
    ---------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------------------------------------
    14 | WARNING | The class short comment should describe what the class does and not simply repeat the class name
    ---------------------------------------------------------------------------------------------------------------------------------------------------

    FILE: /Users/studenttrainees/Project10/drupalorg10/docroot/modules/contrib/menu_admin_per_menu/src/Access/MenuAdminPerMenuAccess.php
    ------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------------------
    19 | ERROR | [x] Expected 1 space before opening brace; found 2
    ------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------------------------------

    Time: 919ms; Memory: 16MB

  • Assigned to nitin_lama
  • Open in Jenkins ā†’ Open on Drupal.org ā†’
    Core: 9.5.5 + Environment: PHP 7.3 & MySQL 5.7
    last update over 1 year ago
    15 pass
  • @nitin_lama opened merge request.
  • Open in Jenkins ā†’ Open on Drupal.org ā†’
    Core: 9.5.5 + Environment: PHP 7.3 & MySQL 5.7
    last update over 1 year ago
    15 pass
  • @nitin_lama opened merge request.
  • Open in Jenkins ā†’ Open on Drupal.org ā†’
    Core: 9.5.5 + Environment: PHP 7.3 & MySQL 5.7
    last update over 1 year ago
    15 pass
  • Issue was unassigned.
  • šŸ‡®šŸ‡³India nitin_lama India

    MR for the change.

  • Status changed to Needs review over 1 year ago
  • Status changed to Needs work 3 months ago
  • šŸ‡µšŸ‡­Philippines paraderojether

    Hi

    I reviewed MR!6, applied it against Menu Admin per Menu 8.x-1.x-dev and there are still remaining phpcs issue shown below:

    āžœ  menu_admin_per_menu git:(98d34cb) curl https://git.drupalcode.org/project/menu_admin_per_menu/-/merge_requests/16.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  4928    0  4928    0     0   9338      0 --:--:-- --:--:-- --:--:--  9476
    patching file README.md
    patching file 'src/Routing/RouteSubscriber.php'
    patching file 'tests/src/Kernel/MenuAdminPerMenuAccessTest.php'
    patching file 'tests/src/Kernel/MenuAdminPerMenuPermissionsTest.php'
    āžœ  menu_admin_per_menu git:(98d34cb) āœ— cd ..
    āžœ  contrib git:(main) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig menu_admin_per_menu
    
    FILE: /Users/jetherparadero/q3do/q3issues/web/modules/contrib/menu_admin_per_menu/src/Access/MenuAdminPerMenuAccess.php
    -----------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    -----------------------------------------------------------------------------------------------------------------------
     26 | WARNING | Menu::loadMultiple calls should be avoided in classes, use dependency injection instead
     35 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    -----------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/jetherparadero/q3do/q3issues/web/modules/contrib/menu_admin_per_menu/src/MenuAdminPerMenuPermissions.php
    ----------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------------------------------------------------
     6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\StringTranslation\StringTranslationTrait.
    ----------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/jetherparadero/q3do/q3issues/web/modules/contrib/menu_admin_per_menu/src/MenuAdminPerMenuAccessInterface.php
    ----------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------------------------------
     6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Menu\MenuLinkInterface.
    ----------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------------------
    
    Time: 548ms; Memory: 16MB

    Kindly check and advise, please.
    Thank you.

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

    i will remove the remaining errors.

  • Status changed to Needs review 3 months ago
  • šŸ‡®šŸ‡³India akshaydalvi212

    Hi

    I had fixed the remaining phpcs issues and raised the PR as here

    and all the phpcs errors are removed
    kindly test and review.

    Thanks.

Production build 0.71.5 2024