Fix the issues reported by phpcs

Created on 5 July 2023, over 1 year ago
Updated 7 June 2024, 6 months ago

Problem/Motivation

Missing coding standards

Steps to reproduce

Run the command:

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

Proposed resolution

Fix the following coding standards issues and create an MR with fixes.

FILE: /Users/roberttabigue/Projects/drupalorgissues/docroot/modules/contrib/codefilter/codefilter.module
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 3 LINES
------------------------------------------------------------------------------------------------------------------------------------------
 17 | ERROR | [x] Missing function doc comment
 35 | ERROR | [ ] The array declaration extends to column 145 (the limit is 80). The array content should be split up over multiple lines
 35 | ERROR | [ ] The array declaration extends to column 206 (the limit is 80). The array content should be split up over multiple lines
 45 | ERROR | [ ] The array declaration extends to column 129 (the limit is 80). The array content should be split up over multiple lines
 45 | ERROR | [ ] The array declaration extends to column 190 (the limit is 80). The array content should be split up over multiple lines
------------------------------------------------------------------------------------------------------------------------------------------


FILE: /Users/roberttabigue/Projects/drupalorgissues/docroot/modules/contrib/codefilter/src/Plugin/Filter/CodeFilter.php
---------------------------------------------------------------------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
---------------------------------------------------------------------------------------------------------------------------------------
  58 | ERROR | The array declaration extends to column 96 (the limit is 80). The array content should be split up over multiple lines
  59 | ERROR | The array declaration extends to column 103 (the limit is 80). The array content should be split up over multiple lines
  62 | ERROR | The array declaration extends to column 126 (the limit is 80). The array content should be split up over multiple lines
  63 | ERROR | The array declaration extends to column 123 (the limit is 80). The array content should be split up over multiple lines
 174 | ERROR | The array declaration extends to column 92 (the limit is 80). The array content should be split up over multiple lines
---------------------------------------------------------------------------------------------------------------------------------------
📌 Task
Status

Fixed

Version

2.0

Component

Code

Created by

🇵🇭Philippines roberttabigue

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

Comments & Activities

  • Issue created by @roberttabigue
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    Waiting for branch to pass
  • 🇵🇭Philippines roberttabigue

    Hi,

    I have created a patch to fix the issues reported by phpcs.

    Please review.
    Thank you!

  • Status changed to Needs work over 1 year ago
  • 🇬🇧United Kingdom joachim
    1. +++ b/codefilter.module
      @@ -14,6 +14,9 @@ function codefilter_form_filter_format_edit_form_alter(&$form, FormStateInterfac
      + *
      

      Needs a comment here.

    2. +++ b/codefilter.module
      @@ -32,7 +35,10 @@ function codefilter_form_filter_format_edit_form_validate(&$form, FormStateInter
      -  if ($form_state->getValue(['filters', 'filter_htmlcorrector', 'status']) && $form_state->getValue(['filters', 'filter_htmlcorrector', 'weight']) < $form_state->getValue(['filters', 'codefilter', 'weight'])) {
      

      Breaking the long lines is good, but I don't think that's quite the right way to do it.

      There are 2 clauses - should be 2 lines.

  • Assigned to nitin_lama
  • 🇮🇳India nitin_lama India

    Patch #2 doesn't apply on 2.0.x branch.

    Providing an updated patch. Please review. Thanks

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    1 pass
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • Assigned to akshay.singh
  • 🇮🇳India akshay.singh Noida

    I am working on this

  • 🇮🇳India akshay.singh Noida

    After applying the above patch, I still got these errors which i have fixed and raised MR and attached a interdiff also.

    ILE: codefilter-3372646/tests/src/Unit/CodeFilterTest.php
    ------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------------------
     6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\codefilter\Plugin\Filter\CodeFilter.
    ------------------------------------------------------------------------------------------------------------------------------------
    
    
    FILE: codefilter-3372646/src/Plugin/Filter/CodeFilter.php
    -----------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------
     6 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Component\Utility\Html.
    -----------------------------------------------------------------------------------------------------------------------
    
  • Issue was unassigned.
  • 🇮🇳India akshay.singh Noida

    changes done please check.
    Thanks

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 5.7
    last update over 1 year ago
    1 pass
  • @akshaysingh opened merge request.
  • Status changed to RTBC over 1 year ago
  • 🇵🇭Philippines roberttabigue

    Hi,

    I applied the latest MR !2 to the module on Drupal 9.5.10 and confirmed all PHPCS errors have been resolved!

    I re-ran this command on the module:
    phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml codefilter/

    Please see the attached files for reference.

    I'm moving this now to RTBC.

    Thank you!

  • 🇬🇧United Kingdom joachim

    Please don't post screenshots of a patch applying. We don't need them and they waste space.

  • Status changed to Fixed 6 months ago
  • 🇬🇧United Kingdom joachim
    • joachim committed de1599b3 on 2.0.x
      Issue #3372646 by akshay.singh, roberttabigue, nitin_lama: Fixed the...
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024