Problem/Motivation

FILE: ...les/contrib/gravitas_countdown/src/Plugin/Block/GravitasCountdownBlock.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 31 WARNINGS AFFECTING 31 LINES
--------------------------------------------------------------------------------
149 | WARNING | File::load calls should be avoided in classes, use dependency
| | injection instead
156 | WARNING | File::load calls should be avoided in classes, use dependency
| | injection instead
175 | WARNING | File::load calls should be avoided in classes, use dependency
| | injection instead
190 | WARNING | File::load calls should be avoided in classes, use dependency
| | injection instead
219 | WARNING | \Drupal calls should be avoided in classes, use dependency
| | injection instead
224 | WARNING | File::load calls should be avoided in classes, use dependency
| | injection instead
--------------------------------------------------------------------------------

Steps to reproduce

Execute the command: phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,js,info,txt,md,yml,twig gravitas_countdown/

Proposed resolution

Add dependency injections.

CommentFileSizeAuthor
#8 3362396-7.patch3.47 KBshanu chouhan
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

urvashi_vora created an issue. See original summary.

prabuela’s picture

Assigned: Unassigned » prabuela
urvashi_vora’s picture

prabuela’s picture

Assigned: prabuela » Unassigned
urvashi_vora’s picture

I will work on this soon.

avpaderno’s picture

Priority: Normal » Minor
Parent issue: #3362401: Fix the issues reported by phpcs »
shanu chouhan’s picture

Assigned: Unassigned » shanu chouhan
shanu chouhan’s picture

Assigned: shanu chouhan » Unassigned
Status: Active » Needs review
StatusFileSize
new3.47 KB

Here's a patch for it.

urvashi_vora’s picture

Assigned: Unassigned » urvashi_vora

I will review it.

urvashi_vora’s picture

Assigned: urvashi_vora » Unassigned
Status: Needs review » Reviewed & tested by the community

Reviewed the patch provided by @Shanu Chouhan. It applies cleanly and modifies the code appropriately.

I can confirm that no issues left for:
1. File::load calls should be avoided in classes, use dependency injection instead
2. \Drupal calls should be avoided in classes, use dependency injection instead

Thanks for the work. Moving it to RTBC.

sujan shrestha’s picture

Version: 1.1.0 » 1.1.1
Status: Reviewed & tested by the community » Needs review

Thank you for the patch. I have implemented the patch file to use dependency injection instead of classes and also fixed the following error on the new version
Argument #1 ($file_storage) must be of type Drupal\Core\Entity\EntityStorageInterface, array given

sujan shrestha’s picture

Assigned: Unassigned » sujan shrestha
Status: Needs review » Fixed
sujan shrestha’s picture

Status: Fixed » Closed (fixed)