Drupal Coding Standards Issues | phpcs

Created on 27 December 2022, over 2 years ago
Updated 8 February 2024, about 1 year ago

Problem/Motivation

Getting following error/warnings

FILE: /app/modules/contrib/simple_block/src/Plugin/Block/SimpleBlockBlock.php
---------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
---------------------------------------------------------------------------------------------------------
106 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
125 | WARNING | FilterFormat::load calls should be avoided in classes, use dependency injection instead
---------------------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/simple_block/src/SimpleBlockEditForm.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------------------
35 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------

Time: 3.95 secs; Memory: 10MB

Steps to reproduce

Run following command

phpcs --standard="Drupal,DrupalPractice" --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml modules/contrib/simple_block/

Proposed resolution

Above error/warnings need to be fixed

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇮🇳India samit.310@gmail.com

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Issue was unassigned.
  • Status changed to RTBC about 2 years ago
  • 🇮🇳India Charchil Khandelwal

    Patch #2 applied cleanly, and all errors and warnings are fixed.
    So moving it to RTBC.
    Thanks

  • First commit to issue fork.
  • Merge request !183329755 - Fix CS → (Merged) created by AstonVictor
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    1 pass
  • Status changed to Fixed about 1 year ago
  • 🇺🇦Ukraine AstonVictor

    The MR doesn't fix all the issues.

      Line   src/SimpleBlockEditForm.php                                                                                
     ------ ----------------------------------------------------------------------------------------------------------- 
      69     Method Drupal\simple_block\SimpleBlockEditForm::save() should return int but return statement is missing.  
    
    
    FILE: /var/www/html/web/modules/contrib/simple_block/modules/simple_block_layout_builder/src/Event/Subscriber/SimpleBlockAddControllerSubscriber.php
    ----------------------------------------------------------------------------------------------------------------------------------------------------
     6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Component\Utility\NestedArray.
    
    FILE: /var/www/html/web/modules/contrib/simple_block/modules/simple_block_layout_builder/tests/scr/FunctionalJavascript/SimpleBlockLayoutBuilderTest.php
    --------------------------------------------------------------------------------------------------------------------------------------------------------
     7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\node\Entity\NodeType.
    
    FILE: /var/www/html/web/modules/contrib/simple_block/tests/src/Functional/SimpleBlockTest.php
    -----------------------------------------------------------------------------------------------------------------------------------------------
     8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Tests\block\Functional\AssertBlockAppearsTrait.
    

    Created a new MR with all the fixes. Merged in 8.x-1.x branch.

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

Production build 0.71.5 2024