Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hey, I came across some best practices issues and coding standards, example of Drupal practices :
phpcs --standard=Drupal modules/contrib/jsonapi_extras/
FILE: /var/www/drupal-8/modules/contrib/jsonapi_extras/modules/jsonapi_defaults/README.txt
------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 5 LINES
------------------------------------------------------------------------------------------
5 | WARNING | Line exceeds 80 characters; contains 344 characters
9 | WARNING | Line exceeds 80 characters; contains 96 characters
10 | WARNING | Line exceeds 80 characters; contains 93 characters
11 | WARNING | Line exceeds 80 characters; contains 94 characters
12 | WARNING | Line exceeds 80 characters; contains 91 characters
------------------------------------------------------------------------------------------
FILE: /var/www/drupal-8/modules/contrib/jsonapi_extras/modules/jsonapi_defaults/tests/src/Functional/JsonApiDefaultsFunctionalTest.php
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------
16 | ERROR | Missing member variable doc comment
--------------------------------------------------------------------------------------------------------------------------------------
FILE: /var/www/drupal-8/modules/contrib/jsonapi_extras/tests/src/Functional/JsonApiExtrasFunctionalTest.php
-----------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------
25 | ERROR | Missing member variable doc comment
-----------------------------------------------------------------------------------------------------------
FILE: /var/www/drupal-8/modules/contrib/jsonapi_extras/src/Form/JsonapiExtrasSettingsForm.php
---------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------
16 | ERROR | Missing member variable doc comment
---------------------------------------------------------------------------------------------
FILE: /var/www/drupal-8/modules/contrib/jsonapi_extras/src/Plugin/jsonapi/FieldEnhancer/JSONFieldEnhancer.php
-------------------------------------------------------------------------------------------------------------
FOUND 8 ERRORS AND 2 WARNINGS AFFECTING 9 LINES
-------------------------------------------------------------------------------------------------------------
9 | ERROR | [x] There must be one blank line after the last USE statement; 2 found;
23 | ERROR | [ ] Missing short description in doc comment
28 | ERROR | [ ] Missing short description in doc comment
30 | ERROR | [ ] Missing parameter comment
31 | ERROR | [ ] Missing parameter comment
32 | ERROR | [ ] Missing parameter comment
32 | ERROR | [ ] Missing parameter type
33 | ERROR | [ ] Missing parameter comment
76 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
77 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
-------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------
FILE: /var/www/drupal-8/modules/contrib/jsonapi_extras/src/Plugin/ResourceFieldEnhancerInterface.php
----------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------
5 | WARNING | [x] Unused use statement
----------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------
FILE: /var/www/drupal-8/modules/contrib/jsonapi_extras/css/jsonapi_extras.expandable_rows_table.css
---------------------------------------------------------------------------------------------------
FOUND 10 ERRORS AFFECTING 10 LINES
---------------------------------------------------------------------------------------------------
2 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
3 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
7 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
11 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
12 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
16 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
20 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
24 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
28 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
32 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 4
---------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 10 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------
FILE: /var/www/drupal-8/modules/contrib/jsonapi_extras/jsonapi_extras.module
----------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------
52 | ERROR | Type hint "array" missing for $variables
----------------------------------------------------------------------------
Time: 1.69 secs; Memory: 14MB
Comment | File | Size | Author |
---|---|---|---|
#2 | code_standart-3065906-2.patch | 7.02 KB | Sergiu Stici |
|
Comments
Comment #2
Sergiu Stici CreditAttribution: Sergiu Stici at FFW commentedHere is the patch, please review.
Comment #3
e0ipsoThanks for taking care of this! 🙏🏽