Fix the issues reported by phpcs

Created on 11 July 2023, over 1 year ago
Updated 25 July 2023, over 1 year ago

Problem/Motivation

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 infogram

FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\infogram\infogram.info.yml
--------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------
 6 | ERROR | [x] Expected 1 newline at end of file; 0 found
--------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\infogram\infogram.install
----------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------------------------------------------------------------------
 1 | ERROR | [x] End of line character is invalid; expected "\n" but found "\r\n"
 9 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\File\Exception\FileException.
----------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\infogram\infogram.libraries.yml
-------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------
 4 | ERROR | [x] Expected 1 newline at end of file; 0 found
-------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\infogram\infogram.module
-------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES
-------------------------------------------------------------------------------------
  1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
 35 | WARNING | [ ] Line exceeds 80 characters; contains 94 characters
 38 | ERROR   | [x] list(...) is forbidden, use [...] instead.
-------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\infogram\infogram.services.yml
------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------
 3 | ERROR | [x] Expected 1 newline at end of file; 0 found
------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\infogram\README.txt
-------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
-------------------------------------------------------------------------------
  5 | WARNING | [ ] Line exceeds 80 characters; contains 129 characters
 15 | ERROR   | [x] Expected 1 newline at end of file; 0 found
-------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\infogram\src\Infogram.php
-------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------
  1 | ERROR   | [x] End of line character is invalid; expected "\n" but found "\r\n"
 31 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
-------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\infogram\src\Plugin\Filter\FilterInfogram.php
---------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 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\filter\FilterProcessResult.
---------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------


FILE: C:\xampp\htdocs\backendassignment\web\modules\contrib\infogram\templates\infogram.html.twig
-------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------
 2 | ERROR | [x] Expected 1 newline at end of file; 0 found
-------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------

Time: 860ms; 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

RTBC

Version

1.0

Component

Code

Created by

🇮🇳India sidharth_soman Bangalore

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 @sidharth_soman
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India Jaspreet-Kaur

    Applied patch #2 on Drupal 9.5.x and it resolved the all issues.

  • Status changed to Needs work over 1 year ago
  • 🇵🇭Philippines roberttabigue

    Hi @ sidharth_soman,

    I reviewed your changes and confirmed your Patch applied cleanly to the Infogram charts module against 8.x-1.x-dev.

    Checking patch README.txt...
    Checking patch infogram.info.yml...
    Checking patch infogram.install...
    Checking patch infogram.libraries.yml...
    Checking patch infogram.module...
    Checking patch infogram.services.yml...
    Checking patch src/Plugin/Filter/FilterInfogram.php...
    Checking patch templates/infogram.html.twig...
    Applied patch README.txt cleanly.
    Applied patch infogram.info.yml cleanly.
    Applied patch infogram.install cleanly.
    Applied patch infogram.libraries.yml cleanly.
    Applied patch infogram.module cleanly.
    Applied patch infogram.services.yml cleanly.
    Applied patch src/Plugin/Filter/FilterInfogram.php cleanly.
    Applied patch templates/infogram.html.twig cleanly.

    However, I'm still seeing some PHPCS errors.

    I ran this command:
    phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig infogram

    Please see the attached file named "phpcsafterpatch.png".

    I'm moving this to Needs work for now.

    Thank you!

  • Status changed to Needs review over 1 year ago
  • 🇮🇳India sakthi_dev

    Please review.

  • Status changed to Needs work over 1 year ago
  • 🇵🇭Philippines roberttabigue

    Hi @sakthi_dev,

    Confirmed your Patch was applied cleanly.

    Checking patch README.txt...
    Checking patch infogram.info.yml...
    Checking patch infogram.install...
    Checking patch infogram.libraries.yml...
    Checking patch infogram.module...
    Checking patch infogram.services.yml...
    Checking patch src/Infogram.php...
    Checking patch src/Plugin/Filter/FilterInfogram.php...
    Checking patch templates/infogram.html.twig...
    Applied patch README.txt cleanly.
    Applied patch infogram.info.yml cleanly.
    Applied patch infogram.install cleanly.
    Applied patch infogram.libraries.yml cleanly.
    Applied patch infogram.module cleanly.
    Applied patch infogram.services.yml cleanly.
    Applied patch src/Infogram.php cleanly.
    Applied patch src/Plugin/Filter/FilterInfogram.php cleanly.
    Applied patch templates/infogram.html.twig cleanly.

    However, I'm seeing new ones:

    FILE: /Users/roberttabigue/Projects/drupalorgissues/docroot/modules/contrib/infogram/infogram.module
    ---------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    ---------------------------------------------------------------------------------------------------------
     34 | ERROR | [ ] Inline doc block comments are not allowed; use "/* Comment */" or "// Comment" instead
     36 | ERROR | [x] Whitespace found at end of line
    ---------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------------------
    
    
    FILE: /Users/roberttabigue/Projects/drupalorgissues/docroot/modules/contrib/infogram/src/Infogram.php
    -----------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------
     26 | ERROR | [x] There must be exactly one blank line before the tags in a doc comment
    -----------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------
    
    Time: 212ms; Memory: 10MB

    Assigning to Needs work for the investigation.
    Thank you!

  • Status changed to Needs review over 1 year ago
  • 🇮🇳India mrinalini9 New Delhi

    Updated patch #5 by addressing #6, please review it.

    Thanks!

  • Status changed to RTBC over 1 year ago
  • 🇧🇪Belgium Frederikvho Belgium

    Hi,

    I applied the patch, ran the code sniffer command again, and I get no new PHPCS errors or warnings. So the last patch is fine.
    Thanks.

  • Status changed to Needs work over 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    + 1. Enable the **Infogram embed codes** filter in your
    +   text format configuration (/admin/config/content/formats/manage/{format}).
    

    The second line is not correctly indented.

    -    // Creates a temporary file to allow the getimagesize to function on any php.ini settings.
    +    // Creates a temporary file to allow the getimagesize to function on any
    +    // php.ini settings.
    

    Since that comment is changed, the first verb needs to be fixed too: It is Create, not Creates.

  • Status changed to Needs review over 1 year ago
  • 🇮🇳India sakthi_dev

    Please review.

  • Status changed to RTBC over 1 year ago
  • 🇵🇭Philippines roberttabigue

    Hi,

    I reviewed the latest changes and confirmed the Patch #10 was applied cleanly.

    Checking patch README.txt...
    Checking patch infogram.info.yml...
    Checking patch infogram.install...
    Checking patch infogram.libraries.yml...
    Checking patch infogram.module...
    Checking patch infogram.services.yml...
    Checking patch src/Infogram.php...
    Checking patch src/Plugin/Filter/FilterInfogram.php...
    Checking patch templates/infogram.html.twig...
    Applied patch README.txt cleanly.
    Applied patch infogram.info.yml cleanly.
    Applied patch infogram.install cleanly.
    Applied patch infogram.libraries.yml cleanly.
    Applied patch infogram.module cleanly.
    Applied patch infogram.services.yml cleanly.
    Applied patch src/Infogram.php cleanly.
    Applied patch src/Plugin/Filter/FilterInfogram.php cleanly.
    Applied patch templates/infogram.html.twig cleanly.

    And all PHPCS errors have been fixed.

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

    Please see the attached file for reference.

    I'm moving this now to RTBC.
    Thank you!

  • Status changed to Needs work over 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
      2. Use a Wordpress code from your Infogram account:
      ` [infogram id="{id}" format="{format}" prefix="ignored" title="ignored"])`
    

    The last line is not correctly indented.

     3. Enjoy !
    

    Since the text of that list is changed, the space before the exclamation mark must be removed, since in English that space is not used, contrary to French.

  • Status changed to Needs review over 1 year ago
  • 🇮🇳India mrinalini9 New Delhi

    Updated patch #10 by addressing #12, please review it.

    Thanks!

  • Status changed to RTBC over 1 year ago
  • 🇵🇭Philippines roberttabigue

    Hi,

    The Patch #13 was applied cleanly and no PHPCS errors were shown.

    Checking patch README.txt...
    Checking patch infogram.info.yml...
    Checking patch infogram.install...
    Checking patch infogram.libraries.yml...
    Checking patch infogram.module...
    Checking patch infogram.services.yml...
    Checking patch src/Infogram.php...
    Checking patch src/Plugin/Filter/FilterInfogram.php...
    Checking patch templates/infogram.html.twig...
    Applied patch README.txt cleanly.
    Applied patch infogram.info.yml cleanly.
    Applied patch infogram.install cleanly.
    Applied patch infogram.libraries.yml cleanly.
    Applied patch infogram.module cleanly.
    Applied patch infogram.services.yml cleanly.
    Applied patch src/Infogram.php cleanly.
    Applied patch src/Plugin/Filter/FilterInfogram.php cleanly.
    Applied patch templates/infogram.html.twig cleanly.

    Please see the attached file for reference.

    Moving this to RTBC.

    Thank you!

Production build 0.71.5 2024