Fix the errors/warnings reported by PHP_CodeSniffer

Created on 10 August 2022, over 2 years ago
Updated 5 June 2024, 7 months ago

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
📌 Task
Status

RTBC

Version

1.0

Component

Code

Created by

🇮🇳India Harsh panchal

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

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇩🇪Germany mxh Offenburg

    Formatting is still not following Drupal coding standards.

  • 🇮🇹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.

  • First commit to issue fork.
  • Status changed to Needs review almost 2 years ago
  • 🇧🇷Brazil elber Brazil

    Hi i fixed the phpcs errors please revise.

  • Status changed to Needs work almost 2 years ago
  • 🇩🇪Germany mxh Offenburg

    No, see #17 and #18.

  • 🇧🇷Brazil elber Brazil

    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?

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

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

  • 🇧🇷Brazil elber Brazil

    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?

  • 🇩🇪Germany mxh Offenburg

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

  • 🇧🇷Brazil elber Brazil

    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 do you find the phpcs errors you can let me know it wil be a pleasure keeping working in this issue, thank you!

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

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

  • 🇮🇳India zkhan.aamir

    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
    
  • Status changed to Needs review 11 months ago
  • 🇮🇳India sakthi_dev

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

  • Status changed to Needs work 11 months ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    -  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.

  • Status changed to Needs review 11 months ago
  • 🇮🇳India sakthi_dev

    Addressed the comment #38. Please review.

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

  • Status changed to Needs work 11 months ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

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

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    apaderno changed the visibility of the branch coding_standard to hidden.

  • Status changed to Needs review 11 months ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇮🇳India zkhan.aamir

    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
    
  • First commit to issue fork.
  • 🇮🇳India pray_12

    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
    --------------------------------------------------------------------------------------------------------------------------------------
    
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    Given that the code in the EcaPluginForm.php file is the following line 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';
            }
    
  • Status changed to RTBC 7 months ago
  • 🇮🇳India dev16.addweb

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

Production build 0.71.5 2024