Drupal Coding Standards Issues | phpcs

Created on 27 February 2023, over 1 year ago
Updated 30 July 2024, 4 months ago

Problem/Motivation

FILE: /Users/sahil.goyal/Documents/MySites/10.1.x/drupal/modules/contrib/google_text_to_speech/google_text_to_speech.module
---------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 3 LINES
---------------------------------------------------------------------------------------------------------------------------------------------------------
 10 | ERROR | [x] When importing a class with "use", do not include a leading \
 42 | ERROR | [x] Expected 1 space after IF keyword; 0 found
 56 | ERROR | [ ] All functions defined in a module file must be prefixed with the module's name, found "valid_google_text_to_speech_media" but expected
    |       |     "google_text_to_speech_valid_google_text_to_speech_media"
 56 | ERROR | [x] Missing function doc comment
---------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------------------


FILE: /Users/sahil.goyal/Documents/MySites/10.1.x/drupal/modules/contrib/google_text_to_speech/google_text_to_speech.links.task.yml
-----------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------
 4 | ERROR | [x] Expected 1 newline at end of file; 0 found
-----------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------------


FILE: /Users/sahil.goyal/Documents/MySites/10.1.x/drupal/modules/contrib/google_text_to_speech/config/optional/media.type.google_text_to_speech.yml
---------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------------------------------------
 12 | ERROR | [x] Expected 1 newline at end of file; 0 found
---------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------------


FILE: ...cuments/MySites/10.1.x/drupal/modules/contrib/google_text_to_speech/config/optional/field.field.media.google_text_to_speech.field_gtts_language.yml
---------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------------------------------------------
 20 | ERROR | [x] Expected 1 newline at end of file; 0 found
---------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------------------


FILE: /Users/sahil.goyal/Documents/MySites/10.1.x/drupal/modules/contrib/google_text_to_speech/google_text_to_speech.routing.yml
--------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------
 7 | ERROR | [x] Expected 1 newline at end of file; 0 found
--------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------


FILE: /Users/sahil.goyal/Documents/MySites/10.1.x/drupal/modules/contrib/google_text_to_speech/google_text_to_speech.services.yml
---------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------------------
 4 | ERROR | [x] Expected 1 newline at end of file; 2 found
---------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------


FILE: /Users/sahil.goyal/Documents/MySites/10.1.x/drupal/modules/contrib/google_text_to_speech/google_text_to_speech.permissions.yml
------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------
 4 | ERROR | [x] Expected 1 newline at end of file; 0 found
------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------


FILE: /Users/sahil.goyal/Documents/MySites/10.1.x/drupal/modules/contrib/google_text_to_speech/README.txt
---------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 15 WARNINGS AFFECTING 14 LINES
---------------------------------------------------------------------------------------------------------
  1 | WARNING | [ ] File has mixed line endings; this may cause incorrect results
  1 | WARNING | [ ] File encoding is invalid, expected UTF-8
  1 | ERROR   | [ ] File contains UTF-16 (LE) byte order mark, which may corrupt your application
  3 | WARNING | [ ] Line exceeds 80 characters; contains 644 characters
  5 | WARNING | [ ] Line exceeds 80 characters; contains 204 characters
  9 | WARNING | [ ] Line exceeds 80 characters; contains 166 characters
 11 | WARNING | [ ] Line exceeds 80 characters; contains 184 characters
 15 | WARNING | [ ] Line exceeds 80 characters; contains 286 characters
 17 | WARNING | [ ] Line exceeds 80 characters; contains 344 characters
 19 | WARNING | [ ] Line exceeds 80 characters; contains 366 characters
 23 | WARNING | [ ] Line exceeds 80 characters; contains 144 characters
 25 | WARNING | [ ] Line exceeds 80 characters; contains 154 characters
 26 | WARNING | [ ] Line exceeds 80 characters; contains 178 characters
 27 | WARNING | [ ] Line exceeds 80 characters; contains 192 characters
 34 | WARNING | [ ] Line exceeds 80 characters; contains 92 characters
 36 | WARNING | [ ] Line exceeds 80 characters; contains 628 characters
 36 | ERROR   | [x] Expected 1 newline at end of file; 0 found
---------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------


FILE: /Users/sahil.goyal/Documents/MySites/10.1.x/drupal/modules/contrib/google_text_to_speech/src/Form/TextToSpeechSettingsForm.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 71 ERRORS AND 12 WARNINGS AFFECTING 46 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
   1 | ERROR   | [x] The PHP open tag must be followed by exactly one blank line
   2 | ERROR   | [x] Namespaced classes, interfaces and traits should not begin with a file doc comment
   2 | ERROR   | [ ] Missing short description in doc comment
   3 | WARNING | [ ] @author tags are not usually used in Drupal, because over time multiple contributors will touch the code anyway
   4 | WARNING | [ ] @author tags are not usually used in Drupal, because over time multiple contributors will touch the code anyway
  37 | ERROR   | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
  44 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
  47 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 6
  47 | ERROR   | [x] Short array syntax must be used to define arrays
  48 | ERROR   | [x] Array indentation error, expected 8 spaces but found 12
  49 | ERROR   | [x] Array indentation error, expected 8 spaces but found 12
  50 | ERROR   | [x] Array indentation error, expected 8 spaces but found 12
  51 | ERROR   | [x] Array indentation error, expected 8 spaces but found 12
  53 | ERROR   | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
  55 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 6
  55 | ERROR   | [x] Short array syntax must be used to define arrays
  56 | ERROR   | [x] Array indentation error, expected 8 spaces but found 12
  57 | ERROR   | [x] Array indentation error, expected 8 spaces but found 12
  58 | ERROR   | [x] Array indentation error, expected 8 spaces but found 12
  58 | WARNING | [ ] Translatable strings must not begin or end with white spaces, use placeholders with t() for variables
  59 | ERROR   | [x] Array indentation error, expected 8 spaces but found 12
  61 | ERROR   | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
  63 | ERROR   | [ ] The array declaration extends to column 566 (the limit is 80). The array content should be split up over multiple lines
  63 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  63 | WARNING | [ ] #description values usually have to run through t() for translation
  63 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
  63 | ERROR   | [x] Comma not allowed after last value in single-line array declaration
  63 | ERROR   | [x] Expected one space after the comma, 0 found
  65 | ERROR   | [x] Expected 1 space after IF keyword; 0 found
  66 | ERROR   | [x] Whitespace found at end of line
  69 | ERROR   | [x] Short array syntax must be used to define arrays
  70 | ERROR   | [x] Expected 1 space after FUNCTION keyword; 0 found
  70 | ERROR   | [x] Expected one space after the comma, 0 found
  70 | ERROR   | [x] Expected 1 space after USE keyword; found 0
  70 | ERROR   | [x] Expected 1 space before opening brace; found 0
  70 | ERROR   | [x] Expected 1 space before opening brace; found 0
  71 | ERROR   | [x] list(...) is forbidden, use [...] instead.
  79 | ERROR   | [x] Array indentation error, expected 8 spaces but found 9
  79 | ERROR   | [x] Expected 1 space after "=>"; 3 found
  80 | ERROR   | [x] Array indentation error, expected 8 spaces but found 9
  80 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
  88 | ERROR   | [x] Expected 1 space after "=>"; 2 found
  88 | ERROR   | [x] The first index in a multi-value array must be on a new line
  88 | WARNING | [ ] #options values usually have to run through t() for translation
  88 | ERROR   | [x] Each index in a multi-line array must be on a new line
  88 | WARNING | [ ] #options values usually have to run through t() for translation
  89 | ERROR   | [x] Array indentation error, expected 10 spaces but found 6
  89 | ERROR   | [x] Closing parenthesis of array declaration must be on a new line
  90 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
  98 | ERROR   | [x] Expected 1 space after "=>"; 2 found
  98 | WARNING | [ ] #options values usually have to run through t() for translation
  98 | WARNING | [ ] #options values usually have to run through t() for translation
  99 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
 101 | ERROR   | [ ] The array declaration extends to column 420 (the limit is 80). The array content should be split up over multiple lines
 101 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 101 | WARNING | [ ] #description values usually have to run through t() for translation
 111 | ERROR   | [x] Whitespace found at end of line
 113 | ERROR   | [x] Short array syntax must be used to define arrays
 115 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 3
 115 | ERROR   | [x] Closing brace indented incorrectly; expected 4 spaces, found 3
 125 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 5
 125 | ERROR   | [x] Object operator not indented correctly; expected 6 spaces but found 5
 126 | ERROR   | [x] Object operator not indented correctly; expected 5 spaces but found 6
 132 | ERROR   | [x] Whitespace found at end of line
 133 | ERROR   | [x] Whitespace found at end of line
 137 | ERROR   | [x] Missing function doc comment
 138 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 5
 138 | ERROR   | [x] Expected 1 space after IF keyword; 0 found
 138 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
 138 | ERROR   | [x] Expected 1 space after closing parenthesis; found 0
 139 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 8
 139 | ERROR   | [x] Expected 1 space before "="; 0 found
 139 | ERROR   | [ ] The array declaration extends to column 294 (the limit is 80). The array content should be split up over multiple lines
 139 | ERROR   | [x] Expected one space after the comma, 0 found
 139 | ERROR   | [x] Expected 1 space between ""language_code"" and double arrow; 2 found
 139 | ERROR   | [x] Expected one space after the comma, 0 found
 139 | ERROR   | [x] Expected one space after the comma, 0 found
 140 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 8
 140 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 141 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 8
 142 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 6
 142 | ERROR   | [x] Closing brace indented incorrectly; expected 5 spaces, found 6
 143 | ERROR   | [x] Whitespace found at end of line
----------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 67 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------


FILE: /Users/sahil.goyal/Documents/MySites/10.1.x/drupal/modules/contrib/google_text_to_speech/src/Service/TextToSpeech.php
---------------------------------------------------------------------------------------------------------------------------------------------
FOUND 93 ERRORS AND 11 WARNINGS AFFECTING 64 LINES
---------------------------------------------------------------------------------------------------------------------------------------------
   1 | ERROR   | [x] The PHP open tag must be followed by exactly one blank line
   2 | ERROR   | [x] Namespaced classes, interfaces and traits should not begin with a file doc comment
   2 | ERROR   | [ ] Missing short description in doc comment
   3 | WARNING | [ ] @author tags are not usually used in Drupal, because over time multiple contributors will touch the code anyway
   4 | WARNING | [ ] @author tags are not usually used in Drupal, because over time multiple contributors will touch the code anyway
  11 | WARNING | [x] Unused use statement
  15 | WARNING | [x] Unused use statement
  16 | ERROR   | [x] When importing a class with "use", do not include a leading \
  17 | WARNING | [x] Unused use statement
  17 | ERROR   | [x] When importing a class with "use", do not include a leading \
  18 | WARNING | [x] Unused use statement
  18 | ERROR   | [x] When importing a class with "use", do not include a leading \
  19 | WARNING | [x] Unused use statement
  19 | ERROR   | [x] When importing a class with "use", do not include a leading \
  20 | ERROR   | [x] When importing a class with "use", do not include a leading \
  21 | ERROR   | [x] When importing a class with "use", do not include a leading \
  22 | WARNING | [x] Unused use statement
  22 | ERROR   | [x] There must be one blank line after the last USE statement; 0 found;
  22 | ERROR   | [x] When importing a class with "use", do not include a leading \
  26 | ERROR   | [x] Expected 1 space after class name; 2 found
  26 | ERROR   | [x] Expected 1 space before opening brace; found 2
  27 | ERROR   | [x] Spaces must be used to indent lines; tabs are not allowed
  27 | ERROR   | [x] Whitespace found at end of line
  28 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
  28 | ERROR   | [ ] Missing member variable doc comment
  29 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
  29 | ERROR   | [ ] Missing member variable doc comment
  31 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 0
  37 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 0
  38 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 2
  39 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 2
  41 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 0
  43 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 1
  43 | ERROR   | [x] Missing function doc comment
  45 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
  46 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
  47 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
  57 | ERROR   | [x] Expected 1 space after "="; 2 found
  59 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 1
  61 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 1
  61 | ERROR   | [x] Missing function doc comment
  62 | ERROR   | [x] Use null coalesce operator instead of ternary operator.
  68 | ERROR   | [x] Concat operator must be surrounded by a single space
  68 | ERROR   | [x] Concat operator must be surrounded by a single space
  75 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 1
  75 | ERROR   | [x] Expected 1 blank line after function; 2 found
  79 | ERROR   | [x] Doc comment short description must end with a full stop
  80 | ERROR   | [x] There must be exactly one blank line before the tags in a doc comment
  80 | ERROR   | [x] Tag value indented incorrectly; expected 1 space but found 2
  80 | ERROR   | [x] Parameter comment must be on the next line
  80 | ERROR   | [x] Parameter comment must end with a full stop
  81 | ERROR   | [x] Separate the @param and @return sections by a blank line.
  81 | ERROR   | [ ] Description for the @return value must be on the next line
  83 | ERROR   | [ ] Expected type hint "ParagraphInterface"; found "MediaInterface" for $entity
  89 | ERROR   | [x] Expected 1 space after FOREACH keyword; 0 found
  89 | WARNING | [ ] Unused variable $key.
  90 | ERROR   | [x] Expected 1 space after IF keyword; 0 found
  90 | ERROR   | [x] Expected 1 space after closing parenthesis; found 0
  95 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 5
  96 | ERROR   | [x] Expected 1 blank line after function; 2 found
  99 | ERROR   | [ ] Parameter $entity_type_id is not described in comment
 100 | ERROR   | [x] Doc comment short description must end with a full stop
 101 | ERROR   | [x] There must be exactly one blank line before the tags in a doc comment
 101 | ERROR   | [x] Tag value indented incorrectly; expected 1 space but found 2
 101 | ERROR   | [x] Parameter comment must be on the next line
 101 | ERROR   | [x] Parameter comment must end with a full stop
 102 | ERROR   | [x] Separate the @param and @return sections by a blank line.
 102 | ERROR   | [ ] Description for the @return value must be on the next line
 106 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 108 | ERROR   | [ ] String concat is not required here; use a single string instead
 117 | ERROR   | [x] Missing function doc comment
 118 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 3
 119 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 3
 120 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 3
 120 | ERROR   | [x] Whitespace found at end of line
 121 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 3
 124 | ERROR   | [x] Missing function doc comment
 129 | ERROR   | [x] Concat operator must be surrounded by a single space
 129 | ERROR   | [x] Concat operator must be surrounded by a single space
 131 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 132 | ERROR   | [x] Concat operator must be surrounded by a single space
 132 | ERROR   | [x] Concat operator must be surrounded by a single space
 132 | ERROR   | [x] Concat operator must be surrounded by a single space
 132 | ERROR   | [x] Concat operator must be surrounded by a single space
 132 | ERROR   | [x] Concat operator must be surrounded by a single space
 132 | ERROR   | [x] Concat operator must be surrounded by a single space
 132 | ERROR   | [x] Concat operator must be surrounded by a single space
 132 | ERROR   | [x] Concat operator must be surrounded by a single space
 132 | ERROR   | [x] Concat operator must be surrounded by a single space
 134 | ERROR   | [x] Array indentation error, expected 6 spaces but found 4
 135 | ERROR   | [x] Array indentation error, expected 6 spaces but found 4
 136 | ERROR   | [x] Array indentation error, expected 6 spaces but found 4
 136 | ERROR   | [x] Concat operator must be surrounded by a single space
 137 | ERROR   | [x] Array indentation error, expected 6 spaces but found 4
 143 | ERROR   | [x] Missing function doc comment
 150 | ERROR   | [x] Whitespace found at end of line
 151 | ERROR   | [x] Missing function doc comment
 157 | ERROR   | [ ] The array declaration extends to column 153 (the limit is 80). The array content should be split up over multiple lines
 157 | ERROR   | [x] Expected one space after the comma, 0 found
 157 | ERROR   | [x] Expected 1 space between ""language_code"" and double arrow; 2 found
 157 | ERROR   | [x] Expected one space after the comma, 0 found
 157 | ERROR   | [x] Expected one space after the comma, 0 found
 161 | ERROR   | [x] Expected 1 newline at end of file; 0 found
 161 | ERROR   | [x] The closing brace for the class must have an empty line before it
---------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 90 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------

Time: 121ms; Memory: 10MB

Steps to reproduce

Run the following command: phpcs --standard="Drupal,DrupalPractice" --extensions=php,module,inc,install,test,profile,theme,info,txt,md,yml /Users/sahil.goyal/Documents/MySites/10.1.x/drupal/modules/contrib/google_text_to_speech

Proposed resolution

Fix all the PHP coding standard issues and warnings.

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ“Œ Task
Status

Needs work

Version

2.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia sahil.goyal

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

Production build 0.71.5 2024