Fix the errors/warnings reported by Php_CodeSniffer

Created on 11 January 2023, almost 2 years ago
Updated 25 June 2024, 5 months ago

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

FILE: ./README.md
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 144 | WARNING | Line exceeds 80 characters; contains 93 characters
----------------------------------------------------------------------


FILE: ./src/Form/AllowedBlocksForm.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 11 | ERROR | [x] Use statements should be sorted alphabetically. The
    |       |     first wrong one is
    |       |     Drupal\Core\Form\FormBuilderInterface.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./LayoutBuilderRestriction/EntityViewModeRestrictionByRegion.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 7 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is Drupal\Core\Database\Connection.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./tests/src/FunctionalJavascript/MoveBlockAllowlistTest.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 7 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\layout_library\Entity\Layout.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./tests/src/FunctionalJavascript/MoveBlockCategoryRestrictionTest.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 7 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\layout_library\Entity\Layout.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./tests/src/FunctionalJavascript/MoveBlockDenylistTest.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 7 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\layout_library\Entity\Layout.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Form/MoveBlockForm.php
----------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
----------------------------------------------------------------------
  7 | ERROR   | [x] Use statements should be sorted alphabetically.
    |         |     The first wrong one is
    |         |     Drupal\Core\Ajax\AjaxResponse.
 32 | WARNING | [x] '@todo: respect ordering of plugins (see
    |         |     #3045266)' should match the format '@todo Fix
    |         |     problem X here.'
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Form/RestrictionPluginConfigForm.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 8 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\layout_builder_restrictions\Plugin\LayoutBuilderRestrictionManager.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Plugin/LayoutBuilderRestriction/EntityViewModeRestriction.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 7 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is Drupal\Core\Database\Connection.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Plugin/LayoutBuilderRestrictionBase.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 8 | ERROR | [x] Use statements should be sorted alphabetically. The
   |       |     first wrong one is
   |       |     Drupal\Core\Plugin\ContainerFactoryPluginInterface.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Plugin/LayoutBuilderRestrictionManager.php
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
  6 | ERROR | [x] Use statements should be sorted alphabetically. The
    |       |     first wrong one is
    |       |     Drupal\Core\Cache\CacheBackendInterface.
 99 | ERROR | [ ] The array declaration extends to column 86 (the
    |       |     limit is 80). The array content should be split up
    |       |     over multiple lines
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Traits/PluginHelperTrait.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 10 | ERROR | [x] Use statements should be sorted alphabetically. The
    |       |     first wrong one is
    |       |     Drupal\Core\StringTranslation\StringTranslationTrait.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./tests/src/FunctionalJavascript/CategoryRestrictionsTest.php
----------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
----------------------------------------------------------------------
 18 | WARNING | [ ] Unused variable $blocks.
 37 | ERROR   | [x] Functions must not contain multiple empty lines
    |         |     in a row; found 2 empty lines
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./tests/src/FunctionalJavascript/DefaultRestrictionsTest.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
 17 | WARNING | Unused variable $blocks.
 49 | WARNING | Unused variable $blocks.
----------------------------------------------------------------------


FILE: ./tests/src/FunctionalJavascript/LanguageCategoriesTest.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 5 LINES
----------------------------------------------------------------------
  46 | WARNING | t() calls should be avoided in classes, use
     |         | \Drupal\Core\StringTranslation\StringTranslationTrait
     |         | and $this->t() instead
  52 | WARNING | t() calls should be avoided in classes, use
     |         | \Drupal\Core\StringTranslation\StringTranslationTrait
     |         | and $this->t() instead
  57 | WARNING | t() calls should be avoided in classes, use
     |         | \Drupal\Core\StringTranslation\StringTranslationTrait
     |         | and $this->t() instead
  65 | WARNING | t() calls should be avoided in classes, use
     |         | \Drupal\Core\StringTranslation\StringTranslationTrait
     |         | and $this->t() instead
 110 | WARNING | Unused variable $blocks.
----------------------------------------------------------------------


FILE: ./src/FunctionalJavascript/LayoutBuilderRestrictionsTestBase.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 33 | WARNING | Unused variable $assert_session.
----------------------------------------------------------------------


FILE: ./tests/src/FunctionalJavascript/LayoutRestrictionsTest.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 17 | WARNING | Unused variable $blocks.
----------------------------------------------------------------------


FILE: ./tests/src/FunctionalJavascript/MoveBlockRestrictionTest.php
----------------------------------------------------------------------
FOUND 3 ERRORS AND 1 WARNING AFFECTING 4 LINES
----------------------------------------------------------------------
   6 | ERROR   | [x] Use statements should be sorted alphabetically.
     |         |     The first wrong one is
     |         |     Drupal\layout_library\Entity\Layout.
  68 | ERROR   | [ ] Public method name
     |         |     "MoveBlockRestrictionTest::XtestLayoutLibraryMovePluginBlock"
     |         |     is not in lowerCamel format
 139 | ERROR   | [ ] Public method name
     |         |     "MoveBlockRestrictionTest::XtestMovePluginBlock"
     |         |     is not in lowerCamel format
 260 | WARNING | [ ] Unused variable $node_id.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./tests/src/Traits/MoveBlockHelperTrait.php
----------------------------------------------------------------------
FOUND 3 ERRORS AND 1 WARNING AFFECTING 4 LINES
----------------------------------------------------------------------
  32 | ERROR   | [x] Doc comment short description must end with a
     |         |     full stop
  44 | ERROR   | [x] Inline comments must end in full-stops,
     |         |     exclamation marks, question marks, colons, or
     |         |     closing parentheses
  46 | WARNING | [x] '@todo: Make this more abstracted for other
     |         |     scenarios.' should match the format '@todo Fix
     |         |     problem X here.'
 156 | ERROR   | [ ] The array declaration extends to column 94 (the
     |         |     limit is 80). The array content should be split
     |         |     up over multiple lines
----------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 891ms; Memory: 14MB
📌 Task
Status

Closed: outdated

Version

3.0

Component

Code

Created by

🇮🇳India shivam-kumar

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Status changed to Needs review almost 2 years ago
  • Status changed to Needs work 12 months ago
  • 🇺🇸United States mark_fullmer Tucson

    The most recent patch no longer applies to the latest version of the 8.x-2.x branch. Setting to "Needs work" for a patch update.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Assigned to nitin_lama
  • 🇮🇳India nitin_lama India

    Providing updated patch. Updating IS with the remaining issues. I think we can keep the code as it is. Also README.md file is not updated as per README.md template .

  • Status changed to Needs review 11 months ago
  • 🇮🇳India nitin_lama India

    Please review. Thanks.

  • Issue was unassigned.
  • Status changed to Needs work 11 months ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    -      // @todo: respect ordering of plugins (see #3045266)
    +      // @todo respect ordering of plugins (see #3045266)

    What follows @todo is a sentence: It starts with a capitalized word and it ends with a period (preferable), a question mark, or an exclamation point.

         // Create 2 custom block types, with 3 block instances.
    -    $blocks = $this->generateTestBlocks();
         $node_id = $this->generateTestNode();

    Removing a variable that is not used does not mean removing the full line that initializes that variable. Differently, the custom block types would not be created.

         // Before: 'Body (current)*'
    -    // After: 'Body (current) *'
    +    // After: 'Body (current) *'.

    I would rather remove those (three) comments, as they do not make the previous comment clearer.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    As a side note, the report shows errors/warnings for 19 files, not eight files the patch is changing. Watch out for those warnings which suggest to use $this->t() in test classes (where it should not be used).

  • 🇺🇸United States mark_fullmer Tucson
  • First commit to issue fork.
  • Merge request !31Update 17 files → (Open) created by immaculatexavier
  • Pipeline finished with Failed
    6 months ago
    Total: 416s
    #175314
  • Status changed to Closed: outdated 5 months ago
  • 🇺🇸United States mark_fullmer Tucson

    The most recent version of 3.x shows no coding syntax issues reported by PHPCS: https://git.drupalcode.org/project/layout_builder_restrictions/-/pipelin...

    Closing this issue as outdated. Thanks for the help, regardless, everyone!

Production build 0.71.5 2024