Fix coding standards

Created on 9 May 2024, about 2 months ago
Updated 20 June 2024, 8 days ago

Problem/Motivation

Adding the GitLab CI template identified some coding standards issues:

FILE: ...rssb-3442148/web/modules/custom/rrssb-3442148/src/Form/RRSSBDeleteForm.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 7 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is Drupal\Core\Form\FormStateInterface.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: /builds/issue/rrssb-3442148/web/modules/custom/rrssb-3442148/rrssb.module
--------------------------------------------------------------------------------
FOUND 1 ERROR AND 3 WARNINGS AFFECTING 4 LINES
--------------------------------------------------------------------------------
  18 | ERROR   | [x] Use statements should be sorted alphabetically. The first
     |         |     wrong one is Drupal\Core\Render\BubbleableMetadata.
     |         |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
  43 | WARNING | [ ] Line exceeds 80 characters; contains 81 characters
     |         |     (Drupal.Files.LineLength.TooLong)
 189 | WARNING | [ ] Line exceeds 80 characters; contains 90 characters
     |         |     (Drupal.Files.LineLength.TooLong)
 368 | WARNING | [ ] Line exceeds 80 characters; contains 103 characters
     |         |     (Drupal.Files.LineLength.TooLong)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: /builds/issue/rrssb-3442148/web/modules/custom/rrssb-3442148/rrssb.install
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 10 | ERROR | [x] Use statements should be sorted alphabetically. The first
    |       |     wrong one is Drupal\Core\Config\Entity\ConfigEntityType.
    |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)

Let's fix these.

📌 Task
Status

Fixed

Version

2.0

Component

Code

Created by

🇯🇵Japan ptmkenny

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

Merge Requests

Comments & Activities

  • Issue created by @ptmkenny
  • Merge request !12Coding standards → (Merged) created by ptmkenny
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.5 + Environment: PHP 7.3 & MySQL 5.7
    last update about 2 months ago
    1 pass
  • Pipeline finished with Failed
    about 2 months ago
    Total: 152s
    #168831
  • Status changed to Needs review about 2 months ago
  • 🇵🇭Philippines paraderojether

    Hi

    I reviewed MR!12, applied against Ridiculously Responsive Social Sharing Buttons 8.x-2.x-dev and there are still phpcs issues shown below:

    jetherparadero@PrometSources-MacBook-Pro-3 contrib % phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig rrssb
    
    FILE: /Users/jetherparadero/d_o/drupal-issues/web/modules/contrib/rrssb/rrssb.module
    -------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -------------------------------------------------------------------------------------
     20 | WARNING | Global constants should not be used, move it to a class or interface
    -------------------------------------------------------------------------------------
    
    
    FILE: /Users/jetherparadero/d_o/drupal-issues/web/modules/contrib/rrssb/src/Form/RRSSBSettingsForm.php
    ------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
    ------------------------------------------------------------------------------------------------------------------------------------------
      79 | WARNING | Variable $require_follow inside unset call is undefined.
     186 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
     189 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
    ------------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/jetherparadero/d_o/drupal-issues/web/modules/contrib/rrssb/src/Plugin/Block/RRSSBBlock.php
    -------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------
     27 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    -------------------------------------------------------------------------------------------------------
    
    Time: 310ms; Memory: 12MB
    

    Kindly check and advise, please.
    Thank you.

  • 🇯🇵Japan ptmkenny

    @paraderojether Please note that this issue is to fix the coding standards issues identified by GitLab CI, which you can see are fixed in the pipeline here: https://git.drupalcode.org/issue/rrssb-3446292/-/jobs/1557122

    The GitLab CI tests will report DI issues like

     27 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    

    as phpstan issues, not coding standards issues. I guess this is to ensure that issues don't get fixed twice (no duplication of work).

    You can see that the DI issues are fixed in the phpstan issue: https://www.drupal.org/project/rrssb/issues/3446295 📌 Fix phpstan issues Needs review

  • Pipeline finished with Skipped
    22 days ago
    #192946
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.5 + Environment: PHP 7.3 & MySQL 5.7
    last update 22 days ago
    1 pass
  • First commit to issue fork.
  • Status changed to Fixed 22 days ago
  • 🇬🇧United Kingdom AdamPS

    Thanks

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

Production build 0.69.0 2024