Fix the issues reported by phpcs

Created on 2 June 2023, about 1 year ago
Updated 2 April 2024, 3 months ago

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

FILE: ./swiper_formatter/src/Element/SwiperFormatterSettings.php
--------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------
 71 | ERROR | [x] Use null coalesce operator instead of ternary operator.
--------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------


FILE: ./swiper_formatter/src/Plugin/views/style/SwiperFormatterStyle.php
----------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
----------------------------------------------------------------------------------------------------------
 233 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 330 | ERROR | [x] Use null coalesce operator instead of ternary operator.
 359 | ERROR | [x] Use null coalesce operator instead of ternary operator.
----------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------


FILE: ./swiper_formatter/templates/swiper-formatter.html.twig
-----------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------
 51 | ERROR | [x] Expected 1 newline at end of file; 0 found
-----------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------


FILE: ./swiper_formatter/templates/swiper-formatter-slide.html.twig
-----------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------
 38 | ERROR | [x] Expected 1 newline at end of file; 0 found
-----------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------

Time: 357ms; Memory: 14MB

📌 Task
Status

Fixed

Version

1.0

Component

Code

Created by

🇵🇭Philippines paraderojether

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.

  • Needs reroll

    The patch will have to be re-rolled with new suggestions/changes described in the comments in the issue.

Sign in to follow issues

Comments & Activities

  • Issue created by @paraderojether
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • 🇵🇭Philippines paraderojether

    Created a patch to fix the issues reported by phpcs.

    Please review.
    Thank You.

  • Hello Guys,
    I have applied and tested the #2 patch for swiper_formatter 1.0.x-dev and the phpcs issues has been successfully fixed! The patch was tested on Drupal 9.5.9 and PHP 8.2.4. To provide you with a comprehensive view, I will be adding both a before and after screenshots.

    Thank you for your support!!

  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    phpcs reports more warnings/errors than the ones shown in the issue summary.

  • Assigned to nitin_lama
  • 🇮🇳India nitin_lama

    True @apaderno. There are issues still left after applying the patch #2.
    phpcs reports only for js/swiper_formatter.js file. Attaching ss for reference.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    drupalcs does not produce the same report phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig gives, at least because the latter does not check JavaScript files.

  • 🇮🇳India nitin_lama

    I'm using alias for the commands @apaderno.

  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • 🇵🇭Philippines paraderojether

    Hi I updated the patch to address the other issues that are added in the summary.

    Please review.
    Thank You.

  • 🇮🇳India arpitk

    Hi here is the updated patch.
    command used; phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,js .
    Please review.

    Thanks!

  • 🇮🇳India Preethy_ray

    Hi,
    After reviewing patches #9 and #10, patch is applied successfully without any issues. However, there are still a few remaining PHPCS errors that need to be addressed.
    command used:phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig swiper_formatter/

    FILE: /swiper_formatter/src/SwiperFormatterTrait.php
    ------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------------------
     7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Field\FieldDefinitionInterface.
    ------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /swiper_formatter/src/Element/SwiperFormatterSettings.php
    --------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------------------
     8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Link.
    --------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /swiper_formatter/src/Form/SwiperFormatterForm.php
    ---------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------------------------
     7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\EntityTypeManagerInterface.
    ---------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /swiper_formatter/src/Plugin/views/style/SwiperFormatterStyle.php
    -----------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------
     7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Form\FormStateInterface.
    -----------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /swiper_formatter/src/Plugin/Field/FieldFormatter/SwiperFormatterEntity.php
    ------------------------------------------------------------------------------------------------------------------------------------------------------------FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------------------------------------------ 7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is
       |       |     Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceEntityFormatter.
    ------------------------------------------------------------------------------------------------------------------------------------------------------------PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    FILE: /swiper_formatter/src/Plugin/Field/FieldFormatter/SwiperFormatterText.php
    --------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------------------------------------
     6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\swiper_formatter\SwiperFormatterTrait.
    --------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /swiper_formatter/swiper_formatter.module
    -----------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------
     9 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Cache\Cache.
    -----------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------
    
  • 🇮🇳India Preethy_ray

    Hi,
    I have addressed the remaining phpcs errors and warnings.
    Please review!!!

  • 🇮🇳India karanpagare

    Tested Patch #12 , Looks fine to me , which fixes phpcs issues as per command phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig swiper_formatter/

    • nk_ committed 9fe218db on 1.0.x
      Issue #3364330 by paraderojether, arpitk, pray_12, nitin_lama,...
  • Status changed to Fixed 3 months ago
  • 🇳🇱Netherlands nk_

    Thank you all! It was finally committed in the new release , the last one supporting Drupal 8.8 and 9. A brand new branch 2.0.x with quite some new features is there and recommended for a future use.

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

Production build 0.69.0 2024