Fix the errors/warnings reported by PHP_CodeSniffer

Created on 5 December 2023, 7 months ago
Updated 28 May 2024, 29 days ago

GitLab CI shows the following PHP_CodeSniffer errors/warnings which need to be fixed.

ILE: ...3406124/web/modules/custom/md_slider-3406124/src/Slider/MDSliderImport.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 9 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is Drupal\Core\Messenger\MessengerInterface.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...om/md_slider-3406124/src/Plugin/Field/FieldFormatter/MDSliderFormatter.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is Drupal\Core\Field\FieldItemListInterface.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...06124/web/modules/custom/md_slider-3406124/src/Form/MDSliderImportForm.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is Drupal\Core\Entity\EntityStorageInterface.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...406124/web/modules/custom/md_slider-3406124/src/Form/MDSliderImageForm.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 7 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is Drupal\Core\Ajax\AjaxResponse.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...3406124/web/modules/custom/md_slider-3406124/src/Form/MDSliderEditForm.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 9 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is Drupal\Core\Form\FormStateInterface.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...06124/web/modules/custom/md_slider-3406124/src/Form/MDSliderConfigForm.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 8 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is Drupal\Core\Form\FormStateInterface.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...406124/web/modules/custom/md_slider-3406124/src/Form/MDSliderCloneForm.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 12 | ERROR | [x] Use statements should be sorted alphabetically. The first
    |       |     wrong one is Drupal\Core\Messenger\MessengerInterface.
    |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...web/modules/custom/md_slider-3406124/src/Controller/MDSliderController.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is Drupal\Core\Controller\ControllerBase.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...ue/md_slider-3406124/web/modules/custom/md_slider-3406124/md_slider.module
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 13 | ERROR | [x] Use statements should be sorted alphabetically. The first
    |       |     wrong one is Drupal\file\Entity\File.
    |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
Time: 527ms; Memory: 8MB
๐Ÿ“Œ Task
Status

Needs review

Version

1.5

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia aman_lnwebworks

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 @aman_lnwebworks
  • Gaurav Gupta Jaipur, Rajasthsan

    Gaurav Gupta โ†’ made their first commit to this issueโ€™s fork.

  • Merge request !13406124-: Solve phpcs error. โ†’ (Open) created by Gaurav Gupta
  • Status changed to Needs review 7 months ago
  • ๐Ÿ‡ป๐Ÿ‡ณVietnam HoangD
  • Status changed to Needs work 6 months ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines clarkssquared

    Hi

    I applied MR !1 and I noticed that there is a file that the patch fails to apply

    โžœ  md_slider git:(master) โœ— curl https://git.drupalcode.org/project/md_slider/-/merge_requests/1.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  155k    0  155k    0     0   225k      0 --:--:-- --:--:-- --:--:--  228k
    patching file md_slider.install
    patching file md_slider.module
    patching file 'src/Ajax/ImageDialogSave.php'
    patching file 'src/Controller/MDSliderController.php'
    patching file 'src/Form/MDSliderCloneForm.php'
    patching file 'src/Form/MDSliderConfigForm.php'
    patching file 'src/Form/MDSliderDeleteForm.php'
    patching file 'src/Form/MDSliderEditForm.php'
    patching file 'src/Form/MDSliderExportForm.php'
    patching file 'src/Form/MDSliderImageForm.php'
    patching file 'src/Form/MDSliderImportForm.php'
    patching file 'src/MDCommon.php'
    patching file 'src/MDSlide.php'
    patching file 'src/MDSlider.php'
    patching file 'src/MDSliderDataBase.php'
    patching file 'src/MDSliderInterface.php'
    patching file 'src/Plugin/Block/MDSliderBlock.php'
    patching file 'src/Plugin/Derivative/MDSliderBlock.php'
    patching file 'src/Plugin/Field/FieldFormatter/MDSliderFormatter.php'
    patching file 'src/Plugin/Field/FieldType/FieldMDSlider.php'
    patching file 'src/Plugin/Field/FieldWidget/MDSliderWidget.php'
    patching file 'src/Slider/MDSliderExport.php'
    patching file 'src/Slider/MDSliderImport.php'
    1 out of 5 hunks failed--saving rejects to 'src/Slider/MDSliderImport.php.rej'
    patching file 'src/Slider/MDSliderRenderCss.php'
    patching file 'src/Slider/MDSliderZip.php'
    โžœ  md_slider git:(master) โœ—
    

    I also checked the PHPCS issues and there are so many issues that the PHPCS flagged, below is the preview of what are the errors I couldn't add the whole errors because it is too many.

    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/md_slider/src/Slider/MDSliderExport.php
    --------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 5 ERRORS AFFECTING 5 LINES
    --------------------------------------------------------------------------------------------------------------------------------------------
      51 | ERROR | unserialize() is insecure unless allowed classes are limited. Use a safe format like JSON or use the allowed_classes option.
      57 | ERROR | unserialize() is insecure unless allowed classes are limited. Use a safe format like JSON or use the allowed_classes option.
      58 | ERROR | unserialize() is insecure unless allowed classes are limited. Use a safe format like JSON or use the allowed_classes option.
     112 | ERROR | The array declaration extends to column 96 (the limit is 80). The array content should be split up over multiple lines
     121 | ERROR | Public method name "MDSliderExport::exportMDSlider" is not in lowerCamel format
    --------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/md_slider/src/Controller/MDSliderController.php
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 17 ERRORS AND 10 WARNINGS AFFECTING 24 LINES
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      23 | ERROR   | Public method name "MDSliderController::listMDSlider" is not in lowerCamel format
      78 | ERROR   | Public method name "MDSliderController::configMDSlider" is not in lowerCamel format
      81 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
      95 | ERROR   | Public method name "MDSliderController::editMDSlider" is not in lowerCamel format
      98 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     116 | ERROR   | The $_POST super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->request->get('action') instead
     122 | ERROR   | The $_POST super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->request->get('fid') instead
     123 | ERROR   | The $_POST super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->request->get('fid') instead
     126 | ERROR   | The $_POST super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->request->get('slider_id') instead
     127 | ERROR   | The $_POST super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->request->get('slider_id') instead
     135 | WARNING | File::load calls should be avoided in classes, use dependency injection instead
     137 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     138 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     145 | ERROR   | The $_POST super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->request->get('url') instead
     145 | ERROR   | The $_POST super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->request->get('url') instead
     147 | ERROR   | The $_POST super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->request->get('url') instead
     154 | ERROR   | The $_POST super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->request->get('sid') instead
     172 | ERROR   | The $_POST super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->request->get('action') instead
     178 | ERROR   | The $_POST super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->request->get('change') instead
     180 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     194 | ERROR   | The $_POST super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->request->get('path') instead
     194 | ERROR   | The $_POST super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->request->get('path') instead
     194 | ERROR   | The $_POST super global must not be accessed directly; inject the request_stack service and use $stack->getCurrentRequest()->request->get('path') instead
     200 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     204 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     218 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
     219 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/md_slider/src/MDSlider.php
    -------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------------------------
     66 | ERROR | unserialize() is insecure unless allowed classes are limited. Use a safe format like JSON or use the allowed_classes option.
    -------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 1.5 secs; Memory: 22MB
    
    โžœ  contrib git:(master) โœ—
  • Status changed to Needs review 6 months ago
  • ๐Ÿ‡ป๐Ÿ‡ณVietnam HoangD
  • Assigned to nitin_lama
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama

    Updated the IS for remaining issues.

  • Issue was unassigned.
  • Status changed to Needs work 6 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    Why is only one of the Drupal rulesets used? There is also the DrupalPractice one, which would report more warnings/errors.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia priya_07_

    priya_07_ โ†’ changed the visibility of the branch 3406124- to hidden.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia priya_07_

    priya_07_ โ†’ changed the visibility of the branch 3406124- to active.

  • Status changed to Needs review 2 months ago
  • Gaurav Gupta Jaipur, Rajasthsan

    Solve all phpcs error using Drupal ruleset

  • Pipeline finished with Success
    2 months ago
    Total: 3693s
    #148859
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Pipeline finished with Success
    2 months ago
    Total: 3692s
    #148951
  • Pipeline finished with Success
    2 months ago
    Total: 3691s
    #149066
  • Status changed to Needs work 2 months ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines paraderojether

    Hi

    I reviewed MR!3, applied against Mega Slider 1.5.4, confirmed the patch applied however there are still phpcs that are not fixed.

    Kindly check and advise, please.
    Thank you.

  • Pipeline finished with Success
    2 months ago
    Total: 3557s
    #151246
  • Status changed to Needs review 29 days ago
  • Gaurav Gupta Jaipur, Rajasthsan

    Solve the phpcs issue and check the pipeline.
    Showing no phpcs error.

  • Pipeline finished with Success
    29 days ago
    Total: 3692s
    #183933
Production build 0.69.0 2024