Fix the issues reported by PHPCS

Created on 31 March 2023, about 1 year ago
Updated 20 April 2023, about 1 year ago

Problem/Motivation

Fix the issues reported by PHPCS for Drupal and DrupalPractice standards in 2.0.x branch

Steps to reproduce

Execute the command: phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,js,info,txt,md,yml,twig smart_trim/

Proposed resolution

Fix all the issues mentioned below:

FILE: ...www/html/contribution/drupal8/web/modules/smart_trim-3351447/CHANGELOG.txt
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 16 WARNINGS AFFECTING 16 LINES
--------------------------------------------------------------------------------
3 | WARNING | Line exceeds 80 characters; contains 81 characters
4 | WARNING | Line exceeds 80 characters; contains 87 characters
5 | WARNING | Line exceeds 80 characters; contains 82 characters
10 | WARNING | Line exceeds 80 characters; contains 89 characters
12 | WARNING | Line exceeds 80 characters; contains 141 characters
13 | WARNING | Line exceeds 80 characters; contains 97 characters
14 | WARNING | Line exceeds 80 characters; contains 88 characters
15 | WARNING | Line exceeds 80 characters; contains 95 characters
18 | WARNING | Line exceeds 80 characters; contains 89 characters
19 | WARNING | Line exceeds 80 characters; contains 91 characters
25 | WARNING | Line exceeds 80 characters; contains 134 characters
27 | WARNING | Line exceeds 80 characters; contains 87 characters
28 | WARNING | Line exceeds 80 characters; contains 97 characters
32 | WARNING | Line exceeds 80 characters; contains 118 characters
33 | WARNING | Line exceeds 80 characters; contains 81 characters
35 | WARNING | Line exceeds 80 characters; contains 96 characters
--------------------------------------------------------------------------------

FILE: .../smart_trim-3351447/src/Plugin/Field/FieldFormatter/SmartTrimFormatter.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
--------------------------------------------------------------------------------
301 | WARNING | Only string literals should be passed to t() where possible
311 | WARNING | Only string literals should be passed to t() where possible
313 | WARNING | \Drupal calls should be avoided in classes, use dependency
| | injection instead
--------------------------------------------------------------------------------

FILE: ...ution/drupal8/web/modules/smart_trim-3351447/src/Truncate/TruncateHTML.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
36 | WARNING | The class short comment should describe what the class does and
| | not simply repeat the class name
--------------------------------------------------------------------------------

Time: 777ms; Memory: 10MB

📌 Task
Status

Fixed

Version

2.0

Component

Code

Created by

🇮🇳India urvashi_vora Madhya Pradesh, India

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 @urvashi_vora
  • 🇮🇳India urvashi_vora Madhya Pradesh, India

    I am working on this, will provide a patch shortly

  • @urvashi_vora opened merge request.
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India urvashi_vora Madhya Pradesh, India
  • Status changed to Needs work about 1 year ago
  • 🇺🇸United States ultimike Florida, USA

    @urvashi_vora - thanks so much for doing this - just one tiny nit-pick above in comment 4...

    -mike

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    The issue summary should always describe what the issue is trying to fix and, in the case, of coding standards issues, show which command has been used, which arguments have been used, and which report that command shown.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India urvashi_vora Madhya Pradesh, India
  • 🇮🇳India urvashi_vora Madhya Pradesh, India

    Hi @ultimike,

    I have made the required changes, please verify.

    Thanks

  • 🇮🇳India urvashi_vora Madhya Pradesh, India

    Hi @apaderno,

    I have updated the issue summary, Please review.

    Thanks

  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    +Issue #2782689 by yvesvanlaer, heddn, markie: How to 
    +translate a custom read more link?
    +Issue #2733381 by Stefdewa, Shreya Shetty: UTF-8 encoding 
    +needed to show all characters correctly
    

    It is quite hard to read the change log in that way. It would be better if the part of the line split by the previous line would be indented. I still think it would be better to leave those lines as they are, though, or change how they are formatted.

     /**
    - * Class TruncateHTML.
    + * Implements Class TruncateHTML.
      */
    

    That short description does not say what the class purpose is. (No, a class does not implement itself.)
    Class is not spelled correctly, since it is not at the beginning of a sentence, it is not a proper noun nor an acronym.

  • First commit to issue fork.
  • Status changed to Needs review about 1 year ago
  • 🇧🇷Brazil elber Brazil

    Hi I just fixed the remaining errors, please revise.

  • Status changed to Needs work about 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    -Issue #2829817 by ultimike, markie, ruloweb: Apply dependency injection (DI) to TruncateHTML class
    +Issue #2829817 by ultimike, markie, ruloweb: Apply dependency
    +injection (DI) to TruncateHTML class
    

    See my previous comment. What I reported there is still valid.

  • 🇧🇷Brazil elber Brazil

    HI I did a rebase and changed the changelog file according with Apaderno's comment. Please revise.

  • 🇺🇸United States markie Albuquerque, NM

    the repository needs local rebase again to fix conflicts.

  • Assigned to elber
  • 🇧🇷Brazil elber Brazil

    I will do that

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    16 pass
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    -Issue #2829817 by ultimike, markie, ruloweb: Apply dependency injection (DI) to TruncateHTML class
    +Issue #2829817 by ultimike, markie, ruloweb: Apply dependency
    +injection (DI) to TruncateHTML class

    The splitted lines are still not indented, which means two spaces should be added to the second line.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    16 pass
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • 🇧🇷Brazil elber Brazil

    Hi I just fixed the characters limit in the contributor.md. Please revise

  • 🇺🇸United States markie Albuquerque, NM

    Whoops.. I approved but then found this:

    ☁  smart_trim [smart_trim-3351447-3351447-fix-the-issues] phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,js,info,txt,md,yml,twig .
    
    FILE: /Users/mark/Sites/Development/drupal10/web/modules/development/smart_trim/contributor.md
    ----------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------
     170 | WARNING | Line exceeds 80 characters; contains 81 characters
    ----------------------------------------------------------------------------------------------
    
    Time: 658ms; Memory: 12MB
    
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    16 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 5.7
    last update about 1 year ago
    16 pass
  • Status changed to Fixed about 1 year ago
  • 🇺🇸United States markie Albuquerque, NM

    Updated the line that was at issue and merged. Thanks for your help!

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    +Issue #3131842 by markie, Kristen Pol, PapaGrande:
    +Read more still not translated
    

    Indenting means adding two spaces at the beginning of the line.
    The second line is not indented at all, and that makes reading the list of changes done difficult to read.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024