Problem/Motivation
Getting following error/warnings
FILE: /var/www/html/modules/contrib/storage/storage.routing.yml
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
18 | ERROR | [x] Expected 1 newline at end of file; 2 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
FILE: /var/www/html/modules/contrib/storage/config/schema/storage.schema.yml
----------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------
10 | ERROR | [x] Expected 1 newline at end of file; 2 found
----------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------
FILE: /var/www/html/modules/contrib/storage/storage.tokens.inc
-----------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------
127 | WARNING | Only string literals should be passed to t() where possible
-----------------------------------------------------------------------------
FILE: /var/www/html/modules/contrib/storage/src/Form/StorageSettingsForm.php
-----------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------
12 | WARNING | The class short comment should describe what the class does and not simply repeat the class name
-----------------------------------------------------------------------------------------------------------------
FILE: /var/www/html/modules/contrib/storage/src/Form/StorageRevisionDeleteForm.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 1 WARNING AFFECTING 2 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
94 | ERROR | The array declaration extends to column 169 (the limit is 80). The array content should be split up over multiple lines
95 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
95 | ERROR | The array declaration extends to column 249 (the limit is 80). The array content should be split up over multiple lines
-----------------------------------------------------------------------------------------------------------------------------------------
FILE: /var/www/html/modules/contrib/storage/src/Form/StorageRevisionRevertForm.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 1 WARNING AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------------------------------
118 | ERROR | The array declaration extends to column 170 (the limit is 80). The array content should be split up over multiple lines
119 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
119 | ERROR | The array declaration extends to column 226 (the limit is 80). The array content should be split up over multiple lines
------------------------------------------------------------------------------------------------------------------------------------------
FILE: /var/www/html/modules/contrib/storage/src/Form/StorageTypeForm.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 11 WARNINGS AFFECTING 11 LINES
------------------------------------------------------------------------------------------------------------------------------------------
118 | WARNING | Line exceeds 80 characters; contains 88 characters
133 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
135 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
140 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
142 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
147 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
149 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
154 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
156 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
167 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
169 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
------------------------------------------------------------------------------------------------------------------------------------------
FILE: /var/www/html/modules/contrib/storage/src/Form/StorageForm.php
---------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------
60 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
---------------------------------------------------------------------------------------------
FILE: /var/www/html/modules/contrib/storage/src/Access/StorageRevisionAccessCheck.php
----------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------
125 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------
FILE: /var/www/html/modules/contrib/storage/src/StorageViewsData.php
-----------------------------------------------------------------------------
FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 3 LINES
-----------------------------------------------------------------------------
69 | WARNING | [x] There must be no blank line following an inline comment
69 | WARNING | [ ] There must be no blank line following an inline comment
292 | WARNING | [ ] Line exceeds 80 characters; contains 82 characters
327 | WARNING | [ ] Line exceeds 80 characters; contains 85 characters
-----------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------
FILE: /var/www/html/modules/contrib/storage/src/Entity/StorageType.php
------------------------------------------------------------------------
FOUND 6 ERRORS AND 3 WARNINGS AFFECTING 8 LINES
------------------------------------------------------------------------
166 | WARNING | [ ] Possible useless method overriding detected
169 | ERROR | [x] Inline comments must start with a capital letter
170 | WARNING | [ ] Line exceeds 80 characters; contains 85 characters
170 | ERROR | [ ] Comment indentation error, expected only 1 spaces
172 | ERROR | [ ] Comment indentation error, expected only 3 spaces
173 | ERROR | [ ] Comment indentation error, expected only 5 spaces
175 | WARNING | [ ] Line exceeds 80 characters; contains 81 characters
177 | ERROR | [ ] Comment indentation error, expected only 7 spaces
184 | ERROR | [ ] Comment indentation error, expected only 1 spaces
------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------
FILE: /var/www/html/modules/contrib/storage/src/Controller/StorageController.php
---------------------------------------------------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AND 1 WARNING AFFECTING 6 LINES
---------------------------------------------------------------------------------------------------------------------------------------------
111 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
130 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 4
130 | ERROR | [x] Object operator not indented correctly; expected 6 spaces but found 4
131 | ERROR | [x] Object operator not indented correctly; expected 4 spaces but found 6
186 | ERROR | [ ] The array declaration extends to column 141 (the limit is 80). The array content should be split up over multiple lines
215 | ERROR | [ ] The array declaration extends to column 138 (the limit is 80). The array content should be split up over multiple lines
216 | ERROR | [x] Expected newline after closing brace
---------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------
FILE: /var/www/html/modules/contrib/storage/src/StoragePermissions.php
-----------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
-----------------------------------------------------------------------------------------------------------------------------------------
78 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
82 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
-----------------------------------------------------------------------------------------------------------------------------------------
FILE: /var/www/html/modules/contrib/storage/src/StorageListBuilder.php
----------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------------------
22 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
34 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
----------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------
Time: 2 secs; Memory: 6MB
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/storage/
Proposed resolution
Above error/warnings need to be fixed
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | Screenshot from 2024-05-31 10-54-40.png | 115.8 KB | atul_ghate |
| #17 | interdiff_13-17.txt | 4.07 KB | nikolay shapovalov |
| #17 | 3334370-17.patch | 22.82 KB | nikolay shapovalov |
| #14 | Screenshot from 2023-08-17 16-19-29.png | 157 KB | shiv_sharma |
| #14 | Screenshot from 2023-08-17 16-19-15.png | 171.33 KB | shiv_sharma |
Issue fork storage-3334370
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
Comment #2
samitk commentedError/warnings are fixed.
Also i removed
public function postSave(EntityStorageInterface $storage, $update = TRUE) {function fromsrc/Entity/StorageType.phppath. As that function doesn't have any function definition.Comment #4
charchil khandelwal commentedI will review this.
Comment #6
charchil khandelwal commentedThanks @samit.310@gmail.com, patch #2 applied cleanly, all errors and warnings are fixed.
And i also created MR for same.
Please review.
Comment #7
mxh commentedIn the
StorageTypeFormclass, the dependency injection of thestring_translationservice is missing.Comment #8
samitk commentedHi @mxh,
Thanks for the review,
string_translationservice has been added.Please review.
Comment #9
avpadernoI am not sure it is correct to remove that method. The commented out code could be code maintainers temporary commented out to then change it.
That description is still repeating the class name without describing what the class purpose is.
Avoiding that lines exceed 80 characters does not making shortening them to 50 characters. Also, when a comment line is shortened, all comment must be reformatted.
Comment #10
chaitanyadessai commentedPlease review patch.
Comment #11
sidharth_soman commentedPatch #10 applies cleanly and resolves all errors on the 1.1.x branch. I have attached the relevant screenshots.
Moving to RTBC.
Comment #12
avpadernoThe code is still using
\Drupalto inject dependencies.Like the existing comment, the changed comment is still repeating the class name.
That does not describe the file purpose.
I suggest to check the description used by Drupal core for those files.
Comment #13
mrinalini9 commentedUpdated patch #10 by addressing #12, please review it.
Thanks & Regards,
Mrinalini
Comment #14
shiv_sharma commented@Mrinalini I applied your patch it applied successfully but still able to see some warning which can be fix by phpcbf.

Comment #15
nitin_lamaComment #16
nitin_lamaComment #17
nikolay shapovalov commentedFixes issue mentioned in #9 and #12.
We can disable phpcs for StorageType::postSave() to fix violation we still have, or we can completely remove this method. Maintainer can always get the code from git history. I'd prefer removing postSave().
Comment #18
a.aaronjake commentedHi @Nikolay Shapovalov,
Applied patch #17 successfully, however it threw 6 errors and 3 warnings.
Kindly check.
Thanks,
Jake
Comment #21
atul_ghate commentedAdded MR to fix all phpcs issue please.
Comment #22
a.aaronjake commentedHi @atul_ghate,
Applied latest MR!16 version successfully, confirmed all issues fixed.
Will move this to RTBC.
Thanks,
Jake
Comment #25
avpadernoGitLab CI no longer reports PHP_CodeSniffer warnings/errors. The MR fixes all the warnings/errors.
Comment #27
mandclu commentedComment #29
mandclu commentedThanks for everyone's work here. I updated this for the 1.4.x branch and merged it in.