Update code to pass phpcs and phpstan

Created on 3 May 2024, 7 months ago
Updated 17 May 2024, 6 months ago

Problem/Motivation

phpcs reports these issues:

FILE: .../matomo_reports/web/modules/custom/matomo_reports/src/Form/ReportsForm.php
--------------------------------------------------------------------------------
FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES
--------------------------------------------------------------------------------
14 | WARNING | [ ] The class short comment should describe what the class
| | does and not simply repeat the class name
| | (Drupal.Commenting.ClassComment.Short)
83 | ERROR | [x] 2 spaces found before inline comment; expected "//
| | 'container-inline'," but found "// 'container-inline',"
| | (Drupal.Commenting.InlineComment.SpacingBefore)
219 | ERROR | [x] Expected newline after closing brace
| | (Drupal.ControlStructures.ControlSignature.NewlineAfterCloseBrace)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...ports/web/modules/custom/matomo_reports/src/Form/MatomoReportsSettings.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
16 | WARNING | The class short comment should describe what the class does and
| | not simply repeat the class name
| | (Drupal.Commenting.ClassComment.Short)
--------------------------------------------------------------------------------
FILE: ...b/modules/custom/matomo_reports/src/Controller/MatomoReportsController.php
--------------------------------------------------------------------------------
FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES
--------------------------------------------------------------------------------
15 | WARNING | [ ] The class short comment should describe what the class does
| | and not simply repeat the class name
| | (Drupal.Commenting.ClassComment.Short)
88 | ERROR | [x] Expected newline after closing brace
| | (Drupal.ControlStructures.ControlSignature.NewlineAfterCloseBrace)
91 | ERROR | [x] Functions must not contain multiple empty lines in a row;
| | found 2 empty lines
| | (Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
Time: 209ms; Memory: 6MB
PHP CODE SNIFFER REPORT SUMMARY
--------------------------------------------------------------------------------
FILE ERRORS WARNINGS
--------------------------------------------------------------------------------
...m/matomo_reports/src/Controller/MatomoReportsController.php 2 1
...es/custom/matomo_reports/src/Form/MatomoReportsSettings.php 0 1
.../web/modules/custom/matomo_reports/src/Form/ReportsForm.php 2 1
--------------------------------------------------------------------------------
A TOTAL OF 4 ERRORS AND 3 WARNINGS WERE FOUND IN 6 FILES
--------------------------------------------------------------------------------
PHPCBF CAN FIX 4 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
PHP CODE SNIFFER VIOLATION SOURCE SUMMARY
---------------------------------------------------------------------------
SOURCE COUNT
---------------------------------------------------------------------------
[ ] Drupal.Commenting.ClassComment.Short 3
[x] Drupal.ControlStructures.ControlSignature.NewlineAfterCloseBrace 2
[x] Drupal.Commenting.InlineComment.SpacingBefore 1
[x] Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines 1
---------------------------------------------------------------------------
A TOTAL OF 7 SNIFF VIOLATIONS WERE FOUND IN 4 SOURCES
---------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SOURCES AUTOMATICALLY (4 VIOLATIONS IN TOTAL)
---------------------------------------------------------------------------

phpstan reports these issues:
------ -----------------------------------------------------------------
Line src/Controller/MatomoReportsController.php
------ -----------------------------------------------------------------
105 Variable $token_auth in empty() always exists and is not falsy.
------ -----------------------------------------------------------------
------ ---------------------------------------------------------------------
Line src/Form/ReportsForm.php
------ ---------------------------------------------------------------------
128 Inner named functions are not supported by PHPStan. Consider
refactoring to an anonymous function, class method, or a
top-level-defined function. See issue #165
(https://github.com/phpstan/phpstan/issues/165) for more details.
189 Call to static method filter() on an unknown class
Drupal\matomo_reports\Form\Xss.
πŸ’‘ Learn more at https://phpstan.org/user-guide/discovering-symbols
190 Call to static method filter() on an unknown class
Drupal\matomo_reports\Form\Xss.
πŸ’‘ Learn more at https://phpstan.org/user-guide/discovering-symbols
212 Call to static method filter() on an unknown class
Drupal\matomo_reports\Form\Xss.
πŸ’‘ Learn more at https://phpstan.org/user-guide/discovering-symbols
213 Call to static method filter() on an unknown class
Drupal\matomo_reports\Form\Xss.
πŸ’‘ Learn more at https://phpstan.org/user-guide/discovering-symbols
------ ---------------------------------------------------------------------
[ERROR] Found 6 errors

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ“Œ Task
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States shelane

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024