Fix the issues reported by phpcs

Created on 5 July 2023, over 1 year ago
Updated 31 July 2024, 4 months ago

Problem/Motivation

FILE: /var/www/html/vb/d_cont/view_mode_by_owner_role/view_mode_by_owner_role.info.yml
----------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
----------------------------------------------------------------------------------------------
7 | WARNING | All dependencies must be prefixed with the project name, for example "drupal:"
8 | WARNING | All dependencies must be prefixed with the project name, for example "drupal:"
9 | WARNING | All dependencies must be prefixed with the project name, for example "drupal:"
----------------------------------------------------------------------------------------------

FILE: /var/www/html/vb/d_cont/view_mode_by_owner_role/src/Form/SettingsMapRoleViewModeForm.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------
74 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/vb/d_cont/view_mode_by_owner_role/src/Form/BasicSettingsForm.php
------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
------------------------------------------------------------------------------------
79 | WARNING | Possible useless method overriding detected
86 | WARNING | Possible useless method overriding detected
------------------------------------------------------------------------------------

FILE: /var/www/html/vb/d_cont/view_mode_by_owner_role/src/Form/SettingsViewModeMapForm.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------
35 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/vb/d_cont/view_mode_by_owner_role/src/Form/SettingsChooseRoleForm.php
-----------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------
52 | WARNING | Unused variable $config.
-----------------------------------------------------------------------------------------

FILE: /var/www/html/vb/d_cont/view_mode_by_owner_role/src/Hooks/EntityUser.php
---------------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AFFECTING 6 LINES
---------------------------------------------------------------------------------------------------------
39 | ERROR | [ ] Inline doc block comments are not allowed; use "/* Comment */" or "// Comment" instead
43 | ERROR | [x] Missing function doc comment
47 | ERROR | [ ] Inline doc block comments are not allowed; use "/* Comment */" or "// Comment" instead
51 | ERROR | [x] Missing function doc comment
55 | ERROR | [ ] Inline doc block comments are not allowed; use "/* Comment */" or "// Comment" instead
59 | ERROR | [x] Missing function doc comment
---------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------

FILE: /var/www/html/vb/d_cont/view_mode_by_owner_role/src/Hooks/ChangeNodeViewMode.php
---------------------------------------------------------------------------------------------------------
FOUND 7 ERRORS AFFECTING 6 LINES
---------------------------------------------------------------------------------------------------------
14 | ERROR | [ ] Doc comment is empty
28 | ERROR | [ ] Doc comment is empty
36 | ERROR | [ ] Doc comment is empty
46 | ERROR | [ ] Doc comment is empty
46 | ERROR | [ ] Inline doc block comments are not allowed; use "/* Comment */" or "// Comment" instead
50 | ERROR | [x] Missing function doc comment
78 | ERROR | [ ] Doc comment is empty
---------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------

Time: 130ms; Memory: 10MB

Steps to reproduce

Execute the command: phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig view_mode_by_owner_role/

Remaining tasks

Patch review

๐Ÿ“Œ Task
Status

Needs work

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia urvashi_vora Madhya Pradesh, India

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

Comments & Activities

  • Issue created by @urvashi_vora
  • Status changed to Needs work 12 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Ashutosh Ahirwal India

    Provided patch get applied cleanly but still throwing some error.

    Used command:-
    ./vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,css,js,yml web/modules/custom/view_mode_by_owner_role

    Remaining issues:-
    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/view_mode_by_owner_role/src/Form/SettingsMapRoleViewModeForm.php
    -----------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------------
    6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Form\FormStateInterface.
    -----------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/view_mode_by_owner_role/src/Form/BasicSettingsForm.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: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/view_mode_by_owner_role/src/Plugin/Validation/Constraint/UserRoleNumberConstraintValidator.php
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\DependencyInjection\ContainerInjectionInterface.
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/view_mode_by_owner_role/src/Hooks/ChangeNodeViewMode.php
    -----------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------
    8 | 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: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/view_mode_by_owner_role/src/Hooks/EntityUser.php
    -----------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------------------------
    8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\DependencyInjection\ContainerInjectionInterface.
    -----------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------------------------

    Time: 181ms; Memory: 10MB

  • Assigned to nitin_lama
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India

    Addressed #2. Providing updated patch.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India

    Please review. Thanks.

  • Issue was unassigned.
  • Status changed to Needs review 12 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India
  • Hi, reviewed the patch #4, applied cleanly and fixes all phpcs erros/warnings. Thank you!

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia dev16.addweb

    silvi.addweb โ†’ made their first commit to this issueโ€™s fork.

  • Status changed to Needs work 4 months ago
  • Hi @nint_lama,

    I applied the patch that you provided and it was applied smoothly, however, the result was opposite to what comment #7 have said. Please see below:

    view_mode_by_owner_role git:(1.0.x) curl https://www.drupal.org/files/issues/2023-12-07/coding-standard-fixes_4.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 11283  100 11283    0     0  36209      0 --:--:-- --:--:-- --:--:-- 37735
    patching file src/Form/BasicSettingsForm.php
    patching file src/Form/SettingsChooseRoleForm.php
    patching file src/Form/SettingsMapRoleViewModeForm.php
    patching file src/Form/SettingsViewModeMapForm.php
    patching file src/Hooks/ChangeNodeViewMode.php
    patching file src/Hooks/EntityUser.php
    patching file src/Plugin/Validation/Constraint/UserRoleNumberConstraintValidator.php
    patching file view_mode_by_owner_role.info.yml
    โžœ  view_mode_by_owner_role git:(1.0.x) โœ— cd ..
    โžœ  contrib git:(master) โœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig view_mode_by_owner_role
    
    FILE: ...web/modules/contrib/view_mode_by_owner_role/src/Form/BasicSettingsForm.php
    --------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     43 | ERROR | [x] Multi-line function declarations must have a trailing comma
        |       |     after the last parameter
     43 | ERROR | [x] The closing parenthesis of a multi-line function declaration
        |       |     must be on a new line
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    Time: 254ms; Memory: 10MB

    Kindly check

    Thanks,
    Jake

Production build 0.71.5 2024