GitlabCI: Fix PHPCS and PHPSTAN validation errors

Created on 22 February 2024, 10 months ago
Updated 21 June 2024, 6 months ago

Problem/Motivation

There is a files need to fixed with coding standards.
Here is the command : -
phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml,twig modules/contrib/field_group/

Result : -

FILE: /home/prem/Documents/drupal11/modules/custom/field_group/templates/field-group-accordion-item.html.twig
-------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------
 39 | ERROR | [x] Expected 1 newline at end of file; 0 found
-------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------


FILE: /home/prem/Documents/drupal11/modules/custom/field_group/src/FieldGroupFormatterPluginManager.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
  8 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Extension\ModuleHandlerInterface.
 42 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
-----------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------------------


FILE: /home/prem/Documents/drupal11/modules/custom/field_group/src/Plugin/Derivative/FieldGroupLocalAction.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------
 10 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Component\Plugin\Derivative\DeriverBase.
-----------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------------------


FILE: /home/prem/Documents/drupal11/modules/custom/field_group/src/Plugin/field_group/FieldGroupFormatter/HtmlElement.php
-------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------------
 8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Component\Utility\Html.
-------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------


FILE: /home/prem/Documents/drupal11/modules/custom/field_group/src/Plugin/field_group/FieldGroupFormatter/AccordionItem.php
---------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------------
 63 | WARNING | Unused variable $key.
---------------------------------------------------------------------------------------------------------------------------


FILE: /home/prem/Documents/drupal11/modules/custom/field_group/src/Form/FieldGroupAddForm.php
----------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------
 291 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------


FILE: /home/prem/Documents/drupal11/modules/custom/field_group/src/FormatterHelper.php
-------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------
 5 | ERROR | [x] Non-namespaced classes/interfaces/traits should not be referenced with use statements
-------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------


FILE: /home/prem/Documents/drupal11/modules/custom/field_group/src/Element/HorizontalTabs.php
---------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------
 133 | ERROR | [x] Use null coalesce operator instead of ternary operator.
---------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------


FILE: /home/prem/Documents/drupal11/modules/custom/field_group/src/Routing/FieldGroupConverter.php
--------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\ParamConverter\ParamConverterInterface.
--------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------------------


FILE: /home/prem/Documents/drupal11/modules/custom/field_group/src/Routing/RouteSubscriber.php
----------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------
 40 | WARNING | Unused variable $defaults.
----------------------------------------------------------------------------------------------


FILE: /home/prem/Documents/drupal11/modules/custom/field_group/tests/src/Functional/ManageDisplayTest.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 5 LINES
------------------------------------------------------------------------------------------------------------------------------------------
  89 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 103 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 123 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 139 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 170 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
------------------------------------------------------------------------------------------------------------------------------------------


FILE: /home/prem/Documents/drupal11/modules/custom/field_group/tests/src/Functional/EntityDisplayTest.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------------
 135 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
------------------------------------------------------------------------------------------------------------------------------------------


FILE: /home/prem/Documents/drupal11/modules/custom/field_group/tests/src/Functional/FieldGroupTestTrait.php
-----------------------------------------------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 4 LINES
-----------------------------------------------------------------------------------------------------------
 47 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 48 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 49 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 50 | ERROR | [x] Use null coalesce operator instead of ternary operator.
-----------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------


FILE: /home/prem/Documents/drupal11/modules/custom/field_group/field_group.module
---------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
---------------------------------------------------------------------------------
  74 | WARNING | [ ] Unused variable $route_name.
 294 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
---------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------


FILE: /home/prem/Documents/drupal11/modules/custom/field_group/includes/field_ui.inc
------------------------------------------------------------------------------------
FOUND 8 ERRORS AFFECTING 6 LINES
------------------------------------------------------------------------------------
 143 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 149 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 149 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 159 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 159 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 201 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 492 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 607 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------


FILE: /home/prem/Documents/drupal11/modules/custom/field_group/contrib/field_group_migrate/src/Plugin/migrate/source/d7/FieldGroup.php
-------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------------------------------
 92 | ERROR | unserialize() is insecure unless allowed classes are limited. Use a safe format like JSON or use the allowed_classes option.
-------------------------------------------------------------------------------------------------------------------------------------------


FILE: /home/prem/Documents/drupal11/modules/custom/field_group/contrib/field_group_migrate/src/Plugin/migrate/source/d6/FieldGroup.php
-------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------------------------------
 45 | ERROR | unserialize() is insecure unless allowed classes are limited. Use a safe format like JSON or use the allowed_classes option.
-------------------------------------------------------------------------------------------------------------------------------------------

Time: 1.08 secs; Memory: 18MB

Steps to reproduce

Run PHPCS on afield_group module.

Proposed resolution

Fixed the coding standards.

๐Ÿ“Œ Task
Status

Fixed

Version

3.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia prem suthar Ahemdabad- Gujrat , Jodhpur - Rajsthan

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 @prem suthar
  • Pipeline finished with Failed
    10 months ago
    Total: 271s
    #101516
  • Status changed to Needs review 10 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia prem suthar Ahemdabad- Gujrat , Jodhpur - Rajsthan
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Ashutosh Ahirwal India

    Ashutosh Ahirwal โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Ashutosh Ahirwal India

    Hi Provided MR working fine but there are still some error found related to js
    I have updated MR Needs Review.
    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/field_group

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/field_group/js/field_group.field_ui.js
    ---------------------------------------------------------------------------------------------------------------
    FOUND 4 ERRORS AFFECTING 4 LINES
    ---------------------------------------------------------------------------------------------------------------
    49 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
    58 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
    111 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
    120 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
    ---------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/field_group/js/field_group.js
    ------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------
    15 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "NULL" but found "null"
    ------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/field_group/formatters/tabs/horizontal-tabs.js
    -----------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------
    72 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
    -----------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/field_group/formatters/tabs/tabs.js
    ------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    ------------------------------------------------------------------------------------------------------------
    24 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
    40 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
    ------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/field_group/formatters/accordion/accordion.js
    ----------------------------------------------------------------------------------------------------------------------
    FOUND 4 ERRORS AFFECTING 4 LINES
    ----------------------------------------------------------------------------------------------------------------------
    22 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
    32 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
    35 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
    45 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
    ----------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/field_group/formatters/html_element/html-element.js
    ----------------------------------------------------------------------------------------------------------------------------
    FOUND 3 ERRORS AFFECTING 3 LINES
    ----------------------------------------------------------------------------------------------------------------------------
    55 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
    66 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
    69 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
    ----------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------------------

    Time: 1.8 secs; Memory: 18MB

  • Pipeline finished with Failed
    10 months ago
    Total: 236s
    #111838
  • Pipeline finished with Failed
    7 months ago
    Total: 218s
    #175539
  • Pipeline finished with Failed
    7 months ago
    Total: 276s
    #176534
  • First commit to issue fork.
  • Pipeline finished with Success
    7 months ago
    #176707
  • Pipeline finished with Success
    7 months ago
    #176709
  • Pipeline finished with Success
    7 months ago
    Total: 294s
    #176726
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance dydave

    Quick follow-up on this issue:

    A few additional commits were added to the current merge request MR!47 with a few comments, see above at #6.

    But mostly, at this point:
    Last build on MR!47: https://git.drupalcode.org/issue/field_group-3423199/-/pipelines/176726

     

    Changes to file MigrateUiFieldGroupTest.php from merge request MR!49 (see ๐Ÿ“Œ Automated Drupal 11 compatibility fixes for field_group - Fixed PHPUnit on GitlabCI RTBC ) had to be ported to this MR for the phpunit tests to complete, see:
    https://git.drupalcode.org/project/field_group/-/merge_requests/49/diffs...
    So changes to this file could probably be reverted once the phpunit tests are fixed in the main development branch (8.x-3.x).
     

    We would greatly appreciate if a maintainer or someone with write permission could take a look at ticket's merge request MR!47 and let us know if there would be any more work needed.

    Feel free to let us know if you have any questions or concerns on merge request MR!47 or any aspect of this ticket in general, we would surely be glad to help.
    Thanks in advance for your feedback and reviews.

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance dydave
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance dydave
  • Pipeline finished with Failed
    7 months ago
    Total: 372s
    #179188
  • Pipeline finished with Success
    7 months ago
    Total: 317s
    #179205
  • Pipeline finished with Success
    7 months ago
    Total: 345s
    #179212
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance dydave

    Quick follow-up on this issue:

    Since there were not too many issues and some of them were already fixed by the PHPCS changes, I went ahead and got all PHPSTAN errors fixed in the same MR.

    At this point PHPCS, PHPSTAN and PHPUNIT jobs all seem to be passing ๐ŸŸข
    See last build: https://git.drupalcode.org/issue/field_group-3423199/-/pipelines/179212

    Feel free to let us know if you have any questions or concerns on merge request MR!47 or any aspect of this ticket in general, we would surely be glad to help.
    Thanks in advance for your feedback and reviews.

    • DYdave โ†’ committed eb2167b7 on 8.x-3.x
      Issue #3423199: Temporary port of patch from DO-3430494 to pass phpunit...
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium nils.destoop

    nils.destoop โ†’ made their first commit to this issueโ€™s fork.

  • Pipeline finished with Failed
    7 months ago
    #188006
  • Status changed to Fixed 7 months ago
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium nils.destoop

    Thx for the merge request. This has been merged

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia prem suthar Ahemdabad- Gujrat , Jodhpur - Rajsthan
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024