Fix the errors/warnings reported by Php_CodeSniffer

Created on 11 January 2023, over 2 years ago
Updated 25 June 2024, about 1 year 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.

Production build 0.71.5 2024