Clean up phpcs issues, disallow failures

Created on 22 May 2024, 7 months ago
Updated 5 June 2024, 7 months ago

Problem/Motivation

Clean up the identified issues and update the .gitlab-ci.yml to prevent future failures.

Proposed resolution

Make it so.

📌 Task
Status

Fixed

Version

2.3

Component

Code

Created by

🇨🇦Canada mandclu

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

Merge Requests

Comments & Activities

  • Issue created by @mandclu
  • Merge request !29Clean up phpcs issues → (Merged) created by mandclu
  • Pipeline finished with Skipped
    7 months ago
    #179506
    • mandclu committed 68daddb0 on 2.3.x
      Issue #3449144 by mandclu: Clean up phpcs issues, disallow failures
      
  • Status changed to Fixed 7 months ago
  • 🇪🇨Ecuador jwilson3

    🎉 💪

  • Status changed to Needs work 7 months ago
  • 🇪🇨Ecuador jwilson3

    When I run ddev phpcs locally it generates a phpcs.xml.dist file whose contents are an HTML 404, which then triggers a failure.

    ❯ ddev phpcs
    ERROR: Ruleset /var/www/html/phpcs.xml.dist is not valid
    - On line 10, column 8: Opening and ending tag mismatch: meta line 4 and head
    - On line 73, column 8: Opening and ending tag mismatch: head line 3 and html
    - On line 74, column 1: Premature end of data in tag html line 2
    

    Should we add a phpcs.xml file?

  • 🇪🇨Ecuador jwilson3

    I copied over the phpcs.xml.dist from Drupal core, and see several failures on local.

    $ cp ./web/core/phpcs.xml.dist ./phpcs.xml
    $ ddev phpcs
    
    FILE: /var/www/html/web/modules/custom/svg/tests/src/Traits/SvgImageFieldCommonTrait.php
    ----------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------------------------------------
     1 | ERROR | [x] Missing declare(strict_types=1). (SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing)
    ----------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /var/www/html/web/modules/custom/svg/tests/src/Traits/SvgImageFieldCreationTrait.php
    ----------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------------------------------------
     1 | ERROR | [x] Missing declare(strict_types=1). (SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing)
    ----------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /var/www/html/web/modules/custom/svg/.ddev/xhprof/xhprof_prepend.php
    --------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 6 ERRORS AND 2 WARNINGS AFFECTING 8 LINES
    --------------------------------------------------------------------------------------------------------------------------------------------------------
      3 | ERROR   | [x] You must use "/**" style comments for a file comment (Drupal.Commenting.FileComment.WrongStyle)
     20 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false" (Generic.PHP.UpperCaseConstant.Found)
     27 | ERROR   | [x] You must use "/**" style comments for a function comment (Drupal.Commenting.FunctionComment.WrongStyle)
     28 | ERROR   | [x] Opening brace should be on the same line as the declaration (Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine)
     29 | WARNING | [ ] Unused variable $xhprof_link_dir. (DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariable)
     37 | WARNING | [ ] Unused variable $run_id. (DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariable)
     46 | ERROR   | [x] You must use "/**" style comments for a function comment (Drupal.Commenting.FunctionComment.WrongStyle)
     47 | ERROR   | [x] Opening brace should be on the same line as the declaration (Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine)
    --------------------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 592ms; Memory: 8MB
    
    
    PHP CODE SNIFFER REPORT SUMMARY
    ---------------------------------------------------------------------------------------------------------
    FILE                                                                                     ERRORS  WARNINGS
    ---------------------------------------------------------------------------------------------------------
    /var/www/html/web/modules/custom/svg/.ddev/xhprof/xhprof_prepend.php                     6       2
    /var/www/html/web/modules/custom/svg/tests/src/Traits/SvgImageFieldCommonTrait.php       1       0
    /var/www/html/web/modules/custom/svg/tests/src/Traits/SvgImageFieldCreationTrait.php     1       0
    ---------------------------------------------------------------------------------------------------------
    A TOTAL OF 8 ERRORS AND 2 WARNINGS WERE FOUND IN 3 FILES
    ---------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX 8 OF THESE SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------
    
    
    PHP CODE SNIFFER VIOLATION SOURCE SUMMARY
    ----------------------------------------------------------------------------------------
        SOURCE                                                                         COUNT
    ----------------------------------------------------------------------------------------
    [x] Drupal.Commenting.FunctionComment.WrongStyle                                   2
    [ ] DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariable                    2
    [x] Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine          2
    [x] SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing  2
    [x] Drupal.Commenting.FileComment.WrongStyle                                       1
    [x] Generic.PHP.UpperCaseConstant.Found                                            1
    ----------------------------------------------------------------------------------------
    A TOTAL OF 10 SNIFF VIOLATIONS WERE FOUND IN 6 SOURCES
    ----------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 5 MARKED SOURCES AUTOMATICALLY (8 VIOLATIONS IN TOTAL)
    ----------------------------------------------------------------------------------------
    
    Failed to run phpcs : exit status 2
    
  • 🇪🇨Ecuador jwilson3

    jwilson3 changed the visibility of the branch 3449144-clean-up-phpcs to hidden.

  • 🇪🇨Ecuador jwilson3

    jwilson3 changed the visibility of the branch 3449144-clean-up-phpcs to hidden.

  • Pipeline finished with Skipped
    7 months ago
    #179630
    • jwilson3 committed e1d47993 on 2.3.x
      Issue #3449144 by mandclu: Clean up phpcs issues, disallow failures
      
  • Status changed to Fixed 7 months ago
  • 🇪🇨Ecuador jwilson3

    jwilson3 changed the visibility of the branch 3449144-clean-up-phpcs to active.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024