Fix the issues reported by phpcs

Created on 12 July 2022, over 2 years ago
Updated 1 June 2024, 7 months ago

Problem/Motivation

Drupal coding standard issue on PHPCS. Need to resolve coding standard issue.

FILE: ./mailsystem_8.x-4.x/tests/modules/mailsystem_test/src/Plugin/Mail/DummySender.php
 29 | WARNING | [x] 'TODO: Implement format() method.' should match the format '@todo Fix problem X here.'

FILE: ./mailsystem_8.x-4.x/tests/modules/mailsystem_test/src/Plugin/Mail/Dummy.php
 22 | WARNING | [x] 'TODO: Implement format() method.' should match the format '@todo Fix problem X here.'
 35 | WARNING | [x] 'TODO: Implement mail() method.' should match the format '@todo Fix problem X here.'

FILE: ./mailsystem_8.x-4.x/tests/modules/mailsystem_test/src/Plugin/Mail/DummyFormatter.php
 22 | WARNING | [x] 'TODO: Implement format() method.' should match the format '@todo Fix problem X here.'

FILE: ./mailsystem_8.x-4.x/mailsystem.module
 32 | WARNING | [x] '@todo: Reimplement this as soon as module port or similar module is around.' should match the format '@todo
    |         |     Fix problem X here.'

FILE: ./mailsystem_8.x-4.x/src/MailsystemManager.php
 142 | ERROR   | [ ] The array declaration extends to column 94 (the limit is 80). The array content should be split up over
     |         |     multiple lines
 166 | WARNING | [x] '@todo: Reimplement this as soon as module port or similar module is around.' should match the format '@todo
     |         |     Fix problem X here.'

FILE: ./mailsystem_8.x-4.x/src/Form/AdminForm.php
 242 | ERROR | The array declaration extends to column 99 (the limit is 80). The array content should be split up over multiple
     |       | lines
 242 | ERROR | The array declaration extends to column 155 (the limit is 80). The array content should be split up over multiple
     |       | lines
 248 | ERROR | The array declaration extends to column 123 (the limit is 80). The array content should be split up over multiple
     |       | lines
 295 | ERROR | The array declaration extends to column 96 (the limit is 80). The array content should be split up over multiple
     |       | lines
 296 | ERROR | The array declaration extends to column 90 (the limit is 80). The array content should be split up over multiple
     |       | lines
 300 | ERROR | The array declaration extends to column 108 (the limit is 80). The array content should be split up over multiple
     |       | lines
 308 | ERROR | The array declaration extends to column 110 (the limit is 80). The array content should be split up over multiple
     |       | lines

Steps to reproduce

Run phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig ./.

Proposed resolution

Fix the reported issues.

📌 Task
Status

Needs work

Version

4.0

Component

Code

Created by

🇮🇳India arunkumark Coimbatore

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.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    -    $config_key = $this->getModuleKeyConfigPrefix($form_state->getValue(['custom', 'custom_module']), $form_state->getValue(['custom', 'custom_module_key']));
    +    $config_key = $this
    +      ->getModuleKeyConfigPrefix(
    +      $form_state->getValue(['custom', 'custom_module']),
    +      $form_state->getValue(['custom', 'custom_module_key']));

    The coding standards describe exactly which lines need to be long less than 80 characters. There are many exceptions that needs to be observed. Writing the variable containing the object in a line and the called method in a new line does not make the code easier to read.

    -    if (($form_state->getValue(['custom', 'custom_formatter']) == '') && ($form_state->getValue(['custom', 'custom_sender']) == '')) {
    +    if (($form_state->getValue(['custom', 'custom_formatter']) == '') &&
    +    ($form_state->getValue(['custom', 'custom_sender']) == '')) {
           $form_state->setErrorByName('custom][custom_formatter', $this->t('At least a formatter or sender is required.'));

    I think that is given as example of how not to split a statement, in the coding standards.

     name: Mailsystem Test
     type: module
    +description: Mailsystem test module
     package: Testing
     hidden: true

    Is the description for a test module necessary, given that module is hidden?

       requirements:
    +  # Please add comment manually here.
         _access: 'TRUE'

    That is not a necessary comment, which does not describe anything about the following line.

  • 🇮🇳India kkalashnikov Ghaziabad, India

    Include comment #9 in current patch.

  • Status changed to Needs review almost 2 years ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Assigned to himanshu_jhaloya
  • Issue was unassigned.
  • 🇮🇳India himanshu_jhaloya Indore

    #10 patch applied cleanly, no issue found, Reroll the patch #10 small change.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    Implementing hook_help() is not part of this issue, since phpcs has not reported anything about that. The last patch contains off-topic changes.

  • Status changed to Needs work almost 2 years ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    +    if (($form_state->getValue(['custom', 'custom_formatter']) == '')
    +      &&($form_state->getValue(['custom', 'custom_sender']) == '')) {

    I think the Drupal coding standards uses code similar to that to show how not to split a if statement.

    +    $config->set('defaults.sender',
    +    $form_state->getValue(['mailsystem', 'default_sender']));

    I am not sure that line should be split too. In the case it is, the second line should be indented, to make more evident it is part of the previous line.

    -          foreach ([MailsystemManager::MAILSYSTEM_TYPE_FORMATTING, MailsystemManager::MAILSYSTEM_TYPE_SENDING] as $type) {
    +          foreach ([MailsystemManager::MAILSYSTEM_TYPE_FORMATTING,
    +            MailsystemManager::MAILSYSTEM_TYPE_SENDING,
    +          ] as $type) {
    

    That seems more code formatted as per PSR12 coding standards.

  • Merge request !8rerole the patch → (Open) created by himanshu_jhaloya
  • Status changed to Needs review almost 2 years ago
  • Status changed to Needs work almost 2 years ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    +    if ($form_state->hasValue(['custom', 'modules']) && is_array(
    +      $form_state->getValue(['custom', 'modules']))) {
    
    -          foreach ([MailsystemManager::MAILSYSTEM_TYPE_FORMATTING, MailsystemManager::MAILSYSTEM_TYPE_SENDING] as $type) {
    +          foreach ([MailsystemManager::MAILSYSTEM_TYPE_FORMATTING, MailsystemManager::MAILSYSTEM_TYPE_SENDING,
    +          ] as $type) {
    

    It is still better to leave the control statement on a single line.

  • Assigned to elber
  • 🇧🇷Brazil elber Brazil

    I will work on it.

  • 🇧🇷Brazil elber Brazil

    Hi I fixed the phpcs errors and I did the rebase, please revise.

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • 🇮🇳India Yashaswi18

    Hello, after checking out to the branch and running the phpcs command I found one issue.

    phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,js,yml mailsystem/
    
    FILE: /home/yashaswi/contribs/mailsystem/tests/modules/mailsystem_test/mailsystem_test.info.yml
    -----------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------
     1 | WARNING | "Description" property is missing in the info.yml file
    -----------------------------------------------------------------------------------------------
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update 9 months ago
    4 pass
  • 🇫🇷France Florent Jousseaume

    Fixing phpcs warning

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update 9 months ago
    4 pass
  • Status changed to RTBC 7 months ago
  • 🇵🇭Philippines roberttabigue

    Hi @arunkumark,

    I have reviewed the changes and confirmed that Patch #23 was applied cleanly to the Mail System module against 8.x-4.x on Drupal 10.

    And all PHPCS errors have been fixed.

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

    Please see the attached file for reference.

    I'm moving this now to ‘RTBC’.

    Thank you!

  • First commit to issue fork.
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.3 & MySQL 5.7
    last update 7 months ago
    PHPLint Failed
  • Status changed to Needs work 7 months ago
  • 🇨🇭Switzerland berdir Switzerland
Production build 0.71.5 2024