Fix the issues reported by phpcs

Created on 7 July 2023, over 1 year ago
Updated 17 July 2024, 8 months ago

Running phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig /var/www/html/VB/drupal-10.1.0/modules/contrib/toggle-2.0.1 shows the following warnings/errors that should be fixed.

FILE: /var/www/html/VB/drupal-10.1.0/modules/contrib/toggle-2.0.1/toggle/lib/Drupal/toggle/Plugin/field/FieldWidget/ToggleWidget.php
-------------------------------------------------------------------------
FOUND 23 ERRORS AND 14 WARNINGS AFFECTING 22 LINES
-------------------------------------------------------------------------
  25 | ERROR   | [ ] Missing short description in doc comment
  29 | WARNING | [x] '@TODO This is a temporary stop-gap implementation. Not quite sure what's' should match the format '@todo Fix problem X here.'
  33 | ERROR   | [x] Short array syntax must be used to define arrays
  34 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  42 | ERROR   | [x] Short array syntax must be used to define arrays
  43 | ERROR   | [x] Line indented incorrectly; expected at least 4 spaces, found 0
  43 | ERROR   | [x] 6 spaces found before inline comment; expected "// 'ajax' => FALSE," but found "//      'ajax' => FALSE,"
  53 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 0
  53 | ERROR   | [ ] Comment indentation error, expected only 1 spaces
  54 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 0
  54 | ERROR   | [ ] Comment indentation error, expected only 4 spaces
  55 | WARNING | [ ] Line exceeds 80 characters; contains 90 characters
  55 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 0
  56 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 0
  57 | WARNING | [x] There must be no blank line following an inline comment
  57 | WARNING | [ ] There must be no blank line following an inline comment
  57 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 0
  57 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
  60 | ERROR   | [x] Short array syntax must be used to define arrays
  62 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  74 | ERROR   | [x] Short array syntax must be used to define arrays
  82 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  82 | ERROR   | [x] Short array syntax must be used to define arrays
  85 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 0
  85 | ERROR   | [ ] Comment indentation error, expected only 1 spaces
  86 | WARNING | [ ] Line exceeds 80 characters; contains 88 characters
  86 | WARNING | [x] There must be no blank line following an inline comment
  86 | WARNING | [ ] There must be no blank line following an inline comment
  86 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 0
  86 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 112 | ERROR   | [x] Short array syntax must be used to define arrays
 116 | ERROR   | [x] Short array syntax must be used to define arrays
 123 | ERROR   | [x] Short array syntax must be used to define arrays
 134 | WARNING | [x] '@TODO #ajax' should match the format '@todo Fix problem X here.'
 135 | WARNING | [x] There must be no blank line following an inline comment
 135 | WARNING | [x] '@TODO get/add entity id + other metadata for AJAX?' should match the format '@todo Fix problem X here.'
 135 | WARNING | [ ] There must be no blank line following an inline comment
-------------------------------------------------------------------------
PHPCBF CAN FIX THE 25 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------

FILE: /var/www/html/VB/drupal-10.1.0/modules/contrib/toggle-2.0.1/toggle/lib/Drupal/toggle/Plugin/Field/FieldFormatter/ToggleFormatter.php
-------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
-------------------------------------------------------------------------
  6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Field\FieldItemListInterface.
 28 | ERROR | [x] Short array syntax must be used to define arrays
 31 | ERROR | [x] Short array syntax must be used to define arrays
-------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------

FILE: /var/www/html/VB/drupal-10.1.0/modules/contrib/toggle-2.0.1/toggle/contrib/toggle_example/toggle_example.module
-------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-------------------------------------------------------------------------
 1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
 5 | ERROR | [x] Expected 1 newline at end of file; 2 found


-------------------------------------------------------------------------

FILE: /var/www/html/VB/drupal-10.1.0/modules/contrib/toggle-2.0.1/toggle/toggle.module
-------------------------------------------------------------------------
FOUND 42 ERRORS AND 3 WARNINGS AFFECTING 40 LINES
-------------------------------------------------------------------------
   9 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Routing\RouteMatchInterface.
   9 | ERROR   | [x] There must be one blank line after the last USE statement; 2 found;
  15 | ERROR   | [x] Expected 1 blank line before function; 2 found
  16 | ERROR   | [x] Short array syntax must be used to define arrays
  18 | ERROR   | [x] Short array syntax must be used to define arrays
  20 | ERROR   | [x] Short array syntax must be used to define arrays
  24 | ERROR   | [x] Short array syntax must be used to define arrays
  25 | ERROR   | [x] Short array syntax must be used to define arrays
  28 | ERROR   | [x] Short array syntax must be used to define arrays
  31 | ERROR   | [x] Short array syntax must be used to define arrays
  32 | ERROR   | [x] Short array syntax must be used to define arrays
  34 | WARNING | [x] A comma should follow the last multiline array item. Found: 'toggle_pre_render_radio'
  37 | ERROR   | [x] Short array syntax must be used to define arrays
  41 | ERROR   | [x] Short array syntax must be used to define arrays
  43 | ERROR   | [x] Short array syntax must be used to define arrays
  47 | ERROR   | [x] Short array syntax must be used to define arrays
  48 | ERROR   | [x] Short array syntax must be used to define arrays
  51 | ERROR   | [x] Short array syntax must be used to define arrays
  54 | ERROR   | [x] Short array syntax must be used to define arrays
  55 | ERROR   | [x] Short array syntax must be used to define arrays
  60 | ERROR   | [x] Short array syntax must be used to define arrays
  71 | ERROR   | [x] Short array syntax must be used to define arrays
  72 | ERROR   | [x] Short array syntax must be used to define arrays
  76 | ERROR   | [x] Short array syntax must be used to define arrays
  80 | ERROR   | [x] Short array syntax must be used to define arrays
  84 | ERROR   | [x] Short array syntax must be used to define arrays
  92 | WARNING | [ ] Line exceeds 80 characters; contains 81 characters
  94 | ERROR   | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
 118 | WARNING | [ ] Line exceeds 80 characters; contains 82 characters
 119 | ERROR   | [x] Use "elseif" in place of "else if"
 130 | ERROR   | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
 151 | ERROR   | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
 166 | ERROR   | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
 179 | ERROR   | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
 181 | ERROR   | [ ] All functions defined in a module file must be prefixed with the module's name, found "form_type_toggle_checkbox_value" but expected
     |         |     "toggle_form_type_toggle_checkbox_value"
 187 | ERROR   | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
 189 | ERROR   | [ ] All functions defined in a module file must be prefixed with the module's name, found "form_type_toggle_checkboxes_value" but expected
     |         |     "toggle_form_type_toggle_checkboxes_value"
 195 | ERROR   | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
 197 | ERROR   | [ ] All functions defined in a module file must be prefixed with the module's name, found "form_type_toggle_radios_value" but expected
     |         |     "toggle_form_type_toggle_radios_value"
 224 | ERROR   | [x] Short array syntax must be used to define arrays
 224 | ERROR   | [ ] The array declaration extends to column 620 (the limit is 80). The array content should be split up over multiple lines
 224 | ERROR   | [x] Short array syntax must be used to define arrays
 224 | ERROR   | [x] Short array syntax must be used to define arrays
 228 | ERROR   | [x] Short array syntax must be used to define arrays
 228 | ERROR   | [x] Short array syntax must be used to define arrays
-------------------------------------------------------------------------
PHPCBF CAN FIX THE 32 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------

FILE: /var/www/html/VB/drupal-10.1.0/modules/contrib/toggle-2.0.1/toggle/README.txt
-------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-------------------------------------------------------------------------
 7 | WARNING | Line exceeds 80 characters; contains 100 characters
-------------------------------------------------------------------------

FILE: /var/www/html/VB/drupal-10.1.0/modules/contrib/toggle-2.0.1/toggle/TODO.txt
-------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-------------------------------------------------------------------------
 8 | WARNING | Line exceeds 80 characters; contains 81 characters
-------------------------------------------------------------------------

FILE: /var/www/html/VB/drupal-10.1.0/modules/contrib/toggle-2.0.1/toggle/assets/skins/toggle.default.css
-------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------
 1 | ERROR | [x] Expected 1 newline at end of file; 0 found
-------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------

FILE: /var/www/html/VB/drupal-10.1.0/modules/contrib/toggle-2.0.1/toggle/assets/toggle.css
-------------------------------------------------------------------------
FOUND 65 ERRORS AFFECTING 55 LINES
-------------------------------------------------------------------------
  5 | ERROR | [ ] Class definition is empty
 10 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 2
 11 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 11 | ERROR | [x] Closing brace of class definition must be on new line
 12 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 4
 13 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
 14 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
 15 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
 16 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
 17 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
 18 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
 19 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
 20 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
 21 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
 22 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
 22 | ERROR | [x] Closing brace of class definition must be on new line
 23 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 6
 23 | ERROR | [x] Multiple selectors should each be on a single line
 24 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
 25 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
 26 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
 27 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
 28 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
 29 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
 30 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
 31 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
 32 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
 33 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
 34 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
 35 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
 35 | ERROR | [x] Closing brace of class definition must be on new line
 36 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 6
 37 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
 38 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
 39 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
 40 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
 41 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
 42 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
 43 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
 44 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
 45 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
 46 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
 47 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
 48 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
 49 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 8
 49 | ERROR | [x] Closing brace of class definition must be on new line
 50 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 2
 51 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 51 | ERROR | [x] Closing brace of class definition must be on new line
 52 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 2
 53 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 54 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 55 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 56 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 56 | ERROR | [x] Closing brace of class definition must be on new line
 57 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 2
 58 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 59 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 59 | ERROR | [x] Closing brace of class definition must be on new line
 60 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 2
 61 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
 61 | ERROR | [x] Closing brace of class definition must be on new line
 62 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 4
 63 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 6
 63 | ERROR | [x] Closing brace of class definition must be on new line
-------------------------------------------------------------------------
PHPCBF CAN FIX THE 64 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------

FILE: /var/www/html/VB/drupal-10.1.0/modules/contrib/toggle-2.0.1/toggle/toggle.theme.inc
-------------------------------------------------------------------------
FOUND 4 ERRORS AND 2 WARNINGS AFFECTING 6 LINES
-------------------------------------------------------------------------
  13 | ERROR   | [ ] Missing parameter type
  27 | ERROR   | [x] Short array syntax must be used to define arrays
  65 | ERROR   | [ ] Missing parameter type
  79 | ERROR   | [x] Short array syntax must be used to define arrays
 135 | WARNING | [ ] Line exceeds 80 characters; contains 82 characters
 153 | WARNING | [ ] Line exceeds 80 characters; contains 82 characters
-------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------

Time: 89ms; Memory: 10MB
šŸ“Œ Task
Status

RTBC

Version

2.0

Component

Code

Created by

šŸ‡®šŸ‡³India indrapatil Bangalore

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

Comments & Activities

  • Issue created by @indrapatil
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹

    The content of the contrib/toggle_example/toggle_example.info.yml file is the following one.

    name: Toggle Example
    type: module
    description: 'Provides examples for working with the Toggle module.'
    package: Examples
    core: 8.x
    core_version_requirement: ^8 || ^9
    dependencies:
      - drupal:entity_reference
      - drupal:taxonomy
      - toggle:toggle
    

    It does not contain any project line, contrarily to what the PHP_CodeSniffer report says. Was the project cloned with git clone?

  • @indrapatil opened merge request.
  • šŸ‡®šŸ‡³India indrapatil Bangalore
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • šŸ‡®šŸ‡³India indrapatil Bangalore

    Yes, Its a git clone.

  • Status changed to Needs work over 1 year ago
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • First commit to issue fork.
  • Status changed to Needs review about 1 year ago
  • Status changed to RTBC 8 months ago
  • Hi @everyone,

    The changes on MR !2 can be applied successfully, no errors were reported.

    toggle git:(2.0.x) curl https://git.drupalcode.org/project/toggle/-/merge_requests/2.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 22400    0 22400    0     0  19567      0 --:--:--  0:00:01 --:--:-- 19928
    patching file README.txt
    patching file TODO.txt
    patching file assets/skins/toggle.default.css
    patching file assets/toggle.css
    patching file contrib/toggle_example/toggle_example.module
    patching file lib/Drupal/toggle/Plugin/Field/FieldFormatter/ToggleFormatter.php
    patching file lib/Drupal/toggle/Plugin/field/FieldWidget/ToggleWidget.php
    patching file toggle.module
    patching file toggle.theme.inc
    āžœ  toggle git:(2.0.x) āœ— cd ..
    āžœ  contrib git:(master) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig toggle
    āžœ  contrib git:(master) āœ—

    Will now move this to RTBC.

    Thanks,
    Jake

Production build 0.71.5 2024