Use statements should be sorted alphabetically.

Created on 19 July 2023, over 1 year ago
Updated 22 July 2024, 4 months ago

Problem/Motivation

I'm getting the use statements sorting error for multiple files in the module.

Steps to reproduce

Run the command:

phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml modules/contrib/qtools_transport_profiler/

Proposed resolution

Fix the following coding standards issues and upload the patch or create an MR with fixes.

FILE: modules/contrib/qtools_transport_profiler/src/TransportServiceWrapper.php
---------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------------
 10 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\qtools_common\QToolsCacheHelper.
---------------------------------------------------------------------------------------------------------------------------

FILE: modules/contrib/qtools_transport_profiler/src/Form/ReportFilterForm.php
-----------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------------------
 8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Datetime\DrupalDateTime.
-------------------------------------------------------------------------------------------------------------------------

FILE: modules/contrib/qtools_transport_profiler/src/ReportService.php
-------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------------------------------
 9 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Database\Connection.
-------------------------------------------------------------------------------------------------------------------------

๐Ÿ“Œ Task
Status

RTBC

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia swatichouhan012

Live updates comments and jobs are added and updated live.
  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @swatichouhan012
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia swatichouhan012

    The statements are now sorted. Please review the patch

  • Status changed to Needs work 4 months ago
  • Hi @swatichouhan012,

    The patch you provided was applied successfully and confirmed fixed sorting of statements, however, sorting is not the only error that was reported by my terminal, those errors needs to be fixed. Please see below:

    qtools_transport_profiler git:(1.0.x) curl https://www.drupal.org/files/issues/2023-07-19/3375579-2.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  2248  100  2248    0     0   5762      0 --:--:-- --:--:-- --:--:--  5931
    patching file src/Form/ReportFilterForm.php
    patching file src/ReportService.php
    patching file src/TransportServiceWrapper.php
    โžœ  qtools_transport_profiler git:(1.0.x) โœ— cd ..
    โžœ  contrib git:(master) โœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig qtools_transport_profiler
    
    FILE: ...9/web/modules/contrib/qtools_transport_profiler/src/PerformanceService.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     58 | ERROR | [x] Multi-line function declarations must have a trailing comma
        |       |     after the last parameter
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    
    FILE: .../modules/contrib/qtools_transport_profiler/src/TransportServiceWrapper.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     60 | ERROR | [x] Multi-line function declarations must have a trailing comma
        |       |     after the last parameter
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    
    FILE: ...contrib/qtools_transport_profiler/src/Controller/ErrorReportController.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     47 | ERROR | [x] Multi-line function declarations must have a trailing comma
        |       |     after the last parameter
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    
    FILE: ...ntrib/qtools_transport_profiler/src/Controller/RequestReportController.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     43 | ERROR | [x] Multi-line function declarations must have a trailing comma
        |       |     after the last parameter
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    Time: 689ms; Memory: 16MB

    Kindly check

    Thanks,
    Jake

  • First commit to issue fork.
  • Merge request !1Issue #3375579:Fixed all phpcs. โ†’ (Open) created by Unnamed author
  • Status changed to Needs review 4 months ago
  • Status changed to RTBC 4 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vinmayiswamy

    Hi,
    I've tested MR !1 in Drupal 10.3.xโ€จThe patch is applied Cleanly...

    Test Result:โ€จ
    The phpcs issues were fixed after the updated changes.

    RTBC+1

    Thanks!

  • Hi @everyone,

    Also confirmed MR!1 fixed all reported errors.

    qtools_transport_profiler git:(1.0.x) curl https://git.drupalcode.org/project/qtools_transport_profiler/-/merge_requests/1.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  4465    0  4465    0     0  14843      0 --:--:-- --:--:-- --:--:-- 15238
    patching file src/Controller/ErrorReportController.php
    patching file src/Controller/RequestReportController.php
    patching file src/Form/ReportFilterForm.php
    patching file src/PerformanceService.php
    patching file src/ReportService.php
    patching file src/TransportServiceWrapper.php
    โžœ  qtools_transport_profiler git:(1.0.x) โœ— cd ..
    โžœ  contrib git:(master) โœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig qtools_transport_profiler
    zsh: command not found: phpcs
    โžœ  contrib git:(master) โœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig qtools_transport_profiler
    โžœ  contrib git:(master) โœ—

    RTBC +1 also from me.

    Thanks,
    Jake

Production build 0.71.5 2024