Problem/Motivation
When running the module code against Drupal coding standards based on Drupal standard, the module shows errors
Report:
FILE: /home/contribution/drupal/web/modules/contrib/weather_wave/src/Plugin/Block/WeatherWaveBlock.php
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 29 ERRORS AND 12 WARNINGS AFFECTING 29 LINES
--------------------------------------------------------------------------------------------------------------------------------------
1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
1 | ERROR | [x] Whitespace found at end of line
2 | ERROR | [x] Namespaced classes, interfaces and traits should not begin with a file doc comment
7 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 1
9 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 1
10 | WARNING | [x] Unused use statement
10 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 1
11 | WARNING | [x] Unused use statement
11 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 1
12 | WARNING | [x] Unused use statement
12 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 1
13 | WARNING | [x] Unused use statement
13 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 1
13 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Config\ConfigFactoryInterface.
14 | WARNING | [x] Unused use statement
14 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 1
15 | WARNING | [x] Unused use statement
15 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 1
16 | ERROR | [x] Whitespace found at end of line
19 | ERROR | [x] Whitespace found at end of line
26 | ERROR | [x] Expected 1 space before opening brace; found 0
46 | ERROR | [x] There must be no blank lines after the function comment
49 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 2
50 | ERROR | [x] Whitespace found at end of line
52 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
53 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
53 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
54 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
57 | ERROR | [x] Concat operator must be surrounded by a single space
57 | ERROR | [x] Concat operator must be surrounded by a single space
58 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
59 | ERROR | [x] Expected one space after the comma, 0 found
59 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "True"
62 | ERROR | [x] Expected 1 space after "="; 2 found
63 | ERROR | [x] Short array syntax must be used to define arrays
64 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
65 | ERROR | [x] Expected 1 space after "="; 2 found
66 | ERROR | [x] Whitespace found at end of line
67 | ERROR | [x] Whitespace found at end of line
68 | ERROR | [x] Expected 1 newline at end of file; 0 found
68 | ERROR | [x] The closing brace for the class must have an empty line before it
--------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 35 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------------------------------------------
FILE: /home/contribution/drupal/web/modules/contrib/weather_wave/src/Controller/WeatherForecastController.php
----------------------------------------------------------------------------------------------------------------------------------
FOUND 13 ERRORS AND 5 WARNINGS AFFECTING 13 LINES
----------------------------------------------------------------------------------------------------------------------------------
6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Controller\ControllerBase.
7 | WARNING | [x] Unused use statement
9 | WARNING | [x] Unused use statement
10 | WARNING | [x] Unused use statement
11 | WARNING | [x] Unused use statement
13 | ERROR | [x] Missing class doc comment
13 | ERROR | [x] Expected 1 space before opening brace; found 2
17 | ERROR | [x] Expected 1 blank line before function; 0 found
19 | ERROR | [x] Expected 1 space before "?"; 0 found
21 | ERROR | [x] Expected 1 space after "="; 0 found
21 | ERROR | [x] Concat operator must be surrounded by a single space
21 | ERROR | [x] Concat operator must be surrounded by a single space
22 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
24 | ERROR | [x] Expected one space after the comma, 0 found
24 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "True"
31 | ERROR | [x] Whitespace found at end of line
35 | ERROR | [x] Expected 1 newline at end of file; 0 found
35 | ERROR | [x] The closing brace for the class must have an empty line before it
----------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 17 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------
FILE: /home/contribution/drupal/web/modules/contrib/weather_wave/src/Form/WeatherWaveForm.php
---------------------------------------------------------------------------------------------------------------------------------------------
FOUND 37 ERRORS AND 11 WARNINGS AFFECTING 36 LINES
---------------------------------------------------------------------------------------------------------------------------------------------
7 | WARNING | [x] Unused use statement
8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\Element\EntityAutocomplete.
9 | WARNING | [x] Unused use statement
12 | ERROR | [x] Function comment short description must start with exactly one space
12 | ERROR | [x] Doc comment short description must end with a full stop
13 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
13 | ERROR | [x] There must be exactly one newline after the Class comment
15 | ERROR | [x] PHP keywords must be lowercase; expected "class" but found "Class"
19 | ERROR | [x] Expected 1 blank line before function; 0 found
20 | ERROR | [x] Opening brace should be on the same line as the declaration
21 | ERROR | [x] Language constructs must be followed by a single space; expected "return [" but found "return["
24 | ERROR | [x] Expected 1 blank line after function; 0 found
28 | ERROR | [x] Expected 1 space before opening brace; found 0
31 | ERROR | [x] Whitespace found at end of line
32 | ERROR | [x] Expected 1 blank line after function; 0 found
34 | ERROR | [x] Whitespace found at end of line
35 | ERROR | [x] Whitespace found at end of line
36 | ERROR | [x] Expected 1 space before opening brace; found 0
37 | ERROR | [x] Whitespace found at end of line
39 | ERROR | [x] Expected 1 space before "?"; 0 found
40 | ERROR | [x] Expected 1 space before "?"; 0 found
59 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "False"
59 | ERROR | [x] Comments may not appear after statements
65 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
66 | WARNING | [ ] Line exceeds 80 characters; contains 91 characters
66 | ERROR | [x] Comments may not appear after statements
71 | ERROR | [x] Whitespace found at end of line
73 | ERROR | [x] Expected 1 blank line after function; 0 found
77 | ERROR | [x] Expected 1 space before opening brace; found 0
78 | WARNING | [ ] Unused variable $form_value.
79 | ERROR | [x] Expected 1 space before ":"; 0 found
80 | WARNING | [ ] Unused variable $article_id.
84 | ERROR | [x] Object operator not indented correctly; expected 6 spaces but found 9
84 | ERROR | [x] Expected one space after the comma, 0 found
85 | ERROR | [x] Expected one space after the comma, 0 found
87 | ERROR | [x] Expected 1 blank line after function; 0 found
91 | ERROR | [x] Visibility must be declared on method "weather_wave_reset_form_submit"
91 | ERROR | [ ] Method name "WeatherWaveForm::weather_wave_reset_form_submit" is not in lowerCamel format
91 | ERROR | [x] Namespaced classes/interfaces/traits should be referenced with use statements
92 | WARNING | [x] There must be no blank line following an inline comment
92 | WARNING | [ ] There must be no blank line following an inline comment
94 | WARNING | [ ] Unused variable $cityFieldValue.
94 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
97 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 4
97 | ERROR | [x] Object operator not indented correctly; expected 6 spaces but found 4
97 | ERROR | [x] Expected one space after the comma, 0 found
99 | ERROR | [x] Expected 1 newline at end of file; 0 found
99 | ERROR | [x] The closing brace for the Class must have an empty line before it
---------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 39 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------
FILE: /home/contribution/drupal/web/modules/contrib/weather_wave/weather_wave.module
------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 8 ERRORS AND 1 WARNING AFFECTING 8 LINES
------------------------------------------------------------------------------------------------------------------------------------------------------------
10 | ERROR | [x] There must be no blank lines after the function comment
12 | ERROR | [x] Expected 1 space before opening brace; found 0
13 | ERROR | [x] Language constructs must be followed by a single space; expected "return [" but found "return["
20 | ERROR | [x] Array closing indentation error, expected 6 spaces but found 4
24 | ERROR | [x] Expected 1 blank line after function; 0 found
24 | ERROR | [x] Whitespace found at end of line
26 | WARNING | [ ] Format should be "* Implements hook_foo().", "* Implements hook_foo_BAR_ID_bar() for xyz_bar().",, "* Implements hook_foo_BAR_ID_bar()
| | for xyz-bar.html.twig.", "* Implements hook_foo_BAR_ID_bar() for xyz-bar.tpl.php.", or "* Implements hook_foo_BAR_ID_bar() for block
| | templates."
28 | ERROR | [x] Namespaced classes/interfaces/traits should be referenced with use statements
35 | ERROR | [x] Expected 1 newline at end of file; 0 found
------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------------------------------
FILE: /home/contribution/drupal/web/modules/contrib/weather_wave/weather_wave.routing.yml
----------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
----------------------------------------------------------------------------------------------------------------------
8 | WARNING | [ ] Open page callback found, please add a comment before the line why there is no access restriction
16 | ERROR | [x] Expected 1 newline at end of file; 0 found
----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------
FILE: /home/contribution/drupal/web/modules/contrib/weather_wave/weather_wave.libraries.yml
-----------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------
10 | ERROR | [x] Expected 1 newline at end of file; 2 found
-----------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------
FILE: /home/contribution/drupal/web/modules/contrib/weather_wave/weather_wave.links.menu.yml
------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------
6 | ERROR | [x] Expected 1 newline at end of file; 0 found
------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------
FILE: /home/contribution/drupal/web/modules/contrib/weather_wave/weather_wave.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
-------------------------------------------------------------------------------------------
Steps to reproduce
Run following command:
phpcs --standard=Drupal, DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,yml weather_wave/
Proposed resolution
Above error/warnings need to be fixed.