GitLab CI - PHPCS - Long lines and whitespace errors

Created on 6 April 2024, over 1 year ago
Updated 20 April 2024, over 1 year ago

Problem/Motivation

Latest PHPCS error list is much improved. The summary is:

PHP CODE SNIFFER VIOLATION SOURCE SUMMARY
--------------------------------------------------------------------------------
    SOURCE                                                                 COUNT
--------------------------------------------------------------------------------
[ ] Drupal.Files.LineLength.TooLong                                        7
[x] Drupal.Commenting.TodoComment.TodoFormat                               6
[x] Drupal.Classes.UnusedUseStatement.UnusedUse                            5
[x] SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.Incorrectl  5
[x] Drupal.Arrays.Array.ArrayIndentation                                   3
[x] Drupal.Commenting.DataTypeNamespace.DataTypeNamespace                  3
[x] Drupal.Commenting.FunctionComment.Missing                              3
[ ] Drupal.NamingConventions.ValidVariableName.LowerCamelName              3
[x] SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator.  3
[x] SlevomatCodingStandard.PHP.ShortList.LongListUsed                      2
[x] Squiz.WhiteSpace.SuperfluousWhitespace.EndLine                         2
[x] Drupal.Arrays.Array.ArrayClosingIndentation                            1
[x] Drupal.Commenting.ClassComment.Missing                                 1
[x] Drupal.Commenting.DocComment.SpacingBeforeTags                         1
[ ] Drupal.Commenting.FunctionComment.MissingParamType                     1
[x] Drupal.Commenting.InlineComment.NotCapital                             1
[x] Drupal.Commenting.PostStatementComment.Found                           1
[ ] Drupal.Commenting.VariableComment.Missing                              1
[ ] Drupal.Semantics.FunctionT.NotLiteralString                            1
[x] Drupal.WhiteSpace.OpenTagNewline.BlankLine                             1
[ ] Generic.CodeAnalysis.UselessOverridingMethod.Found                     1
[x] SlevomatCodingStandard.TypeHints.DeclareStrictTypes.IncorrectStrictTy  1
--------------------------------------------------------------------------------
A TOTAL OF 53 SNIFF VIOLATIONS WERE FOUND IN 22 SOURCES
--------------------------------------------------------------------------------

The most common error relates to long lines, but there are also some whitespace errors, so I think they can be dealt with together.

Steps to reproduce

Review a Gitlab pipeline and check the PHPCS result, such as this one: https://git.drupalcode.org/project/smart_date/-/jobs/1251055

Proposed resolution

Focus on the following error tyoes:

  • Drupal.Files.LineLength.TooLong
  • Drupal.Arrays.Array.ArrayIndentation
  • Squiz.WhiteSpace.SuperfluousWhitespace.EndLine
  • Drupal.Commenting.DocComment.SpacingBeforeTags
  • Drupal.WhiteSpace.OpenTagNewline.BlankLine

Remaining tasks

Fix the above errors.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

📌 Task
Status

Fixed

Version

4.1

Component

Code

Created by

🇮🇪Ireland lostcarpark

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