Fix the issues reported by phpcs

Created on 6 January 2022, almost 3 years ago
Updated 7 March 2024, 9 months ago

Problem/Motivation

Child issue from https://www.drupal.org/project/libraries/issues/3075081 ๐Ÿ› Coding standard Needs review
The idea here is to fix all phpcs errors/warnings from the files in the tests/ directory.

Steps to reproduce

Open the Libraries API module directory on your terminal and run the command: phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml tests/ > phpcs_libraries_tests.txt. You should end up with a file like the one attached bellow.

Proposed resolution

Fix the errors either automatically or manually and create a patch.

๐Ÿ“Œ Task
Status

Needs review

Version

3.0

Component

Code

Created by

๐Ÿ‡ง๐Ÿ‡ทBrazil Matheus Macario

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

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    +  /**
    +   * Constructs the controller exampร„ยบe.
    +   *
    +   * @param Drupal\libraries\ExternalLibrary\LibraryManager $libraryManager
    +   *   The library manager.
    +   */
    +  public function __construct(LibraryManager $libraryManager) {
    +    $this->libraryManager = $libraryManager;
    +  }

    The short description for a class constructor must include the class name and its namespace.

       /**
        * Injects BookManager Service.
        */
       public static function create(ContainerInterface $container) {
    -    return new static();
    +    return new static(
    +        $container->get('libraries.manager'),
    +    );
       }

    The documentation comment for that method is simply {@inheritdoc}.

       /**
        * Loads a specified library (variant) for testing.
        *
        * JavaScript and CSS files can be checked directly by SimpleTest, so we only
    -   * need to manually check for PHP files. We provide information about the loaded
    -   * JavaScript and CSS files for easier debugging. See example/README.txt for
    -   * more information.
    +   * need to manually check for PHP files. We provide information about the
    +   * loaded JavaScript and CSS files for easier debugging.
    +   * See example/README.txt for more information.
        */
       private function buildPage($library, $variant = NULL) {

    Parameters and return value are not described.

    -          // $filepath = str_replace('index.php/', '', $filepath);
    +          // $filepath = str_replace('index.php/', '', $filepath);.

    Periods are not added to commented out code, since code is not a sentence.

             'type' => 'external',
             'data' => 'http://example.com/example.css',
             'version' => '1.0.0',
    -      ]],
    +      ],
    +      ],

    The last two lines are not correctly indented.

    -      ->set('global_locators', [['id' => 'uri', 'configuration' => ['uri' => 'asset://']]])
    +      ->set('global_locators', [[
    +        'id' => 'uri',
    +        'configuration' => ['uri' => 'asset://'],
    +      ],
    +      ])
           ->save();

    Lines are allowed to be longer than 80 characters, when they are more readable. The changed code is not more readable than the existing code.

        * @return string
    +   *   returns the library type id string.

    The return value description must not start with returns nor include the return type.
    id is also misspelled.

  • First commit to issue fork.
  • Assigned to nitin_lama
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India
  • Issue was unassigned.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India
  • Assigned to sourabhjain
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sourabhjain

    Let me work on #22.

  • Issue was unassigned.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sourabhjain

    When I am applying patch 16 on 8.x-3.x version it is showing me below error

    sourabhjain@LPT-SOURABH libraries % git apply 3257291-16.patch.txt 
    error: patch failed: tests/src/Functional/LibrariesWebTest.php:196
    error: tests/src/Functional/LibrariesWebTest.php: patch does not apply

    Please update the patch against the version number or correct the version number in ticket.

  • Status changed to Needs review over 1 year ago
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update over 1 year ago
    32 pass
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia mrinalini9 New Delhi

    Rerolled patch #16, please review it.

    Thanks!

  • Assigned to sourabhjain
  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sourabhjain

    Let me work on #22.

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 9.5.x + Environment: PHP 8.0 & MySQL 5.7
    last update over 1 year ago
    32 pass
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sourabhjain

    Fixed the #22 issues. Please review.

  • Hi, patch #28 applied cleanly, but left with minor errors.

    FILE: C:\Users\Nisha\Contribution\libraries\tests\src\Functional\LibrariesWebTest.php
    -------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    -------------------------------------------------------------------------------------------------------
     280 | ERROR | Public method name "LibrariesWebTest::_testLibrariesLoad" is not in lowerCamel format
     411 | ERROR | Public method name "LibrariesWebTest::_testLibrariesOutput" is not in lowerCamel format
    -------------------------------------------------------------------------------------------------------
    
    Time: 1.7 secs; Memory: 14MB
    

    Patch #30 applied cleanly and addresses all the issues mentioned in #22.

  • Status changed to Needs work 10 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    Let's create a MR from the existing issue fork.

  • Assigned to nitin_lama
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India
  • Open on Drupal.org โ†’
    Core: 10.2.1 + Environment: PHP 8.2 & MySQL 8
    last update 10 months ago
    Not currently mergeable.
  • Issue was unassigned.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama India
  • Status changed to Needs review 9 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia pray_12
Production build 0.71.5 2024