GitlabCI: Fix PHPCS validation errors

Created on 5 July 2024, 3 months ago
Updated 26 August 2024, about 2 months ago

Problem/Motivation

command -:
phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig web/modules/contrib/colorbox/

FILE: /var/www/html/d10/web/modules/contrib/colorbox/colorbox.post_update.php
-------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------------------------
9 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\Entity\EntityFormDisplay.
-------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/d10/web/modules/contrib/colorbox/colorbox.theme.inc
-----------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------
10 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Component\Utility\Xss.
-----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/d10/web/modules/contrib/colorbox/src/Plugin/Field/FieldFormatter/ColorboxFormatter.php
----------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 3 WARNINGS AFFECTING 4 LINES
----------------------------------------------------------------------------------------------------------------------------------------
9 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Field\FieldDefinitionInterface.
463 | WARNING | [ ] ImageStyle::load calls should be avoided in classes, use dependency injection instead
485 | WARNING | [ ] ImageStyle::load calls should be avoided in classes, use dependency injection instead
492 | WARNING | [ ] ImageStyle::load calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/d10/web/modules/contrib/colorbox/src/ColorboxAttachment.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: /var/www/html/d10/web/modules/contrib/colorbox/src/Form/ColorboxSettingsForm.php
------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------
11 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Extension\ModuleExtensionList.
------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------

Time: 1.05 secs; Memory: 16MB

Steps to reproduce

Run PHPCS on Config Pages module.

Proposed resolution

Fixed the coding standards.

Remaining tasks

Submit the patch either MR.

šŸ“Œ Task
Status

Fixed

Version

2.1

Component

Code

Created by

šŸ‡®šŸ‡³India hetal.solanki

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 @hetal.solanki
  • Merge request !35phpcs issue solve ā†’ (Open) created by hetal.solanki
  • Issue was unassigned.
  • Status changed to Needs work 3 months ago
  • Pipeline finished with Failed
    3 months ago
    Total: 710s
    #216414
  • First commit to issue fork.
  • šŸ‡®šŸ‡³India chandansha

    I have fixed remaining errors.
    Please review again.
    Thanks.!!

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

    I have fixed remaining errors.
    Please review again.
    Thanks.!!

  • Pipeline finished with Failed
    3 months ago
    Total: 139s
    #231046
  • Assigned to bhaveshdas
  • šŸ‡®šŸ‡³India bhaveshdas

    I applied MR!35 and I still encountered some issues after I ran vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,js,info,txt,md,yml,twig modules/custom/colorbox-3459188/

    FILE: /var/www/html/drupal-contri-d10/modules/custom/colorbox-3459188/src/Form/ColorboxSettingsForm.php
    -------------------------------------------------------------------------------------------------------------------------
    FOUND 6 ERRORS AFFECTING 4 LINES
    -------------------------------------------------------------------------------------------------------------------------
     61 | ERROR | [x] The first parameter of a multi-line function declaration must be on the line after the opening bracket
     62 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
     63 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
     64 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
     64 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
     64 | ERROR | [x] The closing parenthesis of a multi-line function declaration must be on a new line
    -------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /var/www/html/drupal-contri-d10/modules/custom/colorbox-3459188/src/Plugin/Field/FieldFormatter/ColorboxResponsiveFormatter.php
    -------------------------------------------------------------------------------------------------------------------------------------
    FOUND 15 ERRORS AFFECTING 13 LINES
    -------------------------------------------------------------------------------------------------------------------------------------
     106 | ERROR | [x] The first parameter of a multi-line function declaration must be on the line after the opening bracket
     107 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 2
     108 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 6
     109 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 2
     110 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 2
     111 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 6
     112 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 2
     113 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 2
     114 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 6
     115 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 6
     116 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 6
     117 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 6
     118 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 6
     118 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
     118 | ERROR | [x] The closing parenthesis of a multi-line function declaration must be on a new line
    -------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 15 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /var/www/html/drupal-contri-d10/modules/custom/colorbox-3459188/src/Plugin/Field/FieldFormatter/ColorboxFormatter.php
    ---------------------------------------------------------------------------------------------------------------------------
    FOUND 15 ERRORS AFFECTING 13 LINES
    ---------------------------------------------------------------------------------------------------------------------------
     106 | ERROR | [x] The first parameter of a multi-line function declaration must be on the line after the opening bracket
     107 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
     108 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
     109 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
     110 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
     111 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
     112 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
     113 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
     114 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
     115 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
     116 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
     117 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 30
     118 | ERROR | [x] Multi-line function declaration not indented correctly; expected 4 spaces but found 2
     118 | ERROR | [x] Multi-line function declarations must have a trailing comma after the last parameter
     118 | ERROR | [x] The closing parenthesis of a multi-line function declaration must be on a new line
    ---------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 15 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /var/www/html/drupal-contri-d10/modules/custom/colorbox-3459188/styles/stockholmsyndrome/colorbox_style.js
    ----------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------------------
     20 | ERROR | [x] Opening brace must be the last content on the line
    ----------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------
    
    Time: 578ms; Memory: 14MB
    
  • Issue was unassigned.
  • šŸ‡®šŸ‡³India bhaveshdas

    Hi, I have Fixed Remaining PHPCS Issues.
    Could you please review it.

    Thankyou !!

  • Pipeline finished with Failed
    3 months ago
    Total: 186s
    #231081
  • Status changed to Needs work 3 months ago
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi @bhaveshdas,

    I tried to apply MR35 but encountered an error.

    āžœ  colorbox git:(2.0.2) āœ— curl https://git.drupalcode.org/project/colorbox/-/merge_requests/35.diff | git apply -v
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 25376    0 25376    0     0  33424      0 --:--:-- --:--:-- --:--:-- 33389
    Checking patch colorbox.post_update.php...
    error: while searching for:
     * Post-update functions for Colorbox.
     */
    
    use Drupal\Core\Entity\Entity\EntityViewDisplay;
    use Drupal\Core\Entity\Entity\EntityFormDisplay;
    
    /**
     * Saves the image style dependencies into form and view display entities.
    
    error: patch failed: colorbox.post_update.php:5
    error: colorbox.post_update.php: patch does not apply
    Checking patch colorbox.theme.inc...
    error: while searching for:
     * Colorbox theme functions.
     */
    
    use Drupal\Component\Utility\Crypt;
    use Drupal\file\Entity\File;
    use Drupal\image\Entity\ImageStyle;
    use Drupal\Component\Utility\Xss;
    use Drupal\responsive_image\Entity\ResponsiveImageStyle;
    
    /**
     * Prepares variables for colorbox formatter templates.
    
    error: patch failed: colorbox.theme.inc:5
    error: colorbox.theme.inc: patch does not apply
    Checking patch js/colorbox.js...
    error: while searching for:
          };
    
          $(once('init-colorbox', '.colorbox', context))
            .each(function() {
            // Only images are supported for the "colorbox" class.
            // The "photo" setting forces the href attribute to be treated as an image.
            var extendParams = {
              photo: true
            };
            // If a title attribute is supplied, sanitize it.
            var title = $(this).attr('title');
    
    error: patch failed: js/colorbox.js:27
    error: js/colorbox.js: patch does not apply
    Checking patch src/ColorboxAttachment.php...
    error: while searching for:
    
    namespace Drupal\colorbox;
    
    use Drupal\Core\Extension\ModuleHandlerInterface;
    use Drupal\Core\Config\ConfigFactoryInterface;
    use Drupal\Core\Installer\InstallerKernel;
    use Drupal\Core\StringTranslation\StringTranslationTrait;
    
    
    error: patch failed: src/ColorboxAttachment.php:2
    error: src/ColorboxAttachment.php: patch does not apply
    Checking patch src/Form/ColorboxSettingsForm.php...
    error: while searching for:
    
    use Drupal\Core\Asset\LibraryDiscoveryInterface;
    use Drupal\Core\Config\ConfigFactoryInterface;
    use Drupal\Core\Extension\ModuleHandlerInterface;
    use Drupal\Core\Form\ConfigFormBase;
    use Drupal\Core\Form\FormStateInterface;
    use Symfony\Component\DependencyInjection\ContainerInterface;
    use Drupal\Core\Extension\ModuleExtensionList;
    
    /**
     * General configuration form for controlling the colorbox behaviour..
    
    error: patch failed: src/Form/ColorboxSettingsForm.php:4
    error: src/Form/ColorboxSettingsForm.php: patch does not apply
    Checking patch src/Plugin/Field/FieldFormatter/ColorboxFormatter.php...
    error: while searching for:
    
    namespace Drupal\colorbox\Plugin\Field\FieldFormatter;
    
    use Drupal\Core\Asset\LibraryDiscoveryInterface;
    use Drupal\Core\Entity\EntityStorageInterface;
    use Drupal\Core\Extension\ModuleHandlerInterface;
    use Drupal\Core\Field\FieldItemListInterface;
    use Drupal\Core\Field\FieldDefinitionInterface;
    use Drupal\Core\Link;
    use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
    use Drupal\Core\Session\AccountInterface;
    use Drupal\Core\Url;
    use Drupal\image\Entity\ImageStyle;
    use Symfony\Component\DependencyInjection\ContainerInterface;
    use Drupal\Core\Form\FormStateInterface;
    use Drupal\Core\Cache\Cache;
    use Drupal\colorbox\ElementAttachmentInterface;
    use Drupal\image\Plugin\Field\FieldFormatter\ImageFormatterBase;
    
    /**
     * Plugin implementation of the 'colorbox' formatter.
    
    error: patch failed: src/Plugin/Field/FieldFormatter/ColorboxFormatter.php:2
    error: src/Plugin/Field/FieldFormatter/ColorboxFormatter.php: patch does not apply
    Checking patch src/Plugin/Field/FieldFormatter/ColorboxResponsiveFormatter.php...
    error: src/Plugin/Field/FieldFormatter/ColorboxResponsiveFormatter.php: No such file or directory
    Checking patch styles/default/colorbox_style.js...
    Checking patch styles/plain/colorbox_style.js...
    Checking patch styles/stockholmsyndrome/colorbox_style.js...
    Checking patch templates/colorbox-responsive-formatter.html.twig...
    error: templates/colorbox-responsive-formatter.html.twig: No such file or directory
    āžœ  colorbox git:(2.0.2) āœ—

    Please check and advise.
    Thank you

  • First commit to issue fork.
  • Pipeline finished with Success
    2 months ago
    #248354
  • Pipeline finished with Success
    2 months ago
    Total: 163s
    #248357
  • Status changed to Needs review 2 months ago
  • šŸ‡«šŸ‡·France dydave

    Quick follow-up on this issue:

    Created new branch based on latest 2.1.x development branch.

    Applied automated fixes with phpcbf web/modules/contrib/colorbox/, then fixed the remaining issues manually.
    Important: Required PHPCS and PHPSTAN validation jobs to pass ==> To be approved or rejected by the maintainer.

    At this point:
    Last build on MR!40: https://git.drupalcode.org/issue/colorbox-3459188/-/pipelines/248357

     

    We would greatly appreciate if a maintainer or someone with write permission could take a look at ticket's merge request 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!40 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

    DYdave ā†’ changed the visibility of the branch 3459188-fix-the-issues to hidden.

  • First commit to issue fork.
    • DYdave ā†’ committed 036e3351 on 2.1.x
      Issue #3459188 by DYdave: PHPCS on GitlabCI: Fixed all validation errors...
  • Status changed to Fixed 2 months ago
  • šŸ‡ŗšŸ‡øUnited States paulmckibben Atlanta, GA

    Thanks all, I have merged MR 40.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024