Fix the issues reported by phpcs

Created on 1 November 2023, 8 months ago
Updated 13 April 2024, 2 months ago

Problem/Motivation

The following PHPCS Issues were reported:

Command:
vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml /path/to/module/

Reported Issues:

FILE: eqneditor/src/Plugin/CKEditorPlugin/Equationbutton.php
---------------------------------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AND 1 WARNING AFFECTING 6 LINES
---------------------------------------------------------------------------------------------------------------------------------------------
  1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
  6 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\ckeditor\CKEditorPluginBase.
 46 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 50 | ERROR   | [x] Expected 1 blank line after function; 0 found
 56 | ERROR   | [x] Expected 1 blank line after function; 0 found
 57 | ERROR   | [x] The closing brace for the class must have an empty line before it
---------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------

FILE: eqneditor/eqneditor.module
------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
------------------------------------------------------------------------------------------
 23 | ERROR | [x] Short array syntax must be used to define arrays
 25 | ERROR | [x] Case breaking statements must be followed by a single blank line
------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ“Œ Task
Status

RTBC

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia Keshav Patel

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

Merge Requests

Comments & Activities

  • Issue created by @Keshav Patel
  • Status changed to Needs review 8 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Keshav Patel

    The provided patch file "fix_coding_standards-3398244-2.patch", fixes all the phpcs reported issues.

  • Status changed to RTBC 8 months ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines clarkssquared

    Hi Keshav,

    I applied your patch #2 and I confirmed that it fixes all the PHPCS issues, the only remaining issues being flagged are "project", "datestamp", and "version" which I believe appears when the module is installed via composer.

    โžœ  eqneditor git:(master) โœ— curl https://www.drupal.org/files/issues/2023-11-01/fix_coding_standards-3398244-2.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  3503  100  3503    0     0  12201      0 --:--:-- --:--:-- --:--:-- 12555
    patching file eqneditor.module
    patching file 'src/Plugin/CKEditorPlugin/Equationbutton.php'
    โžœ  eqneditor git:(master) โœ— ..
    โžœ  contrib git:(master) โœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml eqneditor 
    
    FILE: ...bing/Projects/d9/d9-local/web/modules/contrib/eqneditor/eqneditor.info.yml
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     1 | WARNING | Remove "project" from the info file, it will be added by
       |         | drupal.org packaging automatically
     1 | WARNING | Remove "datestamp" from the info file, it will be added by
       |         | drupal.org packaging automatically
     1 | WARNING | Remove "version" from the info file, it will be added by
       |         | drupal.org packaging automatically
    --------------------------------------------------------------------------------
    
    Time: 253ms; Memory: 10MB
    
    โžœ  contrib git:(master) โœ— 
    
  • Status changed to Needs work 8 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    +  /**
    +   * Implements \Drupal\ckeditor\Plugin\CKEditorPluginInterface::getFile().
    +   */
    +  public function getFile() {

    For methods defined in an interface or a parent class, the documentation comment contains just {@inheritdoc}.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Keshav Patel

    The revised patch file "fix_coding_standards-3398244-5.patch", fixes the PHPCS reported issues in accordance with comment #4.

  • Status changed to Needs review 8 months ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines erwindaez

    Hi Keshav,

    Confirmed the patch on #5 complies with #4
    Here is the code on line 22:

      /**
       * {@inheritdoc}
       */
      public function getFile() {
        return base_path() . 'libraries/eqneditor/plugin.js';
      }
    
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Preethy_ray

    pray_12 โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia viren18febS

    i have applied #8 and still see some issues, i have fixed and applied a patch for this . Please review

  • Status changed to Needs work 5 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
    +  /**
    +   * Implements \Drupal\ckeditor\Plugin\CKEditorPluginInterface::getFile().
    +   */
    +  public function getFile() {
    +    return base_path() . 'libraries/eqneditor/plugin.js';
    +  }

    Method descriptions do not start with Implements. This has been already reported in comment #4 and fixed in the patch provided in comment #5.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    Let's keep using the issue fork, which has been already created.

  • First commit to issue fork.
  • Status changed to Needs review 5 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Yashaswi18

    These are the only issues I found on running the command:

     phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml eqneditor/
    
    FILE: C:\Users\YASHASWI\OneDrive\Desktop\Contrib\eqneditor\eqneditor.module
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     1 | ERROR | [x] End of line character is invalid; expected "\n" but found
       |       |     "\r\n"
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    
    FILE: ...ive\Desktop\Contrib\eqneditor\src\Plugin\CKEditorPlugin\Equationbutton.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     1 | ERROR | [x] End of line character is invalid; expected "\n" but found
       |       |     "\r\n"
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Hi,
    Applied MR!1 , found no phpcs issues.

  • Status changed to RTBC 2 months ago
  • Changing issue status to RTBC as per #17

  • Pipeline finished with Success
    2 months ago
    Total: 168s
    #147660
  • Pipeline finished with Success
    2 months ago
    Total: 293s
    #147678
Production build 0.69.0 2024