Fix code style issues reported by phpcs

Created on 2 June 2025, 4 months ago

Problem/Motivation

The CI phpcs test reports,

FILE: .../key_auth/web/modules/custom/key_auth/tests/src/Functional/KeyAuthTest.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
295 | ERROR | [x] Parameter $user has null default value, but is not marked as
| | nullable.
| | (SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue.NullabilityTypeMissing)
--------------------------------------------------------------------------------
FILE: ...ilds/project/key_auth/web/modules/custom/key_auth/src/KeyAuthInterface.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
10 | WARNING | The class short comment should describe what the class does and
| | not simply repeat the class name
| | (Drupal.Commenting.ClassComment.Short)
--------------------------------------------------------------------------------
FILE: /builds/project/key_auth/web/modules/custom/key_auth/src/KeyAuth.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
5 | WARNING | [x] Unused use statement
| | (Drupal.Classes.UnusedUseStatement.UnusedUse)
5 | ERROR | [x] Non-namespaced classes/interfaces/traits should not be
| | referenced with use statements
| | (Drupal.Classes.UseGlobalClass.RedundantUseStatement)
--------------------------------------------------------------------------------
FILE: .../project/key_auth/web/modules/custom/key_auth/src/Form/UserKeyAuthForm.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
69 | ERROR | [x] Parameter $user has null default value, but is not marked as
| | nullable.
| | (SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue.NullabilityTypeMissing)
--------------------------------------------------------------------------------
FILE: ...ject/key_auth/web/modules/custom/key_auth/src/Form/KeyAuthSettingsForm.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
11 | WARNING | The class short comment should describe what the class does and
| | not simply repeat the class name
| | (Drupal.Commenting.ClassComment.Short)
--------------------------------------------------------------------------------

Steps to reproduce

https://git.drupalcode.org/project/key_auth/-/jobs/4598849

Proposed resolution

follow the advice

Remaining tasks

make a MR

πŸ“Œ Task
Status

Active

Version

2.2

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States BenStallings

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

Merge Requests

Comments & Activities

  • Issue created by @BenStallings
  • Merge request !21address phpcs issues β†’ (Open) created by BenStallings
  • πŸ‡ΊπŸ‡ΈUnited States BenStallings
  • Pipeline finished with Failed
    4 months ago
    Total: 161s
    #512623
  • Issue was unassigned.
  • Status changed to Needs review about 1 month ago
  • First commit to issue fork.
  • First commit to issue fork.
  • πŸ‡¬πŸ‡§United Kingdom schillerm

    Hi, I was getting these phpcs errors.. in !MR21

    FILE: /home/laptopuser/Documents/Test2/Dev-10-3528017/web/modules/contrib/key_auth/tests/src/Functional/KeyAuthTest.php
    -----------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------
    7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Url.
    -----------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------

    FILE: /home/laptopuser/Documents/Test2/Dev-10-3528017/web/modules/contrib/key_auth/key_auth.module
    --------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------------------------------
    9 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Entity\EntityTypeInterface.
    --------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------------------------------

    FILE: /home/laptopuser/Documents/Test2/Dev-10-3528017/web/modules/contrib/key_auth/src/PageCache/DisallowKeyAuthRequests.php
    --------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------------------------------------
    6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\PageCache\RequestPolicyInterface.
    --------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------------------------------------

    FILE: /home/laptopuser/Documents/Test2/Dev-10-3528017/web/modules/contrib/key_auth/src/Authentication/Provider/KeyAuth.php
    --------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------------------------------------------
    6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is
    | | Drupal\Core\Authentication\AuthenticationProviderInterface.
    --------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------------------------------------------

    FILE: /home/laptopuser/Documents/Test2/Dev-10-3528017/web/modules/contrib/key_auth/src/Form/UserKeyAuthForm.php
    ---------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AND 3 WARNINGS AFFECTING 4 LINES
    ---------------------------------------------------------------------------------------------------------------------
    8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\key_auth\KeyAuth.
    161 | WARNING | [ ] User::load calls should be avoided in classes, use dependency injection instead
    174 | WARNING | [ ] User::load calls should be avoided in classes, use dependency injection instead
    193 | WARNING | [ ] User::load calls should be avoided in classes, use dependency injection instead
    ---------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------------------

    FILE: /home/laptopuser/Documents/Test2/Dev-10-3528017/web/modules/contrib/key_auth/src/Form/KeyAuthSettingsForm.php
    -------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------
    6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Form\ConfigFormBase.
    -------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------------------

    FILE: /home/laptopuser/Documents/Test2/Dev-10-3528017/web/modules/contrib/key_auth/src/KeyAuth.php
    -------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------
    8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\user\UserInterface.
    -------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------------

    FILE: /home/laptopuser/Documents/Test2/Dev-10-3528017/web/modules/contrib/key_auth/src/KeyAuthInterface.php
    -------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------
    6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\user\UserInterface.
    -------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------------

    Time: 167ms; Memory: 12MB

    I have been through and fixed the issues listed above. This involved mostly reordering use statements and some changes to web/modules/contrib/key_auth/src/Form/UserKeyAuthForm.php. The tests fail but they look like they need updating. I tested the old fashioned way by creating a user and generating and deleting keys etc.. No problems.

  • Pipeline finished with Failed
    29 days ago
    Total: 390s
    #593921
Production build 0.71.5 2024