PHPCS errors on config files

Created on 6 January 2022, over 3 years ago
Updated 23 February 2023, about 2 years 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 config/ 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 config/ > phpcs_libraries_config.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

RTBC

Version

3.0

Component

Code

Created by

🇧🇷Brazil Matheus Macario

Live updates comments and jobs are added and updated live.
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.

  • First commit to issue fork.
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Status changed to Needs work about 2 years ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    The issue summary should always describe what the issue is trying to fix and, in the case, of coding standards issues, show which command has been used, which arguments have been used, and which report that command shown.

  • Status changed to Needs review about 2 years ago
  • 🇮🇳India nikhilmahala11

    Fix the issues reported by phpcs but still, there are some phpcs issues left.

  • Status changed to Needs work about 2 years ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    The status is also for the issue summary that needs to be updated.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
           // 2.x: this.majorVersion="2";this.minorVersion="1.3"
    -      // 3.x: majorVersion:'3',minorVersion:'2.0.1'
    +      // 3.x: majorVersion:'3',minorVersion:'2.0.1'.

    I am not sure a period is necessary, given what those comments show.

    +  $items['libraries-download'] = array[
    +  'callback' => 'libraries_drush_download',
    +  'description' => dt('Downloads a registered library into the libraries directory for the active site.'),
    +  'arguments' => [
    +  'name' => dt('The internal name of the registered library.'),
    +  ],
    +  ];

    The first line causes a parsing error.
    The other lines are not indented correctly.

     class AssetLibrary extends LibraryBase implements
    -  AssetLibraryInterface,
    -  LocalLibraryInterface,
    -  RemoteLibraryInterface
    -{
    +    AssetLibraryInterface,
    +    LocalLibraryInterface,
    +    RemoteLibraryInterface {

    The line indentation is wrong.

    -   * \Drupal\libraries\ExternalLibrary\Remote\RemoteLibraryInterface::getRemoteUrl()
    +   *   \Drupal\libraries\ExternalLibrary\Remote\RemoteLibraryInterface::getRemoteUrl()
        */

    Probably that line should start with @see.

    +  /**
    +   *
    +   */
       public function files() {

    Documentation comments for methods need to describe the method, its parameters and its return value.

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

    No, a period is not added at the end of a line containing PHP code.

    -      ]],
    +      ],
    +      ],

    The indentation is wrong.

  • 🇨🇦Canada imustakim Canada

    Issue summary updated.

  • First commit to issue fork.
  • Open on Drupal.org →
    Core: 10.1.4 + Environment: PHP 8.2 & MySQL 8
    last update over 1 year ago
    Not currently mergeable.
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • First commit to issue fork.
  • Open on Drupal.org →
    Core: 10.2.1 + Environment: PHP 8.2 & MySQL 8
    last update about 1 year ago
    Not currently mergeable.
  • Assigned to sorabh.v6
  • 🇮🇳India sorabh.v6 Indore

    Working on this, I solved a few phpcs issues already. There have been some deprecated warning. The ones that are drupal related like hook_hook_info and hook_hook_info_alter, I have corrected them. Others, I tried to find the CRs and any useful information but could not and therefore I removed those deprecated text.

  • 🇨🇦Canada danrod Ottawa

    I'm still seeing a lot of PHPCS issues:

    FILE: /home/daniel/websites/libraries/libraries.install
    ----------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------
     8 | WARNING | [x] Unused use statement
    ----------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------
    
    
    FILE: /home/daniel/websites/libraries/libraries.module
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 56 ERRORS AND 18 WARNINGS AFFECTING 61 LINES
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
       9 | WARNING | [x] Unused use statement
      58 | ERROR   | [ ] Missing parameter type
      60 | ERROR   | [ ] Missing parameter type
      63 | ERROR   | [ ] Return type missing for @return tag in function comment
      68 | ERROR   | [ ] The text '@deprecated Will be removed before a stable Drupal 8 release. Please use the new library load and managment concepts described at: https://www.drupal.org/node/2170763' does
         |         |     not match the standard format: @deprecated in %deprecation-version% and is removed from %removal-version%. %extra-info%.
      68 | ERROR   | [ ] Each @deprecated tag must have a @see tag immediately following it
     101 | ERROR   | [ ] Return type missing for @return tag in function comment
     106 | ERROR   | [ ] The text '@deprecated Will be removed before a stable Drupal 8 release. Please use the new library load and managment concepts described at: https://www.drupal.org/node/2170763' does
         |         |     not match the standard format: @deprecated in %deprecation-version% and is removed from %removal-version%. %extra-info%.
     106 | ERROR   | [ ] Each @deprecated tag must have a @see tag immediately following it
     114 | WARNING | [x] There must be no blank line following an inline comment
     122 | WARNING | [x] Empty PHP statement detected: superfluous semicolon.
     162 | ERROR   | [ ] Return type missing for @return tag in function comment
     166 | ERROR   | [ ] The text '@deprecated Will be removed before a stable Drupal 8 release. Please use the new library load and managment concepts described at: https://www.drupal.org/node/2170763' does
         |         |     not match the standard format: @deprecated in %deprecation-version% and is removed from %removal-version%. %extra-info%.
     166 | ERROR   | [ ] Each @deprecated tag must have a @see tag immediately following it
     203 | ERROR   | [ ] Missing parameter type
     206 | ERROR   | [ ] Missing parameter type
     209 | ERROR   | [ ] The text '@deprecated Will be removed before a stable Drupal 8 release. Please use the new library load and managment concepts described at: https://www.drupal.org/node/2170763' does
         |         |     not match the standard format: @deprecated in %deprecation-version% and is removed from %removal-version%. %extra-info%.
     209 | ERROR   | [ ] Each @deprecated tag must have a @see tag immediately following it
     227 | ERROR   | [ ] Missing parameter type
     229 | ERROR   | [ ] Missing parameter type
     232 | ERROR   | [ ] The text '@deprecated Will be removed before a stable Drupal 8 release. Please use the new library load and managment concepts described at: https://www.drupal.org/node/2170763' does
         |         |     not match the standard format: @deprecated in %deprecation-version% and is removed from %removal-version%. %extra-info%.
     232 | ERROR   | [ ] Each @deprecated tag must have a @see tag immediately following it
     266 | ERROR   | [ ] Long array syntax must not be used in doc comment code annotations
     270 | ERROR   | [ ] Long array syntax must not be used in doc comment code annotations
     271 | ERROR   | [ ] Long array syntax must not be used in doc comment code annotations
     272 | ERROR   | [ ] Long array syntax must not be used in doc comment code annotations
    

    Is this still being worked on? or perhaps I am running the phpcs command with wrong arguments:

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

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    The 8.x-3.x branch is no longer supported. I would suggest creating a new issue for the 4.0.x branch, which is currently the only supported branch.

    Furthermore, since GitLab CI is now available for every project, what needs to be fixed is what GitLab CI jobs show as error/warning.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
Production build 0.71.5 2024