Fix the errors/warnings reported by PHP_CodeSniffer

Created on 27 March 2023, over 1 year ago
Updated 5 March 2024, 10 months ago

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

FILE: ./bamboo_twig_config/src/TwigExtension/Config.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\bamboo_twig\TwigExtension\TwigExtensionBase.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./bamboo_twig_extensions/src/TwigExtension/TwigArray.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is Twig\Extension\AbstractExtension.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./bamboo_twig_extensions/src/TwigExtension/TwigDate.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\Core\Template\TwigEnvironment.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./bamboo_twig_extensions/src/TwigExtension/TwigText.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\Core\Template\TwigEnvironment.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./bamboo_twig_file/src/TwigExtension/File.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is Twig\TwigFilter.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./bamboo_twig_i18n/src/TwigExtension/I18n.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 7 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\bamboo_twig\TwigExtension\TwigExtensionBase.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./bamboo_twig_loader/src/TwigExtension/Loader.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\bamboo_twig\TwigExtension\TwigExtensionBase.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./bamboo_twig_loader/src/TwigExtension/Render.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 7 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\bamboo_twig\TwigExtension\TwigExtensionBase.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./bamboo_twig_security/src/TwigExtension/Security.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\bamboo_twig\TwigExtension\TwigExtensionBase.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./bamboo_twig_token/src/TwigExtension/Token.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\bamboo_twig\TwigExtension\TwigExtensionBase.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./drupalci.yml
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 21 | ERROR | [x] Expected 1 newline at end of file; 2 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./tests/modules/bamboo_twig_test/src/Controller/TestsController.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\Component\Datetime\DateTimePlus.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./tests/src/Functional/BambooTwigExtensionsI18nTest.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is Drupal\Component\Gettext\PoItem.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./tests/src/Functional/BambooTwigLoaderTest.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\Core\StreamWrapper\PublicStream.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./tests/src/Functional/BambooTwigRenderTest.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\Core\StreamWrapper\PublicStream.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./tests/src/Functional/BambooTwigTestBase.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\language\Entity\ConfigurableLanguage.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./tests/src/Kernel/Loader/EntityBlockTest.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 9 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\Tests\bamboo_twig\Traits\BlockCreationTrait.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./tests/src/Kernel/Render/ContentBlockTest.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 8 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\Tests\bamboo_twig\Traits\BlockCreationTrait.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./tests/src/Kernel/Render/ImageTest.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 7 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\Core\StreamWrapper\PublicStream.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 484ms; Memory: 10MB
📌 Task
Status

Fixed

Version

6.0

Component

Code

Created by

🇮🇳India urvashi_vora Madhya Pradesh, India

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 @urvashi_vora
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India urvashi_vora Madhya Pradesh, India
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Status changed to Needs work over 1 year ago
  • 🇨🇭Switzerland wengerk Lausanne

    Thanks for your contrib

    1. on README.md and CONTRIBUTING.md, when breaking command line please add \ to keep it usable

    Exemple:

    -    docker-compose exec -u www-data drupal drush site-install standard --db-url="mysql://drupal:drupal@db/drupal" --site-name=Example -y
    +    docker-compose exec -u www-data drupal drush site-install standard \
    +    --db-url="mysql://drupal:drupal@db/drupal" --site-name=Example -y
    
  • First commit to issue fork.
  • Status changed to Needs review over 1 year ago
  • Status changed to Needs work over 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    -  $ docker-compose exec drupal ./vendor/bin/phpcs ./web/modules/contrib/bamboo_twig/
    +  $ docker-compose exec drupal ./vendor/bin/phpcs
    +  ./web/modules/contrib/bamboo_twig/
    
    -  $ docker-compose exec drupal phpmd ./web/modules/contrib/bamboo_twig/ text ./phpmd.xml \
    -  --suffixes php,module,inc,install,test,profile,theme,css,info,txt --exclude *Test.php,*vendor/*
    +  $ docker-compose exec drupal phpmd ./web/modules/contrib/bamboo_twig/
    +  text ./phpmd.xml \
    +  --suffixes php,module,inc,install,test,profile,theme,css,info,txt
    +  --exclude *Test.php,*vendor/*
       ```
    

    The suggestion given in comment #5 has not been followed.

  • @apaderno comment #8 📌 Fix the errors/warnings reported by PHP_CodeSniffer Needs review code in hooks in post-commit file which it's not showing in phpcs report and comment #5 has suggested on README.md and CONTRIBUTING.md file which have fixed in merge request.

  • 🇨🇭Switzerland wengerk Lausanne

    We should look at what Devel did with a phpcsxml dist file and ignore the 80 limit chars for markdown files

    https://www.drupal.org/project/devel/issues/3133703

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    Yes, and use that for any coding standards issue. When users report coding standards, they should be said to use the phpcs.xml.dist file that comes with the module. If they show the output of phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,js,info,txt,md,yml,twig, they should be said those reports will not be used.

    As a side note, even Drupal core uses a phpcs.xml.dist or phpcs.xml file containing their own rules.

  • First commit to issue fork.
  • Open on Drupal.org →
    Core: 10.1.4 + Environment: PHP 8.1 & MariaDB 10.3.22
    last update about 1 year ago
    Not currently mergeable.
  • 🇮🇳India pray_12

    Fixed the issues reported by phpcs

  • 🇮🇳India pray_12

    Preethy_ray changed the visibility of the branch 3350583-fix-the-issues to hidden.

  • 🇮🇳India zkhan.aamir

    Hi

    Patch #13 is empty

    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules/contrib/bamboo_twig (6.0.x)
    $ curl https://www.drupal.org/files/issues/2023-11-29/phpcs-fix-3350583.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
      0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
    
  • Status changed to Needs review 11 months ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 11 months ago
    Patch Failed to Apply
  • 🇮🇳India pray_12

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

    git apply -v 3350583-17.patch
    3350583-17.patch:22: trailing whitespace.
    - rework tests by using a custom theme "bamboo_twig" in order of overriding
    3350583-17.patch:30: trailing whitespace.
    - allow Render form mixed parameter types - Issue #3273960 by darrenwh,
    3350583-17.patch:32: trailing whitespace.
    - add `bamboo_render_entity_revision` rendering of entity revision -
    3350583-17.patch:34: trailing whitespace.
    - add `bamboo_load_entity_revision` loading of entity revision -
    3350583-17.patch:44: trailing whitespace.
    - fix deprecation
    Checking patch CHANGELOG.md...
    error: while searching for:
    ### Changed
    - re-enable PHPUnit Symfony Deprecation notice
    - update codebase to be compliant PHP8.2
    - rework tests by using a custom theme "bamboo_twig" in order of overriding *.html.twig template for tests purpose

    ### Added
    - add coverage of Drupal 10.1.x
    - allow Render form mixed parameter types - Issue #3273960 by darrenwh, wengerk
    - add `bamboo_render_entity_revision` rendering of entity revision - Issue #3254160 by dibix, wengerk
    - add `bamboo_load_entity_revision` loading of entity revision - Issue #3254160 by dibix, wengerk

    ## [6.0.0] - 2022-11-18
    ### Added

    error: patch failed: CHANGELOG.md:8
    error: CHANGELOG.md: patch does not apply
    Checking patch CONTRIBUTING.md...
    Checking patch README.md...
    Hunk #15 succeeded at 394 (offset 1 line).
    Hunk #16 succeeded at 414 (offset 1 line).
    Hunk #17 succeeded at 431 (offset 1 line).
    Hunk #18 succeeded at 443 (offset 1 line).
    Hunk #19 succeeded at 455 (offset 1 line).
    Hunk #20 succeeded at 483 (offset 1 line).
    error: while searching for:
    {{ bamboo_render_image(1, 'thumbnail') }}
    ```

    `bamboo_render_image_style(path, style, preprocess)` returns the URL string of the
    specified image path or URI.

    - `path` string
    - `style` string

    error: patch failed: README.md:437
    error: README.md: patch does not apply
    Checking patch drupalci.yml...
    Checking patch CONTRIBUTING.md...
    Checking patch README.md...
    error: while searching for:
    The Bamboo Twig module provides some Twig extensions with some useful functions
    and filters aimed to improve the development experience.

    Bamboo Twig has a lot of advantages and brings a lot of new features
    to the Twig landscape of Drupal 8.
    It boosts performance by using lazy loading, improves the code quality
    with automated workflow. It also includes automated unit and kernel tests

    error: patch failed: README.md:11
    error: README.md: patch does not apply
    Checking patch bamboo_twig_config/src/TwigExtension/Config.php...
    Checking patch bamboo_twig_extensions/src/TwigExtension/TwigArray.php...
    Checking patch bamboo_twig_extensions/src/TwigExtension/TwigDate.php...
    Checking patch bamboo_twig_extensions/src/TwigExtension/TwigText.php...
    Checking patch bamboo_twig_file/src/TwigExtension/File.php...
    Checking patch bamboo_twig_i18n/src/TwigExtension/I18n.php...
    Checking patch bamboo_twig_loader/src/TwigExtension/Loader.php...
    Checking patch bamboo_twig_loader/src/TwigExtension/Render.php...
    Checking patch bamboo_twig_security/src/TwigExtension/Security.php...
    Checking patch bamboo_twig_token/src/TwigExtension/Token.php...
    Checking patch tests/modules/bamboo_twig_test/src/Controller/TestsController.php...
    Checking patch tests/src/Functional/BambooTwigExtensionsI18nTest.php...
    Checking patch tests/src/Functional/BambooTwigLoaderTest.php...
    Checking patch tests/src/Functional/BambooTwigRenderTest.php...
    Checking patch tests/src/Functional/BambooTwigTestBase.php...

  • Status changed to Needs work 11 months ago
  • Hi, the patch #17 is throwing as mentioned above so changing the status to Needs work.
    Thankyou.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 11 months ago
    Waiting for branch to pass
  • Status changed to Needs review 11 months ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    I fixed all the warnings/errors for the files the phpcs.xml.dist file committed in the project repository would check.

  • 🇨🇭Switzerland wengerk Lausanne

    Thx Apaderno ! I will take a look a it asap.

    I'm concerned by the failing tests and open another issue to fix it, it's easy to fix but I currently don't have much time for open source

    If you wanna help, you're welcome :)
    https://www.drupal.org/project/bamboo_twig/issues/3417699 🐛 Tests failing on Drupal 10 because Tests module has same name as Test Theme Needs work

  • Status changed to Fixed 10 months ago
  • 🇨🇭Switzerland wengerk Lausanne

    Many Many thanks to all of you ! Has been merged on 6.0.x

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

Production build 0.71.5 2024