Fix coding standards

Created on 10 November 2023, almost 2 years ago
Updated 13 November 2023, almost 2 years ago

Problem/Motivation

Scanning the module identifies a number of coding standards issues:

> ./vendor/bin/phpcs -p --colors --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md --ignore=node_modules,vendor ./web/modules/contrib/webauthn
.E.EEEE.E.E.W..E.WWE.. 22 / 22 (100%)



FILE: /Users/private/d/anata/web/modules/contrib/webauthn/webauthn.module
-------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
-------------------------------------------------------------------------
  1 | ERROR   | [x] Missing file doc comment
 90 | WARNING | [ ] Unused variable $public_key_credential_source.
-------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------


FILE: /Users/private/d/anata/web/modules/contrib/webauthn/src/Form/SettingsForm.php
-----------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 1 LINE
-----------------------------------------------------------------------------------------
 55 | ERROR | [x] Array indentation error, expected 8 spaces but found 10
 55 | ERROR | [x] Object operator not indented correctly; expected 8 spaces but found 10
-----------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------


FILE: /Users/private/d/anata/web/modules/contrib/webauthn/src/Form/PublicKeyCredentialRequestForm.php
-------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 2 WARNINGS AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------------------------------------
 146 | WARNING | [x] There must be no blank line following an inline comment
 146 | WARNING | [ ] There must be no blank line following an inline comment
 316 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
-------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------


FILE: /Users/private/d/anata/web/modules/contrib/webauthn/src/Form/AccountForm.php
-----------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 7 ERRORS AND 6 WARNINGS AFFECTING 12 LINES
-----------------------------------------------------------------------------------------------------------------------------------------------------
  89 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
  99 | ERROR   | [ ] Comment indentation error, expected only 1 spaces
 101 | ERROR   | [ ] Comment indentation error, expected only 1 spaces
 119 | WARNING | [x] '@TODO Provide a way create new credentials with different names/email.' should match the format '@todo Fix problem X here.'
 146 | WARNING | [ ] Line exceeds 80 characters; contains 83 characters
 173 | ERROR   | [x] Expected 1 space(s) after cast statement; 0 found
 309 | WARNING | [x] '@TODO: Alter the form state as the form values are directly extracted and' should match the format '@todo Fix problem X here.'
 310 | ERROR   | [ ] Comment indentation error, expected only 1 spaces
 312 | WARNING | [x] There must be no blank line following an inline comment
 312 | WARNING | [ ] There must be no blank line following an inline comment
 323 | ERROR   | [x] Array indentation error, expected 6 spaces but found 15
 324 | ERROR   | [x] Array indentation error, expected 6 spaces but found 15
 325 | ERROR   | [x] Array closing indentation error, expected 4 spaces but found 13
-----------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------------------------------


FILE: /Users/private/d/anata/web/modules/contrib/webauthn/src/Form/PublicKeyCredentialCreationForm.php
---------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
---------------------------------------------------------------------------------------------------------
  14 | ERROR | [x] Non-namespaced classes/interfaces/traits should not be referenced with use statements
 225 | ERROR | [x] Object operator not indented correctly; expected 8 spaces but found 10
---------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------


FILE: /Users/private/d/anata/web/modules/contrib/webauthn/src/Server.php
-------------------------------------------------------------------------------------------------------------------------------
FOUND 10 ERRORS AND 3 WARNINGS AFFECTING 13 LINES
-------------------------------------------------------------------------------------------------------------------------------
  15 | ERROR   | [x] Non-namespaced classes/interfaces/traits should not be referenced with use statements
  17 | ERROR   | [x] Non-namespaced classes/interfaces/traits should not be referenced with use statements
  44 | ERROR   | [ ] Missing short description in doc comment
  49 | ERROR   | [ ] Missing short description in doc comment
  54 | ERROR   | [ ] Missing short description in doc comment
  59 | ERROR   | [ ] Missing short description in doc comment
  73 | ERROR   | [ ] Missing parameter comment
  74 | ERROR   | [ ] Missing parameter comment
  93 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
  95 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 139 | WARNING | [x] '@TODO Add base64 encoded user picture.' should match the format '@todo Fix problem X here.'
 159 | WARNING | [ ] Exceptions should not be translated
 241 | WARNING | [ ] Exceptions should not be translated
-------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------


FILE: /Users/private/d/anata/web/modules/contrib/webauthn/src/Entity/PublicKeyCredentialSourceRepository.php
------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 1 WARNING AFFECTING 4 LINES
------------------------------------------------------------------------------------------------------------
 21 | ERROR   | [ ] Missing short description in doc comment
 26 | ERROR   | [ ] Missing short description in doc comment
 73 | ERROR   | [x] Expected 1 space after FUNCTION keyword; 0 found
 88 | WARNING | [ ] Exceptions should not be translated
------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------


FILE: /Users/private/d/anata/web/modules/contrib/webauthn/src/Entity/Handlers/PublicKeyCredentialSourceListBuilder.php
----------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------------------------------------------------------
 10 | WARNING | [x] Unused use statement
 34 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------


FILE: /Users/private/d/anata/web/modules/contrib/webauthn/src/Entity/Handlers/PublicKeyCredentialSourceAccessControlHandler.php
-------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------------------
 11 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Access\AccessResult.
-------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------


FILE: /Users/private/d/anata/web/modules/contrib/webauthn/src/Plugin/Validation/Constraint/UserMailRequiredValidator.php
------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------
 27 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------


FILE: /Users/private/d/anata/web/modules/contrib/webauthn/src/Plugin/Validation/Constraint/UserMailRequired.php
---------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
---------------------------------------------------------------------------------------------------------------
  8 | WARNING | [x] Unused use statement
 17 | WARNING | [ ] Line exceeds 80 characters; contains 88 characters
---------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------


FILE: /Users/private/d/anata/web/modules/contrib/webauthn/src/ServerInterface.php
---------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
---------------------------------------------------------------------------------
  17 | ERROR | [x] Doc comment short description must end with a full stop
 102 | ERROR | [ ] Missing parameter comment
 104 | ERROR | [ ] Description for the @return value is missing
---------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------

Time: 335ms; Memory: 16MB
šŸ“Œ Task
Status

Needs review

Version

1.0

Component

Code

Created by

šŸ‡ÆšŸ‡µJapan ptmkenny

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

Comments & Activities

  • Issue created by @ptmkenny
  • @ptmkenny opened merge request.
  • Status changed to Needs review almost 2 years ago
  • šŸ‡ÆšŸ‡µJapan ptmkenny

    My MR in #2 fixes all reported issues except these two:

    FILE: /Users/private/d/anata/web/modules/contrib/webauthn/webauthn.module
    -------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -------------------------------------------------------------------------
     90 | WARNING | Unused variable $public_key_credential_source.
    -------------------------------------------------------------------------
    
    
    FILE: /Users/private/d/anata/web/modules/contrib/webauthn/src/Form/AccountForm.php
    ---------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------
     89 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    ---------------------------------------------------------------------------------------------
    
    Time: 336ms; Memory: 16MB
    
  • šŸ‡µšŸ‡­Philippines clarkssquared

    Hi

    I applied the MR !2 and I confirmed that it fixes most of the PHPCS issues with the exception stated in the comment #3

    āžœ  webauthn git:(87637e1) curl https://git.drupalcode.org/project/webauthn/-/merge_requests/4.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 18599    0 18599    0     0  32702      0 --:--:-- --:--:-- --:--:-- 33035
    patching file 'src/Entity/Handlers/PublicKeyCredentialSourceAccessControlHandler.php'
    patching file 'src/Entity/Handlers/PublicKeyCredentialSourceListBuilder.php'
    patching file 'src/Entity/PublicKeyCredentialSourceRepository.php'
    patching file 'src/Form/AccountForm.php'
    patching file 'src/Form/PublicKeyCredentialCreationForm.php'
    patching file 'src/Form/PublicKeyCredentialRequestForm.php'
    patching file 'src/Form/SettingsForm.php'
    patching file 'src/Plugin/Validation/Constraint/UserMailRequired.php'
    patching file 'src/Plugin/Validation/Constraint/UserMailRequiredValidator.php'
    patching file 'src/Server.php'
    patching file 'src/ServerInterface.php'
    patching file webauthn.module
    āžœ  webauthn git:(87637e1) āœ— ..
    āžœ  contrib git:(master) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml webauthn 
    
    FILE: ...g-subing/Projects/d9/d9-local/web/modules/contrib/webauthn/webauthn.module
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     90 | WARNING | Unused variable $public_key_credential_source.
    --------------------------------------------------------------------------------
    
    
    FILE: ...Projects/d9/d9-local/web/modules/contrib/webauthn/src/Form/AccountForm.php
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     89 | WARNING | \Drupal calls should be avoided in classes, use dependency
        |         | injection instead
    --------------------------------------------------------------------------------
    
    Time: 628ms; Memory: 12MB
    
    āžœ  contrib git:(master) āœ— 
    

    Retaining the status to Needs Review so that others can share their insights regarding the issue.

    RTBC +1 for me.

Production build 0.71.5 2024