Fix the issues reported by phpcs

Created on 23 May 2023, over 1 year ago

Problem/Motivation

Found this issues reported by phpcs:

FILE: /Users/studenttrainees/Drupal.org/drupalorg-site/docroot/modules/contrib/content_editing_message/README.md
----------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------
 31 | WARNING | Line exceeds 80 characters; contains 82 characters
----------------------------------------------------------------------------------------------------------------


FILE: ...rainees/Drupal.org/drupalorg-site/docroot/modules/contrib/content_editing_message/content_editing_message.module
----------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 1 LINE
----------------------------------------------------------------------------------------------------------------------
 48 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
 48 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------


FILE: ...al.org/drupalorg-site/docroot/modules/contrib/content_editing_message/src/Form/ContentEditingMessageFormBase.php
----------------------------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AFFECTING 4 LINES
----------------------------------------------------------------------------------------------------------------------
 229 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
 229 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 3
 229 | ERROR | [x] Object operator not indented correctly; expected 6 spaces but found 3
 230 | ERROR | [x] Object operator not indented correctly; expected 3 spaces but found 6
 283 | ERROR | [ ] The array declaration extends to column 215 (the limit is 80). The array content should be split
     |       |     up over multiple lines
 288 | ERROR | [ ] The array declaration extends to column 213 (the limit is 80). The array content should be split
     |       |     up over multiple lines
----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------

Time: 469ms; Memory: 12MB

Steps to reproduce

Run this command in the module folder: phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml

Proposed resolution

Remaining tasks

šŸ“Œ Task
Status

Active

Version

1.0

Component

Code

Created by

šŸ‡µšŸ‡­Philippines paraderojether

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

Merge Requests

Comments & Activities

  • Issue created by @paraderojether
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • Open in Jenkins ā†’ Open on Drupal.org ā†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    1 pass
  • šŸ‡µšŸ‡­Philippines paraderojether

    Created a patch to fix the issues reported by phpcs.

    Please review.
    Thank You.

  • Status changed to RTBC over 1 year ago
  • šŸ‡¬šŸ‡§United Kingdom schillerm

    Hi, reviewed and tested a patched version of the 8.x-1.x-dev module on a local D9 site.

    I ran phpcs --standard=Drupal --ignore=PATCHES.txt --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml web/modules/contrib/content_editing_message

    No errors or warnings returned, so moving to RTBC.

  • Assigned to Jay Jangid
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • šŸ‡®šŸ‡³India Jay Jangid

    Apply patch #2 showing this error.
    See screenshot.
    Thank you.

  • Open in Jenkins ā†’ Open on Drupal.org ā†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    1 pass
  • šŸ‡µšŸ‡­Philippines paraderojether

    I updated the patch.

    Please review again.
    Thank You.

  • Status changed to Needs work over 1 year ago
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
    -      $this->messenger()->addStatus($this->t('Message <a href=":url">%label</a> has been updated.', ['%label' => $content_editing_message->label(), ':url' => $content_editing_message->toUrl('edit-form')->toString()]));
    +      $this->messenger()->addStatus($this->t(
    +      'Message <a href=":url">%label</a> has been updated.',
    +      [
    +        '%label' => $content_editing_message->label(),
    +        ':url' => $content_editing_message->toUrl('edit-form')->toString(),
    +      ]
    +      ));
    -      $this->messenger()->addStatus($this->t('Message <a href=":url">%label</a> has been added.', ['%label' => $content_editing_message->label(), ':url' => $content_editing_message->toUrl('edit-form')->toString()]));
    +      $this->messenger()->addStatus($this->t(
    +      'Message <a href=":url">%label</a> has been added.',
    +      [
    +        '%label' => $content_editing_message->label(),
    +        ':url' => $content_editing_message->toUrl('edit-form')->toString(),
    +      ]
    +      ));

    The code is not correctly indented.

  • Status changed to Needs review over 1 year ago
  • Open in Jenkins ā†’ Open on Drupal.org ā†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update over 1 year ago
    1 pass
  • šŸ‡®šŸ‡³India sakthi_dev

    Created patch bases on #7. Please review,

  • šŸ‡®šŸ‡³India Raveen Kumar

    Hello guys.
    I have reviewed & implemented the #8 patch on to my drupal website having version - 9.5.9 & PHP version - 8.1
    I am confirming that after using #patch8, the phpcs issues were resolved completely. As you can see in the attached screenshot.
    Please & thank you.

  • šŸ‡®šŸ‡³India dev16.addweb

    Even after applying the patch, I continued to receive this kind of problem.

    FILE: ...l_10_2_6/web/modules/contrib/content_editing_message/tests/src/Unit/ContentEditingMessageTest.php
    -------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------
    46 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
    -------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------

    FILE: ...pal_10_2_6/web/modules/contrib/content_editing_message/src/Form/ContentEditingMessageFormBase.php
    -------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AND 1 WARNING AFFECTING 2 LINES
    -------------------------------------------------------------------------------------------------------
    195 | ERROR | [x] Expected 1 space after FOREACH keyword; 0 found
    195 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
    -------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------

    FILE: ...l_10_2_6/web/modules/contrib/content_editing_message/src/Form/ContentEditingMessageDeleteForm.php
    -------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------
    7 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is
    | | Drupal\Core\Form\FormStateInterface.
    -------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------

    FILE: ...6/web/modules/contrib/content_editing_message/src/Controller/ContentEditingMessageListBuilder.php
    -------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------
    70 | ERROR | [x] Expected 1 space after IF keyword; 0 found
    70 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
    -------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------

    FILE: .../web/web/drupal_10_2_6/web/modules/contrib/content_editing_message/content_editing_message.module
    -------------------------------------------------------------------------------------------------------
    FOUND 9 ERRORS AFFECTING 5 LINES
    -------------------------------------------------------------------------------------------------------
    9 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is
    | | Drupal\Core\Entity\EntityInterface.
    66 | ERROR | [x] Expected 1 space after IF keyword; 0 found
    66 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
    70 | ERROR | [x] Expected newline after closing brace
    70 | ERROR | [x] Expected 1 space after ELSEIF keyword; 0 found
    70 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
    81 | ERROR | [ ] All functions defined in a module file must be prefixed with the module's name,
    | | found "append_message" but expected "content_editing_message_append_message"
    81 | ERROR | [x] Expected 1 space before opening brace; found 0
    110 | ERROR | [x] Expected 1 blank line after function; 0 found
    -------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------

    I have fixed all the issues reported by phpcs.

  • Status changed to Needs work 6 months ago
  • šŸ‡µšŸ‡­Philippines roberttabigue

    Hi @silvi,

    After applying your Patch #10 to the Content Editing Messages module against 8.x-1.x-dev on Drupal 10, I still see 1 PHPCS warning.
    See below:

    FILE: /Users/roberttabigue/Project/DrupalOrg/drupalorgissues/web/modules/contrib/content_editing_message/src/Form/ContentEditingMessageFormBase.php
    ---------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------------------------------------------------------------
     194 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    ---------------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 159ms; Memory: 12MB

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

    Please see the attached files for reference.

    I'm moving this now to Needs work.

    Thank you!

  • Open on Drupal.org ā†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 6 months ago
    Not currently mergeable.
  • Open in Jenkins ā†’ Open on Drupal.org ā†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 6 months ago
    1 pass
  • Pipeline finished with Failed
    6 months ago
    Total: 227s
    #181812
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • Open in Jenkins ā†’ Open on Drupal.org ā†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 6 months ago
    PHPLint Failed
  • Status changed to Needs review 6 months ago
  • šŸ‡®šŸ‡¹Italy apaderno Brescia, šŸ‡®šŸ‡¹
  • Pipeline finished with Failed
    6 months ago
    Total: 150s
    #181909
  • šŸ‡µšŸ‡­Philippines clarkssquared

    HI

    I applied the updated MR !3 and I see some PHPCS issue below:

    āžœ  content_editing_message git:(55518f7) curl https://git.drupalcode.org/project/content_editing_message/-/merge_requests/3.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  8506    0  8506    0     0  14703      0 --:--:-- --:--:-- --:--:-- 14896
    patching file README.md
    patching file content_editing_message.module
    patching file 'src/Controller/ContentEditingMessageListBuilder.php'
    patching file 'src/Form/ContentEditingMessageDeleteForm.php'
    patching file 'src/Form/ContentEditingMessageFormBase.php'
    patching file 'tests/src/Unit/ContentEditingMessageTest.php'
    āžœ  content_editing_message git:(55518f7) āœ— ..
    āžœ  contrib git:(master) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml content_editing_message
    
    FILE: ...web/modules/contrib/content_editing_message/content_editing_message.module
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     82 | ERROR | All functions defined in a module file must be prefixed with the
        |       | module's name, found "append_message" but expected
        |       | "content_editing_message_append_message"
    --------------------------------------------------------------------------------
    
    
    FILE: ...contrib/content_editing_message/src/Form/ContentEditingMessageFormBase.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AND 2 WARNINGS AFFECTING 3 LINES
    --------------------------------------------------------------------------------
     194 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency
         |         |     injection instead
     301 | WARNING | [x] A comma should follow the last multiline array item.
         |         |     Found: )
     313 | ERROR   | [ ] The array declaration extends to column 125 (the limit is
         |         |     80). The array content should be split up over multiple
         |         |     lines
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    Time: 266ms; Memory: 12MB
    
    āžœ  contrib git:(master) āœ— 
    

    Retaining this to needs review for others to give feedback.

  • First commit to issue fork.
  • Hi all!

    The issues have been fixed and the MR merged. Will be on the next release.
    Thank you for you contributions!

Production build 0.71.5 2024