Fix the PHP_CodeSniffer issues reported by GitLab CI

Created on 25 January 2023, almost 2 years ago
Updated 10 May 2024, 7 months ago

GitLab CI reports PHP_CodeSniffer issues that need to be fixed. The ones still to fix are the following ones.

FILE: ...-3336362/web/modules/custom/file_management-3336362/src/FileManagement.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 8 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is Drupal\field\Entity\FieldConfig.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...ile_management-3336362/src/Plugin/views/field/FileManagementOperations.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is Drupal\Core\Url.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...les/custom/file_management-3336362/src/Form/FileManagementEditFileForm.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 6 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is Drupal\Core\Entity\EntityTypeManagerInterface.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...custom/file_management-3336362/src/Controller/FileManagementController.php
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 10 | ERROR | [x] Use statements should be sorted alphabetically. The first
    |       |     wrong one is Drupal\file_management\FileManagement.
    |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
Time: 182ms; Memory: 6MB

 
 

šŸ“Œ Task
Status

Needs review

Version

2.0

Component

Code

Created by

šŸ‡®šŸ‡³India samit.310@gmail.com

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 @samit.310@gmail.com
  • šŸ‡®šŸ‡³India samit.310@gmail.com

    Above error/warnings fixed.

  • šŸ‡®šŸ‡³India Sonal Gyanani

    Patch #2 applied cleanly all errors and warnings are fixed.
    So moving it to RTBC.
    Thanks

  • Issue was unassigned.
  • Status changed to Needs work over 1 year ago
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
    +  /**
    +   * Constructs a FileManagementViewController object.
    +   */
    +  public function __construct(EntityTypeManagerInterface $entity_type_manager) {

    The class name is missing its namespace.

    +  /**
    +   * The File Management service.
    +   *

    File and Management are misspelled.

         $link = Link::fromTextAndUrl(
           $file->getFilename(),
    -      //Url::fromUri(file_create_url($file->getFileUri()))
    -	  Url::fromUri(\Drupal::service('file_url_generator')->generateAbsoluteString($file->getFileUri()))
    +      // Url::fromUri(file_create_url($file->getFileUri()))
    +    Url::fromUri(\Drupal::service('file_url_generator')->generateAbsoluteString($file->getFileUri()))

    The indentation of the last line is wrong.

    +   * @param array $form
    +   *   Form array.

    The short description is missing an article.

    +   *   The form state.
        * @param \Drupal\file\FileInterface $file
    -   *   (optional) The file to be deleted.
    +   *   The file to be deleted (optional).

    It is not necessary to write when a parameter is optional; that is evident from the code.

    +    $new_file_markup = new FormattableMarkup(
    +      'The new file to be used.<br />
    +              Leave empty to keep the existing file.<br />
    +              <strong>Important:</strong> The filename will not be changed unless you specify a new filename below.',
    +      [
    +        '' => '',
    +      ]
    +    );
    +
         $form['new_file_details']['new_file'] = [
           '#title' => $this->t('New file'),
           '#type' => 'file',
    -      '#description' => $this->t(
    -        'The new file to be used.<br />'
    -        . 'Leave empty to keep the existing file.<br />'
    -        . '<strong>Important:</strong> The filename will not be changed unless you specify a new filename below.'
    -      ),
    +      '#description' => $this->t('@new_file_markup', ['@new_file_markup' => $new_file_markup]),
         ];

    The existing code is already correct.

    -    // TODO: set file_validate_extensions correctly
    -    // TODO: Also check the return value of file_save_upload()[0] (could be FALSE)
    +    // @todo set file_validate_extensions correctly

    What follows @todo is a sentence: It starts with a capitalized word and ends with a period.

  • First commit to issue fork.
  • Status changed to Needs review about 1 year ago
  • šŸ‡®šŸ‡³India kalash-j jaipur

    !MR2 Did the required changes mentioned in the comments

  • Status changed to RTBC 7 months ago
  • šŸ‡®šŸ‡³India manish-31

    I have tested the !MR 2 there are no errors on running the PHP CodeSniffer. Marking it RTBC thanks!

    The screenshots, showing the command output before and after applying the MR patch, have been attached.

  • Status changed to Needs review 7 months ago
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • Pipeline finished with Success
    7 months ago
    Total: 203s
    #161525
  • šŸ‡µšŸ‡­Philippines clarkssquared

    Hi

    I applied MR !2 and there are few PHPCS warning and errors

    āžœ  file_management git:(6c34ec1) curl https://git.drupalcode.org/project/file_management/-/merge_requests/2.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 24382    0 24382    0     0  44059      0 --:--:-- --:--:-- --:--:-- 44574
    patching file .gitlab-ci.yml
    patching file composer.json
    patching file file_management.info.yml
    patching file 'modules/file_management_view/README.md'
    patching file 'modules/file_management_view/file_management_view.info.yml'
    patching file 'modules/file_management_view/file_management_view.install'
    patching file 'modules/file_management_view/src/Controller/FileManagementViewController.php'
    patching file 'src/Controller/FileManagementController.php'
    patching file 'src/FileManagement.php'
    patching file 'src/Form/FileManagementDeleteFileConfirmForm.php'
    patching file 'src/Form/FileManagementEditFileForm.php'
    patching file 'src/Plugin/views/field/FileManagementOperations.php'
    āžœ  file_management git:(6c34ec1) āœ— ..
    āžœ  contrib git:(master) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml file_management 
    
    FILE: .../web/modules/contrib/file_management/modules/file_management_view/src/Controller/FileManagementViewController.php
    -----------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------
     23 | WARNING | Line exceeds 80 characters; contains 98 characters
    -----------------------------------------------------------------------------------------------------------------------
    
    
    FILE: ...arksubing-subing/Projects/d9/d9-local/web/modules/contrib/file_management/src/Form/FileManagementEditFileForm.php
    -----------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------
     6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is
       |       |     Drupal\Core\Entity\EntityTypeManagerInterface.
    -----------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------
    
    
    FILE: ...bing/Projects/d9/d9-local/web/modules/contrib/file_management/src/Plugin/views/field/FileManagementOperations.php
    -----------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------
     6 | 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: /Users/clarksubing-subing/Projects/d9/d9-local/web/modules/contrib/file_management/src/FileManagement.php
    -----------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------
     8 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is
       |       |     Drupal\field\Entity\FieldConfig.
    -----------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------
    
    
    FILE: ...ubing-subing/Projects/d9/d9-local/web/modules/contrib/file_management/src/Controller/FileManagementController.php
    -----------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------
     10 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is
        |       |     Drupal\file_management\FileManagement.
    -----------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------
    
    Time: 384ms; Memory: 10MB
    
    āžœ  contrib git:(master) āœ— 
    

    retaining the status to needs review for others to take a look and if they can replicate the issues I reported

  • First commit to issue fork.
  • Pipeline finished with Success
    7 months ago
    Total: 432s
    #169612
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • Pipeline finished with Success
    7 months ago
    Total: 213s
    #169619
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • Pipeline finished with Success
    7 months ago
    Total: 140s
    #169623
  • Pipeline finished with Success
    7 months ago
    Total: 143s
    #169632
  • Pipeline finished with Canceled
    7 months ago
    #169635
  • Pipeline finished with Success
    7 months ago
    Total: 140s
    #169636
Production build 0.71.5 2024