Fix the errors/warnings reported by PHP_CodeSniffer

Created on 6 June 2022, over 2 years ago
Updated 29 December 2023, 12 months ago

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

FILE: ./config_files/config_files.post_update.php
----------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
----------------------------------------------------------------------
 31 | ERROR | Inline doc block comments are not allowed; use "/*
    |       | Comment */" or "// Comment" instead
 33 | ERROR | Inline doc block comments are not allowed; use "/*
    |       | Comment */" or "// Comment" instead
 35 | ERROR | Inline doc block comments are not allowed; use "/*
    |       | Comment */" or "// Comment" instead
----------------------------------------------------------------------


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


FILE: ./config_files/src/ConfigFilesUninstallValidator.php
----------------------------------------------------------------------
FOUND 14 ERRORS AFFECTING 14 LINES
----------------------------------------------------------------------
  1 | ERROR | [ ] An error occurred during processing; checking has
    |       |     been aborted. The error message was: Undefined
    |       |     array key "scope_closer" in
    |       |     /home/kiamlaluno/.composer/vendor/slevomat/coding-standard/SlevomatCodingStandard/Helpers/UseStatementHelper.php
    |       |     on line 194
    |       |     The error originated in the
    |       |     SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses
    |       |     sniff on line 70.
 13 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found
    |       |     2
 15 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found
    |       |     2
 21 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found
    |       |     2
 22 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found
    |       |     4
 23 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found
    |       |     2
 25 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found
    |       |     2
 28 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found
    |       |     2
 29 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found
    |       |     4
 30 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found
    |       |     4
 31 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found
    |       |     6
 32 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found
    |       |     4
 34 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found
    |       |     4
 35 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found
    |       |     2
----------------------------------------------------------------------
PHPCBF CAN FIX THE 13 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./config_files/src/ProxyClass/ConfigFilesUninstallValidator.php
----------------------------------------------------------------------
FOUND 3 ERRORS AND 2 WARNINGS AFFECTING 5 LINES
----------------------------------------------------------------------
  7 | WARNING | [x] Unused use statement
  9 | ERROR   | [x] When importing a class with "use", do not include
    |         |     a leading \
 12 | WARNING | [ ] Line exceeds 80 characters; contains 81
    |         |     characters
 17 | ERROR   | [x] Line indented incorrectly; expected 2 spaces,
    |         |     found 0
 51 | ERROR   | [x] Expected 1 blank line after function; 0 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./config_tools.install
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 10 | ERROR | [x] Use statements should be sorted alphabetically. The
    |       |     first wrong one is GitWrapper\GitException.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


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


FILE: ./git_config/git_config.post_update.php
----------------------------------------------------------------------
FOUND 3 ERRORS AND 3 WARNINGS AFFECTING 6 LINES
----------------------------------------------------------------------
  8 | WARNING | [x] Unused use statement
  9 | WARNING | [x] Unused use statement
 10 | WARNING | [x] Unused use statement
 16 | ERROR   | [ ] Inline doc block comments are not allowed; use
    |         |     "/* Comment */" or "// Comment" instead
 18 | ERROR   | [ ] Inline doc block comments are not allowed; use
    |         |     "/* Comment */" or "// Comment" instead
 20 | ERROR   | [ ] Inline doc block comments are not allowed; use
    |         |     "/* Comment */" or "// Comment" instead
----------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/EventSubscriber/ConfigSubscriber.php
----------------------------------------------------------------------
FOUND 1 ERROR AND 9 WARNINGS AFFECTING 10 LINES
----------------------------------------------------------------------
   6 | ERROR   | [x] Use statements should be sorted alphabetically.
     |         |     The first wrong one is
     |         |     Drupal\Core\Config\ConfigCrudEvent.
  44 | WARNING | [ ] \Drupal calls should be avoided in classes, use
     |         |     dependency injection instead
  49 | WARNING | [ ] \Drupal calls should be avoided in classes, use
     |         |     dependency injection instead
  57 | WARNING | [ ] \Drupal calls should be avoided in classes, use
     |         |     dependency injection instead
  71 | WARNING | [ ] \Drupal calls should be avoided in classes, use
     |         |     dependency injection instead
  76 | WARNING | [ ] \Drupal calls should be avoided in classes, use
     |         |     dependency injection instead
  95 | WARNING | [ ] \Drupal calls should be avoided in classes, use
     |         |     dependency injection instead
 102 | WARNING | [ ] \Drupal calls should be avoided in classes, use
     |         |     dependency injection instead
 118 | WARNING | [ ] \Drupal calls should be avoided in classes, use
     |         |     dependency injection instead
 122 | WARNING | [ ] \Drupal calls should be avoided in classes, use
     |         |     dependency injection instead
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Form/SettingsForm.php
----------------------------------------------------------------------
FOUND 1 ERROR AND 17 WARNINGS AFFECTING 17 LINES
----------------------------------------------------------------------
   6 | WARNING | [x] Unused use statement
   9 | WARNING | [x] Unused use statement
  26 | WARNING | [ ] Possible useless method overriding detected
  59 | WARNING | [ ] t() calls should be avoided in classes, use
     |         |     \Drupal\Core\StringTranslation\StringTranslationTrait
     |         |     and $this->t() instead
  60 | WARNING | [ ] t() calls should be avoided in classes, use
     |         |     \Drupal\Core\StringTranslation\StringTranslationTrait
     |         |     and $this->t() instead
  66 | WARNING | [ ] t() calls should be avoided in classes, use
     |         |     \Drupal\Core\StringTranslation\StringTranslationTrait
     |         |     and $this->t() instead
  67 | WARNING | [ ] t() calls should be avoided in classes, use
     |         |     \Drupal\Core\StringTranslation\StringTranslationTrait
     |         |     and $this->t() instead
  73 | WARNING | [ ] t() calls should be avoided in classes, use
     |         |     \Drupal\Core\StringTranslation\StringTranslationTrait
     |         |     and $this->t() instead
  74 | WARNING | [ ] t() calls should be avoided in classes, use
     |         |     \Drupal\Core\StringTranslation\StringTranslationTrait
     |         |     and $this->t() instead
  75 | WARNING | [ ] t() calls should be avoided in classes, use
     |         |     \Drupal\Core\StringTranslation\StringTranslationTrait
     |         |     and $this->t() instead
  75 | ERROR   | [x] Array indentation error, expected 6 spaces but
     |         |     found 9
  81 | WARNING | [ ] t() calls should be avoided in classes, use
     |         |     \Drupal\Core\StringTranslation\StringTranslationTrait
     |         |     and $this->t() instead
  83 | WARNING | [ ] t() calls should be avoided in classes, use
     |         |     \Drupal\Core\StringTranslation\StringTranslationTrait
     |         |     and $this->t() instead
  89 | WARNING | [ ] t() calls should be avoided in classes, use
     |         |     \Drupal\Core\StringTranslation\StringTranslationTrait
     |         |     and $this->t() instead
  91 | WARNING | [ ] t() calls should be avoided in classes, use
     |         |     \Drupal\Core\StringTranslation\StringTranslationTrait
     |         |     and $this->t() instead
  97 | WARNING | [ ] t() calls should be avoided in classes, use
     |         |     \Drupal\Core\StringTranslation\StringTranslationTrait
     |         |     and $this->t() instead
  99 | WARNING | [ ] t() calls should be avoided in classes, use
     |         |     \Drupal\Core\StringTranslation\StringTranslationTrait
     |         |     and $this->t() instead
 112 | WARNING | [ ] \Drupal calls should be avoided in classes, use
     |         |     dependency injection instead
----------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 158ms; Memory: 6MB
📌 Task
Status

Needs work

Version

2.0

Component

Code

Created by

🇷🇺Russia pavelgerasuta

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

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