Fix the issues reported by phpcs

Created on 1 November 2023, about 1 year ago
Updated 13 April 2024, 8 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 about 1 year ago
  • šŸ‡®šŸ‡³India keshav patel

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

  • Status changed to RTBC about 1 year 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 about 1 year 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 about 1 year 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';
      }
    
  • First commit to issue 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 11 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 11 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 8 months ago
  • Changing issue status to RTBC as per #17

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