Fix the issues reported by phpcs

Created on 11 July 2023, over 1 year ago

Problem/Motivation

PHPCS finds the following errors:

C:\xampp\htdocs\backendassignment\web\modules\contrib>phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig phoney

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\phoney\modules\krypt\src\Twig\KryptExtension.php
------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------
  1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
 17 | ERROR | [x] Short array syntax must be used to define arrays
------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\phoney\phoney.module
-----------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-----------------------------------------------------------------------------------
  1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
 26 | ERROR | [x] Expected 1 blank line after function; 0 found
-----------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\phoney\README.md
----------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------
 45 | WARNING | Line exceeds 80 characters; contains 149 characters
----------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\phoney\src\PhoneyHelper.php
---------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
---------------------------------------------------------------------------------------
  1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
 16 | ERROR | [x] Short array syntax must be used to define arrays
---------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\phoney\src\Plugin\Filter\Phoney.php
-----------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 1 WARNING AFFECTING 4 LINES
-----------------------------------------------------------------------------------------------
  1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
  6 | WARNING | [x] Unused use statement
 46 | ERROR   | [x] Expected 1 blank line after function; 0 found
 47 | ERROR   | [x] The closing brace for the class must have an empty line before it
-----------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------

Time: 771ms; Memory: 6MB

Steps to reproduce

Run the phpcs command on the module.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Needs work

Version

2.0

Component

Code

Created by

🇮🇳India sidharth_soman Bangalore

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

Comments & Activities

  • Issue created by @sidharth_soman
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India sidharth_soman Bangalore

    I've fixed all the issues except the 'line exceeds 80 chars' error in the readme file. I'm leaving this as it is for readability purposes.

    Please review the patch.

  • Status changed to Needs work 10 months ago
  • 🇮🇳India pray_12

    Hello,
    I tried to apply patch #2, but it was unsuccessful.

    Checking patch modules/krypt/src/Twig/KryptExtension.php...
    error: while searching for:
       * {@inheritdoc}
       */
      public function getFilters() {
        return array(
          new TwigFilter('krypt', 'str_krypt'),
        );
      }
    
      /**
    
    error: patch failed: modules/krypt/src/Twig/KryptExtension.php:14
    error: modules/krypt/src/Twig/KryptExtension.php: patch does not apply
    Checking patch phoney.module...
    error: while searching for:
      }
      return '';
    }
    /**
     * Implements hook_page_attachments_alter().
     */
    
    error: patch failed: phoney.module:24
    error: phoney.module: patch does not apply
    Checking patch src/PhoneyHelper.php...
    Checking patch src/Plugin/Filter/Phoney.php...
  • Assigned to PrabuEla
  • 🇮🇳India PrabuEla chennai
  • 🇮🇳India PrabuEla chennai

    Note:

    I have used below need to be tested is it working or not.

    -use Twig_Extension;
    -use Twig_SimpleFilter;
    +use Twig\Extension\AbstractExtension;
    +use Twig\TwigFilter;

    /**
    * Twig extension to encrypt phone links.
    */
    -class KryptExtension extends Twig_Extension {
    +class KryptExtension extends AbstractExtension {

    - return array(
    - new Twig_SimpleFilter('krypt', 'str_krypt'),
    - );
    + return [
    + new TwigFilter('krypt', 'str_krypt'),
    + ];

    @project maintainer.

  • Issue was unassigned.
  • Status changed to Needs review 10 months ago
  • 🇮🇳India PrabuEla chennai
  • 🇮🇳India Yashaswi18

    Hello, tried applying the patch provided in #6, it applied succesfully.

    3373790_3.patch:13: trailing whitespace.
      2. In the backend go to `admin/config/content/formats`,
    3373790_3.patch:14: trailing whitespace.
      e.g. Basic HTML, and under the section "Enabled filters"
    Checking patch README.md...
    Checking patch modules/krypt/src/Twig/KryptExtension.php...
    Checking patch src/PhoneyHelper.php...
    Checking patch src/Plugin/Filter/Phoney.php...
    Applied patch README.md cleanly.
    Applied patch modules/krypt/src/Twig/KryptExtension.php cleanly.
    Applied patch src/PhoneyHelper.php cleanly.
    Applied patch src/Plugin/Filter/Phoney.php cleanly.
    warning: 2 lines add whitespace errors.

    Ran the command phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig to verify, found no errors and warrnings remaining.

  • Status changed to Needs work 6 months ago
  • Hi @PrabuEla,

    I applied patch from comment #5, and found some issues

    FILE: ...terns/Demo-site/drupal-orgissue/web/modules/contrib/phoney/phoney.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
    --------------------------------------------------------------------------------
    
    
    FILE: ...Interns/Demo-site/drupal-orgissue/web/modules/contrib/phoney/phoney.module
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     26 | ERROR | [x] Expected 1 blank line after function; 0 found
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    
    FILE: ...te/drupal-orgissue/web/modules/contrib/phoney/modules/krypt/krypt.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
    --------------------------------------------------------------------------------
    
    
    FILE: ...issue/web/modules/contrib/phoney/modules/krypt/src/Twig/KryptExtension.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     17 | ERROR | [x] Short array syntax must be used to define arrays
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    Time: 213ms; Memory: 10MB

    Kindly check
    Thank you.

  • 🇺🇸United States bkelly
  • Status changed to Fixed about 1 month ago
  • 🇺🇸United States bkelly
  • 🇺🇸United States bkelly
Production build 0.71.5 2024