Fix the issues reported by phpcs

Created on 21 November 2022, about 2 years ago
Updated 8 May 2024, 7 months ago

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

FILE: ./CHANGELOG.md
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
 33 | WARNING | Line exceeds 80 characters; contains 93 characters
 58 | WARNING | Line exceeds 80 characters; contains 140 characters
----------------------------------------------------------------------


FILE: ./field_permissions.info.yml
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 9 | ERROR | [x] Expected 1 newline at end of file; 0 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./field_permissions.module
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
   9 | ERROR | [x] Use statements should be sorted alphabetically.
     |       |     The first wrong one is
     |       |     Drupal\Core\Access\AccessResult.
 153 | ERROR | [ ] All functions defined in a module file must be
     |       |     prefixed with the module's name, found
     |       |     "field_permission_field_config_edit_form_submit"
     |       |     but expected
     |       |     "field_permissions_field_permission_field_config_edit_form_submit"
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Controller/FieldPermissionsController.php
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
  12 | ERROR | [x] Use statements should be sorted alphabetically.
     |       |     The first wrong one is
     |       |     Drupal\field_permissions\Plugin\CustomPermissionsInterface.
 172 | ERROR | [ ] The array declaration extends to column 138 (the
     |       |     limit is 120). The array content should be split
     |       |     up over multiple lines
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/FieldPermissionsService.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 14 | ERROR | [x] Use statements should be sorted alphabetically. The
    |       |     first wrong one is
    |       |     Drupal\field_permissions\Plugin\CustomPermissionsInterface.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Plugin/migrate/process/FieldPermissionSettings.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 8 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\field_permissions\Plugin\FieldPermissionTypeInterface.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./tests/modules/field_permissions_test/src/Plugin/FieldPermissionType/TestAccess.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 9 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\field_permissions\Plugin\CustomPermissionsInterface.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./tests/src/Unit/FieldPermissionsServiceTest.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\comment\CommentManagerInterface.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./tests/src/Unit/Plugin/FieldPermissionType/CustomAccessTest.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\Core\Entity\EntityInterface.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./tests/src/Unit/Plugin/FieldPermissionType/PrivateAccessTest.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\Core\Entity\EntityInterface.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 248ms; Memory: 6MB
šŸ“Œ Task
Status

Needs review

Version

1.0

Component

Code

Created by

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

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • šŸ‡®šŸ‡³India Akram Khan Cuttack, Odisha

    Fixed all Coding standard PHPCS issue

  • šŸ‡®šŸ‡³India Akram Khan Cuttack, Odisha
  • First commit to issue fork.
  • Assigned to vishaljd
  • Status changed to Needs work almost 2 years ago
  • @vishaljd opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review almost 2 years ago
  • Status changed to Needs work almost 2 years ago
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹

    The tests failed, so the correct status is Needs work.

  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹

    The issue summary should always describe what the issue is trying to fix and, in the case, of coding standards issues, report which command has been used, which arguments have been used, and which report that command shown.

  • Status changed to Needs review over 1 year ago
  • šŸ‡®šŸ‡³India nikhilmahala11

    Fixed all Coding standard PHPCS issues

  • Status changed to Needs work over 1 year ago
  • šŸ‡®šŸ‡³India sagarTiwari

    Hello @nikhilmahala11 tested the patch you provided, it still have few errors.

    ../vendor/bin/phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml modules/contrib/field_permissions

    FILE: ...tions/MAMP/htdocs/drupal_contrib/drupal-9.5-dev/web/modules/contrib/field_permissions/CHANGELOG.md
    --------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    --------------------------------------------------------------------------------------------------------
    33 | WARNING | Line exceeds 80 characters; contains 93 characters
    58 | WARNING | Line exceeds 80 characters; contains 140 characters
    --------------------------------------------------------------------------------------------------------

    FILE: ...tdocs/drupal_contrib/drupal-9.5-dev/web/modules/contrib/field_permissions/field_permissions.module
    --------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------
    145 | ERROR | All functions defined in a module file must be prefixed with the module's name, found
    | | "field_permission_field_config_edit_form_submit" but expected
    | | "field_permissions_field_permission_field_config_edit_form_submit"
    --------------------------------------------------------------------------------------------------------

    Time: 305ms; Memory: 12MB

  • Assigned to hardikpandya
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • šŸ‡®šŸ‡³India nayana_mvr

    Verified the patch #17 on Drupal version 10.1.x and Field Permission version 8.x-1.x. The patch applied cleanly and except the following errors, all other coding standard issues are fixed.

    FILE: .../contrib/field_permissions/field_permissions.module
    --------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------------------------------------------------------------
     151 | ERROR | All functions defined in a module file must be prefixed with the module's name, found "field_permission_field_config_edit_form_submit" but
         |       | expected "field_permissions_field_permission_field_config_edit_form_submit"
    --------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: .../contrib/field_permissions/src/Plugin/FieldPermissionType/Manager.php
    --------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------------------------------
     56 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    --------------------------------------------------------------------------------------------------------------------------------
    
    Time: 796ms; Memory: 12MB
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • šŸ‡®šŸ‡³India pray_12

    Hi,
    Addressed the error and warning mentioned in #18.
    Please Review.
    Thankyou!!

  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • Pipeline finished with Success
    10 months ago
    Total: 169s
    #98435
  • First commit to issue fork.
  • Pipeline finished with Success
    9 months ago
    Total: 170s
    #123337
  • Status changed to RTBC 9 months ago
  • šŸ‡«šŸ‡®Finland sokru

    Fixed few remaining CS issues, since the phpcs job succeeds on CI, I set the status to RTBC.

  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹

    apaderno ā†’ changed the visibility of the branch coding_standard to hidden.

  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹

    apaderno ā†’ changed the visibility of the branch 3322809-coding-standard-phpcs to hidden.

  • Status changed to Needs review 8 months ago
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹

    The MR still needs to be reviewed, even if GitLab CI says there are no PHP_CodeSniffer warnings/errors.

  • Pipeline finished with Success
    8 months ago
    Total: 233s
    #161364
  • Pipeline finished with Success
    8 months ago
    Total: 195s
    #161369
  • šŸ‡µšŸ‡­Philippines clarkssquared

    Hi

    I applied the updated MR !24 and I can still see PHPCS issues

    āžœ  field_permissions git:(a5aee30) curl https://git.drupalcode.org/project/field_permissions/-/merge_requests/24.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 19437    0 19437    0     0  33991      0 --:--:-- --:--:-- --:--:-- 34462
    patching file CHANGELOG.md
    patching file field_permissions.info.yml
    patching file field_permissions.module
    patching file 'src/Controller/FieldPermissionsController.php'
    patching file 'src/FieldPermissionsService.php'
    patching file 'src/Plugin/migrate/process/FieldPermissionSettings.php'
    patching file 'tests/modules/field_permissions_test/src/Plugin/FieldPermissionType/TestAccess.php'
    patching file 'tests/src/Unit/FieldPermissionsServiceTest.php'
    patching file 'tests/src/Unit/Plugin/FieldPermissionType/CustomAccessTest.php'
    patching file 'tests/src/Unit/Plugin/FieldPermissionType/PrivateAccessTest.php'
    āžœ  field_permissions git:(a5aee30) āœ— ..
    āžœ  contrib git:(master) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml field_permissions 
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/field_permissions/CHANGELOG.md
    -------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    -------------------------------------------------------------------------------------------------------
     15 | WARNING | Line exceeds 80 characters; contains 84 characters
     50 | WARNING | Line exceeds 80 characters; contains 88 characters
    -------------------------------------------------------------------------------------------------------
    
    
    FILE: ...-subing/Projects/d9/d9-local/web/modules/contrib/field_permissions/tests/src/Unit/FieldPermissionsServiceTest.php
    -----------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------
     144 | ERROR | The array declaration extends to column 95 (the limit is 80). The array content should be split up over
         |       | multiple lines
    -----------------------------------------------------------------------------------------------------------------------
    
    
    FILE: ...g/Projects/d9/d9-local/web/modules/contrib/field_permissions/tests/src/Functional/FieldPermissionsCommentTest.php
    -----------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------
     194 | ERROR | The array declaration extends to column 98 (the limit is 80). The array content should be split up over
         |       | multiple lines
    -----------------------------------------------------------------------------------------------------------------------
    
    
    FILE: ...bing/Projects/d9/d9-local/web/modules/contrib/field_permissions/tests/src/Functional/FieldPermissionsNodeTest.php
    -----------------------------------------------------------------------------------------------------------------------
    FOUND 3 ERRORS AND 1 WARNING AFFECTING 4 LINES
    -----------------------------------------------------------------------------------------------------------------------
      74 | ERROR   | The array declaration extends to column 98 (the limit is 80). The array content should be split up
         |         | over multiple lines
      91 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and
         |         | $this->t() instead
     212 | ERROR   | The array declaration extends to column 104 (the limit is 80). The array content should be split up
         |         | over multiple lines
     238 | ERROR   | The array declaration extends to column 94 (the limit is 80). The array content should be split up
         |         | over multiple lines
    -----------------------------------------------------------------------------------------------------------------------
    
    
    FILE: ...bing-subing/Projects/d9/d9-local/web/modules/contrib/field_permissions/src/Plugin/FieldPermissionType/Manager.php
    -----------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------
     56 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    -----------------------------------------------------------------------------------------------------------------------
    
    
    FILE: ...g-subing/Projects/d9/d9-local/web/modules/contrib/field_permissions/src/Controller/FieldPermissionsController.php
    -----------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------
     100 | ERROR | The array declaration extends to column 95 (the limit is 80). The array content should be split up over
         |       | multiple lines
    -----------------------------------------------------------------------------------------------------------------------
    
    Time: 877ms; Memory: 12MB
    

    retaining the status to needs review so that others can give their feedback

Production build 0.71.5 2024