Fix the issues reported by phpcs

Created on 13 April 2023, over 1 year ago
Updated 29 April 2023, over 1 year ago

vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig web/modules/contrib/twig_attributes/

FILE: /var/www/html/drupalvb/web/modules/contrib/twig_attributes/README.md
--------------------------------------------------------------------------
FOUND 0 ERRORS AND 7 WARNINGS AFFECTING 7 LINES
--------------------------------------------------------------------------
3 | WARNING | Line exceeds 80 characters; contains 83 characters
4 | WARNING | Line exceeds 80 characters; contains 82 characters
5 | WARNING | Line exceeds 80 characters; contains 83 characters
6 | WARNING | Line exceeds 80 characters; contains 81 characters
14 | WARNING | Line exceeds 80 characters; contains 83 characters
16 | WARNING | Line exceeds 80 characters; contains 84 characters
31 | WARNING | Line exceeds 80 characters; contains 85 characters
--------------------------------------------------------------------------

📌 Task
Status

Fixed

Version

2.0

Component

Code

Created by

🇮🇳India dineshkumarbollu

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 @dineshkumarbollu
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Status changed to Needs work over 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    +- **Key:** The key of the property element to which the attributes
    +should be added.

    The indentation of the second line is wrong. There are other changes that are wrong for the same reason.

  • 🇮🇳India Akram Khan Cuttack, Odisha

    added updated patch and address #4 and it fixed all PHPCS issues

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    -    {{ content.field_image|add_attr('image_attributes', {class: ['custom-class']}) }}
    +    {{ content.field_image|add_attr('image_attributes',
    +       {class: ['custom-class']}) }}

    It is better to leave that as one-line code.

  • 🇮🇳India Akram Khan Cuttack, Odisha

    hi @apaderno but if i change it to one-line code. it'll give phpcs warning

    -------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------
    34 | WARNING | Line exceeds 80 characters; contains 85 characters
    -------------------------------------------------------------------------------------------------------

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    @Akram Just ignore it. Coding standards do not say that lines must be shorter than 81 characters. There are quite few cases where splitting the code over two or more lines is wrong.

    This is what Line length and wrapping , part of the Drupal coding standards says. (Emphasis is mine.)

    • Lines containing longer function names, function/class definitions, variable declarations, etc are allowed to exceed 80 characters.
    • Control structure conditions may exceed 80 characters, if they are simple to read and understand.

    A tool is not able to understand what is better, and it can be ignored in such cases.

  • 🇮🇳India Akram Khan Cuttack, Odisha

    address #8

  • Status changed to Needs review over 1 year ago
  • 🇮🇳India Akram Khan Cuttack, Odisha
  • Status changed to RTBC over 1 year ago
  • 🇺🇸United States rlhawk Seattle, Washington, United States
  • 🇺🇸United States rlhawk Seattle, Washington, United States

    I made a slight adjustment to the one example line to bring it below 80 characters. I also made some minor changes to the top two paragraphs. I will cherry pick these changes to the 8.x-1.x branch.

  • 🇺🇸United States rlhawk Seattle, Washington, United States
  • Status changed to Fixed over 1 year ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024