Fix issues reported by PHPCS

Created on 24 June 2024, 6 months ago
Updated 25 June 2024, 6 months ago

Problem/Motivation

With the integration of GitLab CI from 📌 Integration with Gitlab CI Needs review there is now a report for PHPCS issues at https://git.drupalcode.org/issue/search_api_extras-3456678/-/jobs/1938823

PHP_CodeSniffer version 3.10.1 (stable) by Squiz and PHPCSStandards

dealerdirect/phpcodesniffer-composer-installer 1.0.0
drupal/coder 8.3.24
sirbrillig/phpcs-variable-analysis 2.11.18
slevomat/coding-standard 8.15.0
squizlabs/php_codesniffer 3.10.1

Using config file: /builds/issue/search_api_extras-3456678/vendor/squizlabs/php_codesniffer/CodeSniffer.conf
installed_paths: ../../drupal/coder/coder_sniffer,../../sirbrillig/phpcs-variable-analysis,../../slevomat/coding-standard

The installed coding standards are MySource, PEAR, PSR1, PSR2, PSR12, Squiz, Zend, Drupal, DrupalPractice, VariableAnalysis and SlevomatCodingStandard

FILE: ...om/search_api_extras-3456678/src/Plugin/views/sort/SearchApiExtrasSort.php
--------------------------------------------------------------------------------
FOUND 6 ERRORS AND 2 WARNINGS AFFECTING 8 LINES
--------------------------------------------------------------------------------
  6 | WARNING | [x] Unused use statement
    |         |     (Drupal.Classes.UnusedUseStatement.UnusedUse)
 46 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but
    |         |     found "true" (Generic.PHP.UpperCaseConstant.Found)
 50 | ERROR   | [x] Inline control structures are not allowed
    |         |     (Drupal.ControlStructures.InlineControlStructure.NotAllowed)
 53 | ERROR   | [x] Missing function doc comment
    |         |     (Drupal.Commenting.FunctionComment.Missing)
 57 | ERROR   | [x] Expected 1 blank line after function; 2 found
    |         |     (Squiz.WhiteSpace.FunctionSpacing.After)
 83 | WARNING | [x] A comma should follow the last multiline array item. Found:
    |         |     ] (Drupal.Arrays.Array.CommaLastItem)
 87 | ERROR   | [x] Expected 1 blank line after function; 0 found
    |         |     (Squiz.WhiteSpace.FunctionSpacing.AfterLast)
 88 | ERROR   | [x] The closing brace for the class must have an empty line
    |         |     before it
    |         |     (Drupal.Classes.ClassDeclaration.CloseBraceAfterBody)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...ch_api_extras-3456678/src/Plugin/search_api/parse_mode/TermsWithPhrase.php
--------------------------------------------------------------------------------
FOUND 3 ERRORS AND 1 WARNING AFFECTING 4 LINES
--------------------------------------------------------------------------------
  5 | WARNING | [x] Unused use statement
    |         |     (Drupal.Classes.UnusedUseStatement.UnusedUse)
 21 | ERROR   | [x] Expected 1 blank line before function; 0 found
    |         |     (Squiz.WhiteSpace.FunctionSpacing.BeforeFirst)
 27 | ERROR   | [x] Expected 1 blank line after function; 0 found
    |         |     (Squiz.WhiteSpace.FunctionSpacing.AfterLast)
 28 | ERROR   | [x] The closing brace for the class must have an empty line
    |         |     before it
    |         |     (Drupal.Classes.ClassDeclaration.CloseBraceAfterBody)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...678/web/modules/custom/search_api_extras-3456678/src/Form/SettingsForm.php
--------------------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------------
  1 | ERROR | [x] The PHP open tag must be followed by exactly one blank line
    |       |     (Drupal.WhiteSpace.OpenTagNewline.BlankLine)
  1 | ERROR | [x] Expected 1 line before declare statement, found 0.
    |       |     (SlevomatCodingStandard.TypeHints.DeclareStrictTypes.IncorrectWhitespaceBeforeDeclare)
  1 | ERROR | [x] Expected strict_types=1, found strict_types = 1.
    |       |     (SlevomatCodingStandard.TypeHints.DeclareStrictTypes.IncorrectStrictTypesFormat)
 38 | ERROR | [x] Expected 1 blank line after function; 2 found
    |       |     (Squiz.WhiteSpace.FunctionSpacing.After)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...6678/web/modules/custom/search_api_extras-3456678/search_api_extras.module
--------------------------------------------------------------------------------
FOUND 7 ERRORS AND 3 WARNINGS AFFECTING 7 LINES
--------------------------------------------------------------------------------
  1 | ERROR   | [x] The PHP open tag must be followed by exactly one blank line
    |         |     (Drupal.WhiteSpace.OpenTagNewline.BlankLine)
  1 | ERROR   | [x] Missing file doc comment
    |         |     (Drupal.Commenting.FileComment.Missing)
  2 | ERROR   | [x] Missing function doc comment
    |         |     (Drupal.Commenting.FunctionComment.Missing)
  2 | ERROR   | [x] Expected 1 blank line before function; 0 found
    |         |     (Squiz.WhiteSpace.FunctionSpacing.Before)
  3 | ERROR   | [x] Inline comments must start with a capital letter
    |         |     (Drupal.Commenting.InlineComment.NotCapital)
  3 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks,
    |         |     question marks, colons, or closing parentheses
    |         |     (Drupal.Commenting.InlineComment.InvalidEndChar)
 20 | ERROR   | [x] Missing function doc comment
    |         |     (Drupal.Commenting.FunctionComment.Missing)
 21 | WARNING | [ ] Line exceeds 80 characters; contains 115 characters
    |         |     (Drupal.Files.LineLength.TooLong)
 23 | WARNING | [ ] Line exceeds 80 characters; contains 118 characters
    |         |     (Drupal.Files.LineLength.TooLong)
 28 | WARNING | [ ] Line exceeds 80 characters; contains 97 characters
    |         |     (Drupal.Files.LineLength.TooLong)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
Time: 130ms; Memory: 6MB
PHP CODE SNIFFER REPORT SUMMARY
--------------------------------------------------------------------------------
FILE                                                            ERRORS  WARNINGS
--------------------------------------------------------------------------------
...s/custom/search_api_extras-3456678/search_api_extras.module  7       3
.../custom/search_api_extras-3456678/src/Form/SettingsForm.php  4       0
...456678/src/Plugin/search_api/parse_mode/TermsWithPhrase.php  3       1
...xtras-3456678/src/Plugin/views/sort/SearchApiExtrasSort.php  6       2
--------------------------------------------------------------------------------
A TOTAL OF 20 ERRORS AND 6 WARNINGS WERE FOUND IN 4 FILES
--------------------------------------------------------------------------------
PHPCBF CAN FIX 23 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
PHP CODE SNIFFER VIOLATION SOURCE SUMMARY
--------------------------------------------------------------------------------
    SOURCE                                                                 COUNT
--------------------------------------------------------------------------------
[x] Drupal.Commenting.FunctionComment.Missing                              3
[ ] Drupal.Files.LineLength.TooLong                                        3
[x] Drupal.Classes.ClassDeclaration.CloseBraceAfterBody                    2
[x] Drupal.Classes.UnusedUseStatement.UnusedUse                            2
[x] Drupal.WhiteSpace.OpenTagNewline.BlankLine                             2
[x] Squiz.WhiteSpace.FunctionSpacing.After                                 2
[x] Squiz.WhiteSpace.FunctionSpacing.AfterLast                             2
[x] Drupal.Arrays.Array.CommaLastItem                                      1
[x] Drupal.Commenting.FileComment.Missing                                  1
[x] Drupal.Commenting.InlineComment.InvalidEndChar                         1
[x] Drupal.Commenting.InlineComment.NotCapital                             1
[x] Drupal.ControlStructures.InlineControlStructure.NotAllowed             1
[x] Generic.PHP.UpperCaseConstant.Found                                    1
[x] SlevomatCodingStandard.TypeHints.DeclareStrictTypes.IncorrectStrictTy  1
[x] SlevomatCodingStandard.TypeHints.DeclareStrictTypes.IncorrectWhitespa  1
[x] Squiz.WhiteSpace.FunctionSpacing.Before                                1
[x] Squiz.WhiteSpace.FunctionSpacing.BeforeFirst                           1
--------------------------------------------------------------------------------
A TOTAL OF 26 SNIFF VIOLATIONS WERE FOUND IN 17 SOURCES
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 16 MARKED SOURCES AUTOMATICALLY (23 VIOLATIONS IN TOTAL)
--------------------------------------------------------------------------------

Steps to reproduce

See https://git.drupalcode.org/issue/search_api_extras-3456678/-/jobs/1938823

Proposed resolution

Fix reported issues

Remaining tasks

Create MR
Review MR

User interface changes

-

API changes

-

Data model changes

-

📌 Task
Status

RTBC

Version

1.0

Component

Code

Created by

🇧🇪Belgium tim-diels Belgium 🇧🇪

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