Running phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig shows the following errors/warnings which should be fixed.

FILE: ./src/Controller/CoreModeller.php
----------------------------------------------------------------------
FOUND 21 ERRORS AFFECTING 20 LINES
----------------------------------------------------------------------
  55 | ERROR | [ ] Parameter $condition_manager is not described in
     |       |     comment
  62 | ERROR | [ ] Doc comment for parameter $condition does not
     |       |     match actual variable name $form_builder
  62 | ERROR | [x] Parameter comment must be on the next line
 107 | ERROR | [x] Missing function doc comment
 124 | ERROR | [x] A unary operator statement must not be followed by
     |       |     a space
 136 | ERROR | [x] Missing function doc comment
 150 | ERROR | [x] Newline required after opening brace
 155 | ERROR | [x] Missing function doc comment
 169 | ERROR | [x] Newline required after opening brace
 174 | ERROR | [x] Missing function doc comment
 191 | ERROR | [x] A unary operator statement must not be followed by
     |       |     a space
 203 | ERROR | [x] Missing function doc comment
 217 | ERROR | [x] Newline required after opening brace
 222 | ERROR | [x] Missing function doc comment
 236 | ERROR | [x] Newline required after opening brace
 241 | ERROR | [x] Missing function doc comment
 258 | ERROR | [x] A unary operator statement must not be followed by
     |       |     a space
 270 | ERROR | [x] Missing function doc comment
 284 | ERROR | [x] Newline required after opening brace
 289 | ERROR | [x] Missing function doc comment
 303 | ERROR | [x] Newline required after opening brace
----------------------------------------------------------------------
PHPCBF CAN FIX THE 19 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Form/EcaForm.php
----------------------------------------------------------------------
FOUND 5 ERRORS AND 1 WARNING AFFECTING 6 LINES
----------------------------------------------------------------------
 955 | WARNING | [ ] Avoid backslash escaping in translatable strings
     |         |     when possible, use '' quotes instead
 958 | ERROR   | [x] Array indentation error, expected 12 spaces but
     |         |     found 14
 959 | ERROR   | [x] Array indentation error, expected 12 spaces but
     |         |     found 14
 960 | ERROR   | [x] Array closing indentation error, expected 10
     |         |     spaces but found 12
 961 | ERROR   | [x] Array closing indentation error, expected 8
     |         |     spaces but found 10
 962 | ERROR   | [x] Line indented incorrectly; expected 8 spaces,
     |         |     found 10
----------------------------------------------------------------------
PHPCBF CAN FIX THE 5 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ./src/Form/EcaPluginDeleteForm.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 82 | WARNING | Avoid backslash escaping in translatable strings when
    |         | possible, use "" quotes instead
----------------------------------------------------------------------


FILE: ./src/Form/EcaPluginForm.php
----------------------------------------------------------------------
FOUND 5 ERRORS AND 2 WARNINGS AFFECTING 7 LINES
----------------------------------------------------------------------
  177 | ERROR   | [ ] Doc comment for parameter $token_browser does
      |         |     not match actual variable name $config_array
  179 | ERROR   | [ ] Doc comment for parameter $module_handler does
      |         |     not match actual variable name $config_array
  260 | WARNING | [ ] Avoid backslash escaping in translatable
      |         |     strings when possible, use "" quotes instead
  466 | ERROR   | [ ] Concatenating translatable strings is not
      |         |     allowed, use placeholders instead and only one
      |         |     string literal
  607 | WARNING | [ ] Avoid backslash escaping in translatable
      |         |     strings when possible, use "" quotes instead
 1040 | ERROR   | [x] Missing function doc comment
 1048 | ERROR   | [x] Missing function doc comment
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 341ms; Memory: 18MB

Issue fork eca_cm-3302844

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

Harsh panchal created an issue. See original summary.

Harsh panchal’s picture

Assigned: Harsh panchal » Unassigned
Category: Task » Bug report
Status: Active » Needs review
StatusFileSize
new12.09 KB

I have fixed Drupal standard coding issue and providing a patch.

dharti patel’s picture

Assigned: Unassigned » dharti patel
dharti patel’s picture

Assigned: dharti patel » Unassigned
StatusFileSize
new15.19 KB

I've reviewed and applied the #2 patch but after applying the patch facing the below errors.

FILE: /home/drupal/myproject/eca_cm/eca_cm.module
------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
------------------------------------------------------------
  1 | ERROR | [x] Missing file doc comment
 49 | ERROR | [x] Use "elseif" in place of "else if"
------------------------------------------------------------

FILE: /home/drupal/myproject/eca_cm/src/Form/EcaPluginForm.php
------------------------------------------------------------
FOUND 4 ERRORS AND 1 WARNING AFFECTING 5 LINES
------------------------------------------------------------
 259 | WARNING | Avoid backslash escaping in translatable strings when possible, use "" quotes instead
 686 | ERROR   | The array declaration extends to column 120 (the limit is 80). The array content should be split up over multiple lines
 815 | ERROR   | The array declaration extends to column 104 (the limit is 80). The array content should be split up over multiple lines
 818 | ERROR   | The array declaration extends to column 108 (the limit is 80). The array content should be split up over multiple lines
 821 | ERROR   | The array declaration extends to column 105 (the limit is 80). The array content should be split up over multiple lines
------------------------------------------------------------

I have created a patch to fix the above issue.
Kindly review the patch.

Thanks!

mxh’s picture

Status: Needs review » Needs work

Patch is not fulfilling Drupal coding standards. Also, added stuff like this one

+/**
+ * @file
+ * Description message.
+ */

is no descriptive comment, and therefore is less useful than having no comment. Added comments need to make sense and add helpful information.

juancec’s picture

Status: Needs work » Needs review
StatusFileSize
new14.81 KB

Hi, I just did an adjustment to #4 patch, so I'm providing an updated patch with all the PHPCS issues fixed.
Kindly review the patch and let me know your feedback =)

atul_ghate’s picture

Assigned: Unassigned » atul_ghate

Hi,
i will review this patch.

atul_ghate’s picture

Assigned: atul_ghate » Unassigned

Your patch is applied cleanly and can be moved to RTBC.

/var/www/html/oslando/web $ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml --encoding=utf-8 -p modules/contrib/eca_cm/ --ignore=node_module
................ 16 / 16 (100%)

Time: 1.24 secs; Memory: 20MB

juancec’s picture

Status: Needs review » Reviewed & tested by the community
mxh’s picture

Status: Reviewed & tested by the community » Needs work

Formatting is still not following Drupal coding standards.

nitin_lama’s picture

Assigned: Unassigned » nitin_lama
nitin_lama’s picture

Assigned: nitin_lama » Unassigned
StatusFileSize
new31.25 KB

@mxh, by formatting did you mean the function comments ? Because i see no pending CS issues in the module.

no_image

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

vishaljd’s picture

Assigned: Unassigned » vishaljd
Issue tags: -

vishaljd’s picture

Assigned: vishaljd » Unassigned
Status: Needs work » Needs review
mxh’s picture

Status: Needs review » Needs work

Formatting is still not following Drupal coding standards.

avpaderno’s picture

Title: Drupal standard coding issue » Fix the issues reported by phpcs
Category: Bug report » Task
Issue tags: +Coding standards, +Needs issue summary update

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.

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

elber’s picture

Status: Needs work » Needs review

Hi I fixed the phpcs errors please revise.

mxh’s picture

Status: Needs review » Needs work

No, see #17 and #18.

elber’s picture

Hi I ran the follow commands phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml phpcs --standard=DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml after that I made the changes I didn't see phpcs errors anymore, @mxh could you please show me which the errors you are seeing?

avpaderno’s picture

@elber See the previous comments. The issue summary is not even reporting which phpcs coding standards have been used.

elber’s picture

Hi I saw the previous comments and I didn't understand what is wrong with this issue because phpcs errors has been already fixed, please can you tell me what is wrong?

mxh’s picture

By looking into the suggested merge request (which already takes time BTW), I can immedtiately see that your changes are not following Drupal coding standards. I don't take the time to tell what exactly is wrong. I can assure you that the code changes in the merge request is wrong regards Drupal coding standards. Read the guidelines of Drupal coding standards, understand them, look at your suggested merge request and then you'll see what's wrong.

elber’s picture

Hi I ran drupal phpcs commands to check phpcs erros as I said in the comment #23 and I didn't have erros in output, when you find the phpcs errors you can let me know it wil be a pleasure keeping working in this issue, thank you!

indrapatil’s picture

Issue summary: View changes
avpaderno’s picture

mahima_mathur23’s picture

Priority: Normal » Minor
Shreyas gowda’s picture

StatusFileSize
new16.53 KB
avpaderno’s picture

bindu r’s picture

StatusFileSize
new14.76 KB
avpaderno’s picture

Since a MR has been provided, it would be better to keep using that MR.

nisha_j’s picture

StatusFileSize
new12.75 KB
zkhan.aamir’s picture

Hi,

The patch #35 applied succesfully.

Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules/contrib/eca_cm (1.0.x)
$ curl https://www.drupal.org/files/issues/2023-11-29/phpcs-fixes-3302844-35.patch | patch -p1
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 13061  100 13061    0     0  13553      0 --:--:-- --:--:-- --:--:-- 13576
patching file src/Controller/CoreModeller.php
patching file src/Form/EcaForm.php
patching file src/Form/EcaPluginDeleteForm.php
patching file src/Form/EcaPluginForm.php

But still there are some errors

Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules/contrib
$ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,js,yml eca_cm/

FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\contrib\eca_cm\src\Form\EcaForm.php
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------
 587 | ERROR | The array declaration extends to column 82 (the limit is 80). The array content should be split up over multiple lines
--------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\contrib\eca_cm\src\Form\EcaPluginForm.php
---------------------------------------------------------------------------------------------------------------------------------------
FOUND 7 ERRORS AFFECTING 7 LINES
---------------------------------------------------------------------------------------------------------------------------------------
 314 | ERROR | The array declaration extends to column 89 (the limit is 80). The array content should be split up over multiple lines
 714 | ERROR | The array declaration extends to column 88 (the limit is 80). The array content should be split up over multiple lines
 717 | ERROR | The array declaration extends to column 111 (the limit is 80). The array content should be split up over multiple lines
 747 | ERROR | The array declaration extends to column 120 (the limit is 80). The array content should be split up over multiple lines
 876 | ERROR | The array declaration extends to column 104 (the limit is 80). The array content should be split up over multiple lines
 879 | ERROR | The array declaration extends to column 108 (the limit is 80). The array content should be split up over multiple lines
 882 | ERROR | The array declaration extends to column 105 (the limit is 80). The array content should be split up over multiple lines
---------------------------------------------------------------------------------------------------------------------------------------

Time: 1.1 secs; Memory: 20MB
sakthi_dev’s picture

Status: Needs work » Needs review
StatusFileSize
new16 KB

Leaving 314 as it is because it is a if clause. Please review.

avpaderno’s picture

Status: Needs review » Needs work
-  public function __construct(Modellers $modeller_services, Event $event_manager, Condition $condition_manager, Action $action_manager, FormBuilderInterface $form_builder) {
+  public function __construct(
+  Modellers $modeller_services,
+  Event $event_manager,
+  // Corrected variable name.
+  Condition $condition_manager,
+  Action $action_manager,
+  FormBuilderInterface $form_builder
+  ) {

Function/method declarations are written on a single line. There is no need to add a comment to describe what change has been introduced.

     $this->eventManager = $event_manager;
+    // Updated variable assignment.
     $this->conditionManager = $condition_manager;

That comment is not necessary and must be removed.

+  /**
+   * {@inheritdoc}
+   */
   public function addEvent(Eca $eca, string $eca_event_plugin): array {

That method is not inherited from the parent class. Its documentation comment must be different.

-    foreach ($plugins['conditions.' . $config_key] as $plugin) {}
+    foreach ($plugins['conditions.' . $config_key] as $plugin) {
+    }

An empty loop can be simply be removed.

Since an issue fork has been created, let's continue to use it.

sakthi_dev’s picture

Status: Needs work » Needs review
StatusFileSize
new15.21 KB

Addressed the comment #38. Please review.

nisha_j’s picture

Hi, The changes suggested in comment #38 has been incorporated in the patch #39.
Thankyou.

avpaderno’s picture

Status: Needs review » Needs work

Since a issue fork has been already created, let's keep using it.

avpaderno’s picture

Title: Fix the issues reported by phpcs » Fix the errors/warnings reported by PHP_CodeSniffer
Issue summary: View changes

apaderno changed the visibility of the branch coding_standard to hidden.

avpaderno’s picture

Status: Needs work » Needs review
zkhan.aamir’s picture

Hi,

MR #43 applied successfully.

Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules/contrib/eca_cm (1.0.x)
$ curl https://git.drupalcode.org/project/eca_cm/-/merge_requests/7.diff | patch -p1
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 16264    0 16264    0     0  34845      0 --:--:-- --:--:-- --:--:-- 35051
patching file src/Controller/CoreModeller.php
patching file src/Form/EcaPluginDeleteForm.php
patching file src/Form/EcaPluginForm.php

There are still some errors

Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules/contrib
$ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,js,yml eca_cm/

FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\contrib\eca_cm\src\Form\EcaForm.php
----------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
----------------------------------------------------------------------------------------------------------------------------------------
 587 | ERROR   | The array declaration extends to column 82 (the limit is 80). The array content should be split up over multiple lines
 955 | WARNING | Avoid backslash escaping in translatable strings when possible, use '' quotes instead
----------------------------------------------------------------------------------------------------------------------------------------


FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\contrib\eca_cm\src\Form\EcaPluginForm.php
---------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
---------------------------------------------------------------------------------------------------------------------------------------
  314 | ERROR | The array declaration extends to column 89 (the limit is 80). The array content should be split up over multiple lines
 1071 | ERROR | Doc comment is empty
 1082 | ERROR | Doc comment is empty
---------------------------------------------------------------------------------------------------------------------------------------

Time: 1.01 secs; Memory: 20MB

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

pray_12’s picture

Hi,
The errors and warnings from #45 have been successfully addressed;
however, there are still some remaining errors and warnings that need attention.


FILE: .../eca_cm/src/Form/EcaForm.php
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------
 587 | ERROR | The array declaration extends to column 82 (the limit is 80). The array content should be split up over multiple lines
--------------------------------------------------------------------------------------------------------------------------------------


FILE: .../eca_cm/src/Form/EcaPluginForm.php
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------
 314 | ERROR | The array declaration extends to column 89 (the limit is 80). The array content should be split up over multiple lines
--------------------------------------------------------------------------------------------------------------------------------------
avpaderno’s picture

Given that the code in the EcaPluginForm.php file is the following one and that control structure conditions should not be wrapped into multiple lines, it is not possible to change it.

        if (isset($elements['#type']) && in_array($elements['#type'], ['number', 'email'], TRUE)) {
          $elements['#original_form_type'] = $elements['#type'];
          $elements['#type'] = 'textfield';
        }
silvi.addweb’s picture

Status: Needs review » Reviewed & tested by the community

Hello,
I applied the patch provided in !7 for the version 1.0.x-dev, the patch applied successfully.