@codingStandards syntax is deprecated and will be removed in PHP_CodeSniffer version 4.0

Created on 3 September 2024, 8 months ago
Updated 15 September 2024, 8 months ago

See https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignorin...

"The @codingStandards syntax is deprecated and will be removed in PHP_CodeSniffer version 4.0."

GitLab CI testing currently uses squizlabs/php-codesniffer 3.10.2 where the syntax is deprecated. We should move entirely to the new syntax before things break.

Rules currently uses this old syntax in about a dozen places.

This should be replaced with phpcs:ignore or phpcs:disable/enable, and in all cases possible should explicitly say which sniff is being ignored/disabled.

Follow the current usages of phpcs:ignore and phpcs:disable/enable in Rules as examples.

πŸ“Œ Task
Status

Fixed

Version

4.0

Component

Rules Core

Created by

πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

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

Merge Requests

Comments & Activities

  • Issue created by @tr
  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

    The issues that introduced the @codingStandardsIgnore directives are old and were tested under Drupal CI. All that test output is now gone so I can't tell what the exact motivation was to introduce those directives. Since I really really would like to disable only specific sniffs, the first step is to find out which sniffs are failing, and the easiest way to do this is to just first remove all the @codingStandardsIgnore statements, see what coding standards warnings are generated, then fix them from scratch.

    With our ever-changing coding standards, we may find out there are more issues or there are some that don't need to be ignored anymore. Let's find out.

  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

    The errors to be ignored are as follows. I have verified that we really do want to be ignoring all of these, and now we know exactly what we're ignoring.

    --------------------------------------------------------------------------------
    FILE: ...builds/project/rules/web/modules/custom/rules/src/Logger/RulesDebugLog.php
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
    --------------------------------------------------------------------------------
     129 | WARNING | Do not concatenate strings to translatable strings, they
         |         | should be part of the t() argument and you should use
         |         | placeholders (Drupal.Semantics.FunctionT.ConcatString)
     142 | WARNING | Only string literals should be passed to t() where possible
         |         | (Drupal.Semantics.FunctionT.NotLiteralString)
     183 | WARNING | Only string literals should be passed to t() where possible
         |         | (Drupal.Semantics.FunctionT.NotLiteralString)
     208 | WARNING | Only string literals should be passed to t() where possible
         |         | (Drupal.Semantics.FunctionT.NotLiteralString)
    --------------------------------------------------------------------------------
    FILE: ...t/rules/web/modules/custom/rules/src/Drush/Commands/RulesDrushCommands.php
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     309 | WARNING | Line exceeds 80 characters; contains 82 characters
         |         | (Drupal.Files.LineLength.TooLong)
    --------------------------------------------------------------------------------
    FILE: ...ules/web/modules/custom/rules/src/Context/ContextHandlerIntegrityTrait.php
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     9 | WARNING | [x] Unused use statement
       |         |     (Drupal.Classes.UnusedUseStatement.UnusedUse)
  • Pipeline finished with Skipped
    8 months ago
    #283510
    • tr β†’ committed 4e37b643 on 4.0.x
      Issue #3471699 by tr: @codingStandards syntax is deprecated and will be...
  • Status changed to Fixed 8 months ago
  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024