Fix the issues reported by phpcs

Created on 27 September 2023, 9 months ago
Updated 4 March 2024, 4 months ago

Problem/Motivation

phpcs \
--standard=Drupal,DrupalPractice -n \
--extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig \
--ignore="*.features.*,*.pages*.inc,*/node_modules/*" \
web/modules/contrib/group

FILE: /var/www/web/modules/contrib/group/group.api.php
------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------
21 | ERROR | [x] Data types in @param tags need to be fully namespaced
------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------

FILE: /var/www/web/modules/contrib/group/css/permissions.css
------------------------------------------------------------------------
FOUND 8 ERRORS AFFECTING 8 LINES
------------------------------------------------------------------------
7 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
10 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
11 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
14 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
15 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
18 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
21 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
22 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
------------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------

FILE: /var/www/web/modules/contrib/group/css/toolbar.icons.theme.css
-----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-----------------------------------------------------------------------
5 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
9 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
-----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------

FILE: /var/www/web/modules/contrib/group/tests/modules/group_test_plugin/src/Entity/EntityTestWithOwner.php
-----------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------
90 | ERROR | Description for the @return value is missing
-----------------------------------------------------------------------------------------------------------

FILE: /var/www/web/modules/contrib/group/tests/modules/group_test_plugin/src/Plugin/Group/Relation/NodeRelationDeriver.php
--------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------------------------------------------------
8 | ERROR | [x] Missing class doc comment
11 | ERROR | [ ] Doc comment short description must start with a capital letter
--------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/web/modules/contrib/group/tests/src/Unit/GroupPermissionCheckerTest.php
--------------------------------------------------------------------------------------
FOUND 15 ERRORS AFFECTING 13 LINES
--------------------------------------------------------------------------------------
81 | ERROR | Type hint "array" missing for $outsider_permissions
81 | ERROR | Type hint "array" missing for $insider_permissions
81 | ERROR | Type hint "array" missing for $individual_permissions
127 | ERROR | No key specified for array entry; first entry specifies key
140 | ERROR | No key specified for array entry; first entry specifies key
153 | ERROR | No key specified for array entry; first entry specifies key
166 | ERROR | No key specified for array entry; first entry specifies key
179 | ERROR | No key specified for array entry; first entry specifies key
192 | ERROR | No key specified for array entry; first entry specifies key
205 | ERROR | No key specified for array entry; first entry specifies key
218 | ERROR | No key specified for array entry; first entry specifies key
231 | ERROR | No key specified for array entry; first entry specifies key
244 | ERROR | No key specified for array entry; first entry specifies key
257 | ERROR | No key specified for array entry; first entry specifies key
270 | ERROR | No key specified for array entry; first entry specifies key
--------------------------------------------------------------------------------------

More can be found on the attached file.

Steps to reproduce

Install the group module and perform PHPCS for Drupal Standards

Proposed resolution

Fix the errors found from PHPCS

๐Ÿ“Œ Task
Status

Needs work

Version

3.3

Component

Code

Created by

๐Ÿ‡ต๐Ÿ‡ญPhilippines Zed9

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.

  • Assigned to Akshat26
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Akshat26 Bhopal
  • Issue was unassigned.
  • Status changed to Needs review 9 months ago
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 5.7
    last update 9 months ago
    9,628 pass
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Akshat26 Bhopal

    All the mentioned phpcs issues have been fixed. Please review the patch #3390016-5

  • Status changed to Needs work 9 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia aayushDrupal

    Hi Akshat26,
    Patch #5 has been successfully applied, but there are still remaining errors. Please check the attached screenshot.

    Thanks.

  • Status changed to Needs review 9 months ago
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 5.7
    last update 9 months ago
    PHPLint Failed
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Akshat26 Bhopal

    All the mentioned phpcs issues and some extra issue (which are not mentioned) have been fixed. Please review the patch #3390016-7

  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 5.7
    last update 9 months ago
    29 pass, 108 fail
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Akshat26 Bhopal
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Akshat26 Bhopal
  • Assigned to Mohd Sahzad
  • Status changed to Needs work 9 months ago
  • Issue was unassigned.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Mohd Sahzad

    I have updated this issue: Fix the issues reported by phpcs

  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 5.7
    last update 9 months ago
    PHPLint Failed
  • Status changed to Needs review 9 months ago
  • Status changed to Needs work 5 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Preethy_ray

    Hi,
    Applied the patch #12. This patch is throwing the error.

    Checking patch src/Plugin/Group/Relation/GroupRelationType.php...
    error: while searching for:
      protected $description;
    
      /**
       * (optional) The label for the entity reference field.
       *
       * @var \Drupal\Core\Annotation\Translation
       */
      protected $reference_label;
    
      /**
       * (optional) The description for the entity reference field.
       *
       * @var \Drupal\Core\Annotation\Translation
       */
      protected $reference_description;
    
      /**
       * The entity type ID the plugin supports.
       *
       * @var string
       */
      protected $entity_type_id;
    
      /**
       * (optional) The bundle of the entity type the plugin supports.
       *
       * Do not specify if your plugin manages all bundles.
       *
       * @var string|false
       */
      protected $entity_bundle = FALSE;
    
      /**
       * (optional) The bundle class for all relationships using this plugin.
       *
       * If you make sure that your shared class puts all of its functionality in a
       * trait and has its own interface, then it should be easy for others to still
    
    error: patch failed: src/Plugin/Group/Relation/GroupRelationType.php:38
    error: src/Plugin/Group/Relation/GroupRelationType.php: patch does not apply
    
    Checking patch tests/src/Kernel/QueryAlter/QueryAlterTestBase.php...
    error: while searching for:
    
                if ($pub_permission && $unpub_permission) {
                  $cases["single-$copy_key-own-mixpub-$operation"] = $status_base;
                  $cases["single-$copy_key-own-mixpub-$operation"]["{$copy_key}_permissions"] = [$pub_permission, $unpub_permission];
                  $cases["single-$copy_key-own-mixpub-$operation"]["{$copy_key}_pub_owner_check"] = TRUE;
                  $cases["single-$copy_key-own-mixpub-$operation"]["{$copy_key}_unpub_owner_check"] = TRUE;
                }
    
    error: patch failed: tests/src/Kernel/QueryAlter/QueryAlterTestBase.php:538
    error: tests/src/Kernel/QueryAlter/QueryAlterTestBase.php: patch does not apply
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia zkhan.aamir

    Hi,

    Patch #13 applied successfully.

    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules/group (3.2.x)
    $ curl https://www.drupal.org/files/issues/2023-10-06/fix-issues-reported-byphpcs-3390016.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  142k  100  142k    0     0   274k      0 --:--:-- --:--:-- --:--:--  275k
    patching file css/permissions.css
    patching file css/toolbar.icons.theme.css
    patching file group.api.php
    patching file group.module
    patching file modules/gnode/src/Plugin/Group/Relation/GroupNode.php
    patching file modules/gnode/src/Plugin/Group/Relation/GroupNodeDeriver.php
    patching file modules/gnode/src/Plugin/Group/RelationHandler/GroupNodePermissionProvider.php
    patching file modules/gnode/tests/src/Functional/EntityOperationsTest.php
    patching file modules/group_support_revisions/tests/src/Functional/GroupSupportRevisionsTest.php
    patching file src/Access/GroupAccessResult.php
    patching file src/Access/GroupInstalledContentAccessCheck.php
    patching file src/Access/GroupMemberAccessCheck.php
    patching file src/Access/GroupOwnsContentAccessCheck.php
    patching file src/Access/GroupPermissionAccessCheck.php
    patching file src/Access/GroupPermissionHandler.php
    patching file src/Access/GroupPermissionHandlerInterface.php
    patching file src/Access/GroupPermissions.php
    patching file src/Access/GroupRelationshipCreateAccessCheck.php
    patching file src/Access/GroupRelationshipCreateAnyAccessCheck.php
    patching file src/Access/GroupRelationshipCreateAnyEntityAccessCheck.php
    patching file src/Access/GroupRelationshipCreateEntityAccessCheck.php
    patching file src/Annotation/GroupRelationType.php
    patching file src/Breadcrumb/GroupRelationshipTypeBreadcrumbBuilder.php
    patching file src/ConfigTranslation/GroupRoleMapper.php
    patching file src/Controller/GroupMembershipController.php
    patching file src/Entity/Access/GroupRelationshipAccessControlHandler.php
    patching file src/Entity/Controller/GroupController.php
    patching file src/Entity/Controller/GroupListBuilder.php
    patching file src/Entity/Controller/GroupRelationshipController.php
    patching file src/Entity/Controller/GroupRoleController.php
    patching file src/Entity/Controller/GroupRoleListBuilder.php
    patching file src/Entity/Controller/GroupTypeController.php
    patching file src/Entity/Controller/GroupTypeListBuilder.php
    patching file src/Entity/Form/GroupForm.php
    patching file src/Entity/Form/GroupRelationshipDeleteForm.php
    patching file src/Entity/Form/GroupRelationshipTypeDeleteForm.php
    patching file src/Entity/Form/GroupRelationshipTypeForm.php
    patching file src/Entity/Form/GroupRevisionDeleteForm.php
    patching file src/Entity/Form/GroupRoleForm.php
    patching file src/Entity/Form/GroupTypeDeleteForm.php
    patching file src/Entity/GroupInterface.php
    patching file src/Entity/GroupRelationshipInterface.php
    patching file src/Entity/GroupRelationshipType.php
    patching file src/Entity/GroupRole.php
    patching file src/Entity/GroupRoleInterface.php
    patching file src/Entity/Storage/ConfigWrapperStorageSchema.php
    patching file src/Entity/Storage/GroupRelationshipStorage.php
    patching file src/Entity/Storage/GroupRelationshipStorageSchema.php
    patching file src/Entity/Storage/GroupRoleStorageInterface.php
    patching file src/EventSubscriber/AnonymousUserResponseSubscriber.php
    patching file src/EventSubscriber/ConfigSubscriber.php
    patching file src/Form/GroupJoinForm.php
    patching file src/Form/GroupLeaveForm.php
    patching file src/Form/GroupPermissionsForm.php
    patching file src/Form/GroupSettingsForm.php
    patching file src/Plugin/Condition/GroupType.php
    patching file src/Plugin/EntityReferenceSelection/RelationshipSubjectSelection.php
    patching file src/Plugin/Group/Relation/GroupRelationBase.php
    patching file src/Plugin/Group/Relation/GroupRelationCollection.php
    patching file src/Plugin/Group/Relation/GroupRelationInterface.php
    patching file src/Plugin/Group/Relation/GroupRelationType.php
    patching file src/Plugin/Group/Relation/GroupRelationTypeManager.php
    patching file src/Plugin/Group/RelationHandler/AccessControlInterface.php
    patching file src/Plugin/Group/RelationHandler/AccessControlTrait.php
    patching file src/Plugin/Group/RelationHandler/GroupMembershipPostInstall.php
    patching file src/Plugin/Group/RelationHandler/OperationProviderInterface.php
    patching file src/Plugin/Group/RelationHandlerDefault/AccessControl.php
    patching file src/Plugin/Group/RelationHandlerDefault/PermissionProvider.php
    patching file src/Plugin/Menu/LocalAction/WithDestination.php
    patching file src/Plugin/views/access/GroupPermission.php
    patching file src/Plugin/views/argument/GroupId.php
    patching file src/Plugin/views/relationship/GroupRelationshipToEntityBase.php
    patching file src/Plugin/views/relationship/GroupToGroupRelationship.php
    patching file src/ProxyClass/UninstallValidator/GroupRelationshipUninstallValidator.php
    patching file src/QueryAccess/EntityQueryAlter.php
    patching file src/QueryAccess/GroupQueryAlter.php
    patching file src/QueryAccess/QueryAlterBase.php
    patching file src/UninstallValidator/GroupRelationshipUninstallValidator.php
    patching file tests/modules/group_test_plugin/src/Entity/EntityTestWithOwner.php
    patching file tests/modules/group_test_plugin/src/Plugin/Group/Relation/NodeRelationDeriver.php
    patching file tests/src/Functional/EntityOperationsTest.php
    patching file tests/src/Functional/PageCacheTest.php
    patching file tests/src/Kernel/ConfigEntityAccessTest.php
    patching file tests/src/Kernel/ConfigWrapperAccessControlHandlerTest.php
    patching file tests/src/Kernel/ContentEntityAccessComplexTest.php
    patching file tests/src/Kernel/ContentEntityAccessTest.php
    patching file tests/src/Kernel/GroupAccessControlHandlerTest.php
    patching file tests/src/Kernel/GroupKernelTestBase.php
    patching file tests/src/Kernel/GroupRelationshipCreateAccessTest.php
    patching file tests/src/Kernel/GroupRelationshipCrudHookTest.php
    patching file tests/src/Kernel/GroupRelationshipStorageTest.php
    patching file tests/src/Kernel/GroupRelationshipTokenReplaceTest.php
    patching file tests/src/Kernel/GroupTest.php
    patching file tests/src/Kernel/GroupTokenReplaceKernelTestBase.php
    patching file tests/src/Kernel/GroupTokenReplaceTest.php
    patching file tests/src/Kernel/QueryAlter/EntityQueryAlterCacheabilityTest.php
    patching file tests/src/Kernel/QueryAlter/GroupQueryAlterTest.php
    patching file tests/src/Kernel/QueryAlter/QueryAlterTangibleTest.php
    patching file tests/src/Kernel/QueryAlter/QueryAlterTestBase.php
    patching file tests/src/Kernel/RelationHandlerTest.php
    patching file tests/src/Kernel/RevisionUiAccessTest.php
    patching file tests/src/Unit/AccessControlTest.php
    patching file tests/src/Unit/GroupPermissionCheckerTest.php
    patching file tests/src/Unit/GroupRelationTypeManagerTest.php
    patching file tests/src/Unit/GroupRelationshipAccessControlHandlerTest.php
    patching file tests/src/Unit/OperationProviderTest.php
    patching file tests/src/Unit/UiTextProviderTest.php
    

    Still there are issues remaining.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Prem Suthar gujrat

    Prem Suthar โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Preethy_ray

    Hi,
    Solved the phpcs issues.
    Remaining errors need to be adressed are

    FILE: /group/tests/src/Kernel/ContentEntityAccessComplexTest.php
    ---------------------------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    ---------------------------------------------------------------------------------------------------------------------------------------
     1004 | ERROR | The array declaration extends to column 90 (the limit is 80). The array content should be split up over multiple lines
     1056 | ERROR | The array declaration extends to column 90 (the limit is 80). The array content should be split up over multiple lines
    ---------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /group/tests/src/Kernel/QueryAlter/QueryAlterTestBase.php
    ---------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------------------------
     541 | ERROR | The array declaration extends to column 128 (the limit is 80). The array content should be split up over multiple lines
    ---------------------------------------------------------------------------------------------------------------------------------------
    
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium kristiaanvandeneynde Antwerp, Belgium

    Please use a merge request, then GitLab CI runs and we can see if the changes actually make a difference. Currently, GitLab CI complains a bit about phpstan, but not phpcs so I'm not sure if anything needs to be done here.

  • First commit to issue fork.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sakthi_dev

    As MR is there, hiding the patches.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium kristiaanvandeneynde Antwerp, Belgium

    Moved MR to 3.3.x, please make sure origin/3.3.x is merged in

Production build 0.69.0 2024