Problem/Motivation

Coder currently identifies some coding standards issues:

FILE: /var/www/html/web/modules/contrib/permissionspolicy/tests/src/Unit/PermissionsPolicyTest.php
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AFFECTING 6 LINES
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 107 | ERROR | [ ] The array declaration extends to column 90 (the limit is 80). The array content should be split up over multiple lines
 126 | ERROR | [ ] The array declaration extends to column 88 (the limit is 80). The array content should be split up over multiple lines
 152 | ERROR | [x] Functions must not contain multiple empty lines in a row; found 2 empty lines
 181 | ERROR | [x] No space found before comment text; expected "// @todo should appending an empty value result in an empty list?" but found "//@todo should appending an empty
     |       |     value result in an empty list?"
 202 | ERROR | [ ] The array declaration extends to column 103 (the limit is 80). The array content should be split up over multiple lines
 356 | ERROR | [ ] The array declaration extends to column 81 (the limit is 80). The array content should be split up over multiple lines
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/permissionspolicy/src/Form/PermissionsPolicySettingsForm.php
----------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 4 WARNINGS AFFECTING 5 LINES
----------------------------------------------------------------------------------------------------------------------------------------
  36 | WARNING | Unused private method getConfigurableFeatures()
 245 | WARNING | #options values usually have to run through t() for translation
 246 | WARNING | #options values usually have to run through t() for translation
 247 | WARNING | #options values usually have to run through t() for translation
 292 | ERROR   | The array declaration extends to column 99 (the limit is 80). The array content should be split up over multiple lines
----------------------------------------------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/permissionspolicy/src/PermissionsPolicy.php
-----------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------
 156 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
-----------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------

Time: 229ms; Memory: 10MB
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

ptmkenny created an issue. See original summary.

ptmkenny’s picture

Status: Active » Needs review

This MR fixes all of the above warnings except the following:

FILE: /var/www/html/web/modules/contrib/permissionspolicy/src/Form/PermissionsPolicySettingsForm.php
----------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
----------------------------------------------------------------------------------------------------
  36 | WARNING | Unused private method getConfigurableFeatures()
 245 | WARNING | #options values usually have to run through t() for translation
 246 | WARNING | #options values usually have to run through t() for translation
 247 | WARNING | #options values usually have to run through t() for translation
----------------------------------------------------------------------------------------------------


FILE: /var/www/html/web/modules/contrib/permissionspolicy/src/PermissionsPolicy.php
-----------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------
 156 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
-----------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------

I did not fix the "inline comments" warning because it adds a period to the end of some code, whereas the point of the rule is to end sentences in a period.

I left the private method in place because I assume it will be used at some point.

I think the "#options values usually have to run through t() for translation" can be ignored because the options are the actual values used for the permission policy spec and not language dependent. I would ignore them in the linter but I couldn't find a good way to do that.

gapple’s picture

The private method is actually already used, the sniff just appears to not pickup if a method is being called via self or static

Adding phpcs:disable sniffName to the relevant method/class/file docblock will suppress that sniff for the corresponding code block.

gapple’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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