GitLab Ci reports the following PHP_CodeSniffer warnings/errors, which should be fixed.

FILE: ...ntent_editing_message-3362033/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:
    |         |     ] (Drupal.Arrays.Array.CommaLastItem)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...content_editing_message-3362033/src/Form/ContentEditingMessageFormBase.php
--------------------------------------------------------------------------------
FOUND 8 ERRORS AFFECTING 5 LINES
--------------------------------------------------------------------------------
 195 | ERROR | [x] Expected 1 space after FOREACH keyword; 0 found
     |       |     (Drupal.ControlStructures.ControlSignature.SpaceAfterKeyword)
 195 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
     |       |     (Drupal.ControlStructures.ControlSignature.SpaceAfterCloseParenthesis)
 242 | ERROR | [x] Spaces must be used to indent lines; tabs are not allowed
     |       |     (Generic.WhiteSpace.DisallowTabIndent.TabsUsed)
 242 | ERROR | [x] Line indented incorrectly; expected 6 spaces, found 3
     |       |     (Drupal.WhiteSpace.ScopeIndent.IncorrectExact)
 242 | ERROR | [x] Object operator not indented correctly; expected 6 spaces
     |       |     but found 3 (Drupal.WhiteSpace.ObjectOperatorIndent.Indent)
 243 | ERROR | [x] Object operator not indented correctly; expected 3 spaces
     |       |     but found 6 (Drupal.WhiteSpace.ObjectOperatorIndent.Indent)
 296 | ERROR | [ ] The array declaration extends to column 215 (the limit is
     |       |     120). The array content should be split up over multiple
     |       |     lines (Drupal.Arrays.Array.LongLineDeclaration)
 301 | ERROR | [ ] The array declaration extends to column 213 (the limit is
     |       |     120). The array content should be split up over multiple
     |       |     lines (Drupal.Arrays.Array.LongLineDeclaration)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...ntent_editing_message-3362033/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.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...diting_message-3362033/src/Controller/ContentEditingMessageListBuilder.php
--------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 1 LINE
--------------------------------------------------------------------------------
 70 | ERROR | [x] Expected 1 space after IF keyword; 0 found
    |       |     (Drupal.ControlStructures.ControlSignature.SpaceAfterKeyword)
 70 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
    |       |     (Drupal.ControlStructures.ControlSignature.SpaceAfterCloseParenthesis)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
FILE: ...ules/custom/content_editing_message-3362033/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.
     |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)
  66 | ERROR | [x] Expected 1 space after IF keyword; 0 found
     |       |     (Drupal.ControlStructures.ControlSignature.SpaceAfterKeyword)
  66 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
     |       |     (Drupal.ControlStructures.ControlSignature.SpaceAfterCloseParenthesis)
  70 | ERROR | [x] Expected newline after closing brace
     |       |     (Drupal.ControlStructures.ControlSignature.NewlineAfterCloseBrace)
  70 | ERROR | [x] Expected 1 space after ELSEIF keyword; 0 found
     |       |     (Drupal.ControlStructures.ControlSignature.SpaceAfterKeyword)
  70 | ERROR | [x] Expected 1 space after closing parenthesis; found 0
     |       |     (Drupal.ControlStructures.ControlSignature.SpaceAfterCloseParenthesis)
  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"
     |       |     (Drupal.NamingConventions.ValidFunctionName.InvalidPrefix)
  81 | ERROR | [x] Expected 1 space before opening brace; found 0
     |       |     (Drupal.Functions.MultiLineFunctionDeclaration.SpaceBeforeBrace)
 110 | ERROR | [x] Expected 1 blank line after function; 0 found
     |       |     (Squiz.WhiteSpace.FunctionSpacing.After)
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------
Time: 181ms; Memory: 6MB

 
 

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

paraderojether created an issue. See original summary.

paraderojether’s picture

Assigned: paraderojether » Unassigned
Status: Active » Needs review
StatusFileSize
new3.41 KB

Created a patch to fix the issues reported by phpcs.

Please review.
Thank You.

schillerm’s picture

Status: Needs review » Reviewed & tested by the community

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.

jay jangid’s picture

Assigned: Unassigned » jay jangid
jay jangid’s picture

Assigned: jay jangid » Unassigned
Status: Reviewed & tested by the community » Needs review
StatusFileSize
new42.47 KB

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

paraderojether’s picture

StatusFileSize
new3.41 KB

I updated the patch.

Please review again.
Thank You.

avpaderno’s picture

Status: Needs review » Needs work
-      $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.

sakthi_dev’s picture

Status: Needs work » Needs review
StatusFileSize
new3.43 KB

Created patch bases on #7. Please review,

raveen_thakur51’s picture

StatusFileSize
new20.89 KB

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.

silvi.addweb’s picture

StatusFileSize
new6.91 KB

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
-------------------------------------------------------------------------------------------------------

And i have fixed all the issues reported by phpcs.

roberttabigue’s picture

Status: Needs review » Needs work

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!

avpaderno’s picture

Issue summary: View changes
avpaderno’s picture

Status: Needs work » Needs review
clarkssquared’s picture

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.

sovimi made their first commit to this issue’s fork.

sovimi’s picture

Status: Needs review » Fixed

Hi all!

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

Status: Fixed » Closed (fixed)

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