Fix the issues reported by phpcs

Created on 3 March 2023, over 1 year ago
Updated 11 July 2024, 5 months ago

GitLab CI reports PHP_CodeSniffer errors/warnings which should be fixed.

 7 | ERROR | [x] Use statements should be sorted alphabetically. The first
   |       |     wrong one is Drupal\Core\Block\BlockPluginInterface.
   |       |     (SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses.IncorrectlyOrderedUses)

 

📌 Task
Status

RTBC

Version

2.0

Component

Code

Created by

🇮🇳India AditiVB

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.

  • Issue created by @AditiVB
  • 🇮🇳India AditiVB

    Found below issue . I will work on it and fix .

  • Merge request !6Issue #3345822: phpcs issue → (Open) created by Unnamed author
  • Issue was unassigned.
  • 🇮🇳India chetan 11

    chetan 11 made their first commit to this issue’s fork.

  • Merge request !10Issue #3345822: phpcs issue → (Open) created by chetan 11
  • Status changed to Needs review about 1 year ago
  • 🇮🇳India chetan 11

    Hi @Aditi Saraf
    I have fixed the above issue in modal blocks module & raised the MR for the same.
    Thanks

  • Status changed to Needs work about 1 year ago
  • 🇵🇭Philippines clarkssquared

    Hi chetan 11,

    I applied your MR !10 but there are still many PHPCS errors that needs to be fixed,

    ➜  modal_blocks git:(master) ✗ curl https://git.drupalcode.org/project/modal_blocks/-/merge_requests/10.diff | patch -p1  
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 11755    0 11755    0     0  22597      0 --:--:-- --:--:-- --:--:-- 22914
    patching file 'js/modal_blocks.js'
    patching file 'src/Plugin/Block/ModalBlock.php'
    ➜  modal_blocks git:(master) ✗ ..
    ➜  contrib git:(master) ✗ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml modal_blocks 
    
    FILE: .../Projects/d9/d9-local/web/modules/contrib/modal_blocks/modal_blocks.module
    --------------------------------------------------------------------------------
    FOUND 4 ERRORS AFFECTING 2 LINES
    --------------------------------------------------------------------------------
      3 | ERROR | [x] You must use "/**" style comments for a file comment
     23 | ERROR | [x] The open comment tag must be the only content on the line
     23 | ERROR | [x] Doc comment short description must be on the first line
     23 | ERROR | [ ] Doc comment short description must start with a capital
        |       |     letter
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    
    FILE: ...ing-subing/Projects/d9/d9-local/web/modules/contrib/modal_blocks/README.md
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     39 | WARNING | Line exceeds 80 characters; contains 87 characters
    --------------------------------------------------------------------------------
    
    
    FILE: ...rojects/d9/d9-local/web/modules/contrib/modal_blocks/modal_blocks.info.yml
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     1 | WARNING | Remove "project" from the info file, it will be added by
       |         | drupal.org packaging automatically
     1 | WARNING | Remove "datestamp" from the info file, it will be added by
       |         | drupal.org packaging automatically
     1 | WARNING | Remove "version" from the info file, it will be added by
       |         | drupal.org packaging automatically
    --------------------------------------------------------------------------------
    
    
    FILE: .../d9-local/web/modules/contrib/modal_blocks/src/Plugin/Block/ModalBlock.php
    --------------------------------------------------------------------------------
    FOUND 103 ERRORS AND 2 WARNINGS AFFECTING 97 LINES
    --------------------------------------------------------------------------------
       7 | ERROR   | [x] Use statements should be sorted alphabetically. The first
         |         |     wrong one is Drupal\Core\Block\BlockPluginInterface.
      21 | ERROR   | [x] Opening brace should be on the same line as the
         |         |     declaration
      23 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
      26 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
      27 | ERROR   | [x] Opening brace should be on the same line as the
         |         |     declaration
      28 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
      29 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
      31 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
      32 | ERROR   | [x] Array indentation error, expected 10 spaces but found 8
      33 | ERROR   | [x] Array indentation error, expected 10 spaces but found 8
      34 | ERROR   | [x] Array indentation error, expected 10 spaces but found 8
      35 | ERROR   | [x] Array indentation error, expected 10 spaces but found 8
      36 | ERROR   | [x] Array indentation error, expected 10 spaces but found 8
      36 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE"
         |         |     but found "true"
      39 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
      40 | ERROR   | [x] Array indentation error, expected 10 spaces but found 8
      41 | ERROR   | [x] Array indentation error, expected 10 spaces but found 8
      42 | ERROR   | [x] Array indentation error, expected 10 spaces but found 8
      43 | ERROR   | [x] Array indentation error, expected 10 spaces but found 8
      44 | ERROR   | [x] Array indentation error, expected 10 spaces but found 8
      45 | ERROR   | [x] Array indentation error, expected 10 spaces but found 8
      46 | ERROR   | [x] Array indentation error, expected 10 spaces but found 8
      47 | ERROR   | [x] Array indentation error, expected 10 spaces but found 8
      48 | ERROR   | [x] Array indentation error, expected 10 spaces but found 8
      50 | ERROR   | [x] Array indentation error, expected 10 spaces but found 8
      51 | ERROR   | [x] Array indentation error, expected 10 spaces but found 8
      51 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE"
         |         |     but found "true"
      54 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
      55 | ERROR   | [x] Array indentation error, expected 10 spaces but found 8
      56 | ERROR   | [x] Array indentation error, expected 10 spaces but found 8
      57 | ERROR   | [x] Array indentation error, expected 10 spaces but found 8
      58 | ERROR   | [x] Array indentation error, expected 10 spaces but found 8
      59 | ERROR   | [x] Array indentation error, expected 10 spaces but found 8
      60 | ERROR   | [x] Array indentation error, expected 10 spaces but found 8
      60 | ERROR   | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE"
         |         |     but found "true"
      63 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
      64 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
      65 | ERROR   | [x] Array indentation error, expected 10 spaces but found 8
      66 | ERROR   | [x] Array indentation error, expected 10 spaces but found 8
      69 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
      70 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
      72 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
      75 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
      76 | ERROR   | [x] Opening brace should be on the same line as the
         |         |     declaration
      77 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
      78 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
      79 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
      80 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
      81 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
      83 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
      86 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
      87 | ERROR   | [x] Opening brace should be on the same line as the
         |         |     declaration
      88 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
      90 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
      91 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 16
      92 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
      94 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
      95 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
      96 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
      97 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
      98 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
      99 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
     100 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
     101 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
     103 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
     106 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
     107 | ERROR   | [x] Opening brace should be on the same line as the
         |         |     declaration
     108 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
     109 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
     110 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
     111 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
     112 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
     113 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
     115 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
     116 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 8
     117 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 12
     118 | ERROR   | [x] Case breaking statements must be followed by a single
         |         |     blank line
     118 | ERROR   | [x] Case breaking statement indented incorrectly; expected 10
         |         |     spaces, found 12
     119 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 8
     120 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 12
     121 | ERROR   | [x] Case breaking statements must be followed by a single
         |         |     blank line
     121 | ERROR   | [x] Case breaking statement indented incorrectly; expected 10
         |         |     spaces, found 12
     122 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 8
     123 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 12
     124 | ERROR   | [x] Case breaking statements must be followed by a single
         |         |     blank line
     124 | ERROR   | [x] Case breaking statement indented incorrectly; expected 10
         |         |     spaces, found 12
     125 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 8
     126 | ERROR   | [x] Line indented incorrectly; expected 8 spaces, found 12
     127 | ERROR   | [x] Case breaking statement indented incorrectly; expected 10
         |         |     spaces, found 12
     128 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
     130 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
     131 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
     131 | WARNING | [ ] Block::load calls should be avoided in classes, use
         |         |     dependency injection instead
     132 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
     132 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency
         |         |     injection instead
     133 | ERROR   | [x] Object operator not indented correctly; expected 14 spaces
         |         |     but found 16
     135 | ERROR   | [x] Line indented incorrectly; expected 6 spaces, found 12
     136 | ERROR   | [x] Array indentation error, expected 14 spaces but found 12
     137 | ERROR   | [x] Array indentation error, expected 14 spaces but found 12
     139 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
     141 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
     142 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
     143 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
     145 | ERROR   | [x] Line indented incorrectly; expected 4 spaces, found 8
     146 | ERROR   | [x] Line indented incorrectly; expected 2 spaces, found 4
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 103 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    Time: 289ms; Memory: 10MB
    
    ➜  contrib git:(master) ✗ 
    
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    A summary must describe what needs to be changed, and eventually why. A screenshot is not sufficient, even in the case a patch/MR is provided.
    In the case of bug reports, the steps to reproduce the bug should be provided too. In the case of coding standards issues found using an automatic tool, the report given by that tool must be quoted too, including the arguments passed to that tool, if it is a command line tool.

  • First commit to issue fork.
  • 🇮🇹Italy apaderno Brescia, 🇮🇹

    The issue summary still needs to be updated. It is not even clear what exactly needs to be changed.

  • 🇮🇳India zkhan.aamir

    Issue summary updated

  • Assigned to nitin_lama
  • 🇮🇳India nitin_lama India

    Please review.

  • Issue was unassigned.
  • Status changed to Needs review 11 months ago
  • Status changed to Needs work 10 months ago
  • 🇷🇺Russia zniki.ru

    Please update Issue summary, update command and phpcs report.

    phpcs --standard=Drupal,DrupalPractice --extensions=php,inc,module,install,info,test,profile,theme 
    

    Please remove changes that is not a part of phpcs report.

  • First commit to issue fork.
  • Venkatraman Ganesan made their first commit to this issue’s fork.

  • 🇮🇳India zkhan.aamir

    Hi,

    MR #20 applied successfully.

    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules/modal_blocks (8.x-2.x)
    $ curl https://git.drupalcode.org/project/modal_blocks/-/merge_requests/10.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  1225    0  1225    0     0   3380      0 --:--:-- --:--:-- --:--:--  3383
    patching file modal_blocks.module
    patching file src/Plugin/Block/ModalBlock.php
    

    Still some issues remaining.

    Admin@DESKTOP-252TO6V MINGW64 ~/Desktop/projects/drupal/web/modules
    $ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,js,yml modal_blocks/
    
    FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\modal_blocks\README.md
    -------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -------------------------------------------------------------------------------
     39 | WARNING | Line exceeds 80 characters; contains 87 characters
    -------------------------------------------------------------------------------
    
    
    FILE: C:\Users\Admin\Desktop\projects\drupal\web\modules\modal_blocks\src\Plugin\Block\ModalBlock.php
    -----------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    -----------------------------------------------------------------------------------------------------
     125 | WARNING | Block::load calls should be avoided in classes, use dependency injection instead
     126 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
    -----------------------------------------------------------------------------------------------------
    
    Time: 227ms; Memory: 10MB
    
  • Assigned to nitin_lama
  • 🇮🇳India zkhan.aamir

    Issue summary updated.

  • Status changed to Needs review 9 months ago
  • 🇮🇳India nitin_lama India

    Updated MR. Please review.

  • Issue was unassigned.
  • 🇮🇳India karanpagare

    Tried using MR!10, but can't seem to get it working. Getting following error:

    Checking patch js/modal_blocks.js...
    Checking patch src/Plugin/Block/ModalBlock.php...
    Checking patch README.md...
    Checking patch modal_blocks.module...
    Checking patch src/Plugin/Block/ModalBlock.php...
    error: while searching for:
          case 'hour':
            $time = 1 * 60 * 60 * 1000;
            break;
          case 'day':
            $time = 1 * 24 * 60 * 60 * 1000;
            break;
          case 'week':
            $time = 7 * 24 * 60 * 60 * 1000;
            break;
          case 'month':
            $time = 30 * 24 * 60 * 60 * 1000;
            break;
    
    error: patch failed: src/Plugin/Block/ModalBlock.php:107
    error: src/Plugin/Block/ModalBlock.php: patch does not apply
    Checking patch src/Plugin/Block/ModalBlock.php...
    error: while searching for:
     *  package
     * )
     */
    class ModalBlock extends BlockBase implements BlockPluginInterface
    {
    
        /**
         * {@inheritdoc}
         */
        public function blockForm($form, FormStateInterface $form_state)
        {
            $form = parent::blockForm($form, $form_state);
            $config = $this->getConfiguration();
    
            $form['block'] = [
            '#type' => 'entity_autocomplete',
            '#title' => $this->t('Block to embed'),
            '#description' => $this->t('Select which block should be embedded inside modal block.'),
            '#target_type' => 'block',
            '#required' => true,
            ];
    
            $form['period'] = [
            '#type' => 'select',
            '#title' => $this->t('Frequency period type'),
            '#description' => $this->t('Select which period type goes with the frequency value above.'),
            '#empty_option' => $this->t('- Select period type -'),
            '#options' => [
            'hour' => $this->t('Hour'),
            'day' => $this->t('Day'),
            'week' => $this->t('Week'),
            'month' => $this->t('Month'),
            ],
            '#default_value' => $config['period'] ?? 'day',
            '#required' => true,
            ];
    
            $form['frequency'] = [
            '#type' => 'number',
            '#title' => $this->t('Frequency'),
            '#description' => $this->t('The frequency in which the modal block will appear. You can configure the frequency period below.'),
            '#min' => 0,
            '#default_value' => $config['frequency'] ?? '',
            '#required' => true,
            ];
    
            $rand = 'modal-block-' . rand(100000, 999999);
            $form['random'] = [
            '#type' => 'hidden',
            '#value' => $config['random'] ?? $rand,
            ];
    
    <<<<<<< HEAD
        return $form;
      }
    
      /**
       * {@inheritdoc}
       */
      public function blockSubmit($form, FormStateInterface $form_state) {
        $this->setConfigurationValue('block', $form_state->getValue('block'));
        $this->setConfigurationValue('frequency', $form_state->getValue('frequency'));
        $this->setConfigurationValue('period', $form_state->getValue('period'));
        $this->setConfigurationValue('random', $form_state->getValue('random'));
      }
    
      /**
    
    error: patch failed: src/Plugin/Block/ModalBlock.php:17
    error: src/Plugin/Block/ModalBlock.php: patch does not apply
    Checking patch modal_blocks.module...
    error: while searching for:
    <?php
    
    /*
     * @file
     * Provides a Modal Block.
     */
    
    error: patch failed: modal_blocks.module:1
    error: modal_blocks.module: patch does not apply
    Checking patch src/Plugin/Block/ModalBlock.php...
    error: while searching for:
          case 'hour':
            $time = 1 * 60 * 60 * 1000;
            break;
          case 'day':
            $time = 1 * 24 * 60 * 60 * 1000;
            break;
          case 'week':
            $time = 7 * 24 * 60 * 60 * 1000;
            break;
          case 'month':
            $time = 30 * 24 * 60 * 60 * 1000;
            break;
    
    error: patch failed: src/Plugin/Block/ModalBlock.php:107
    error: src/Plugin/Block/ModalBlock.php: patch does not apply
    Checking patch README.md...
    
  • 🇮🇳India dev16.addweb

    silvi.addweb made their first commit to this issue’s fork.

  • Status changed to RTBC 5 months ago
  • Hi @everyone,

    Applied @silvi.addweb's changes on the MR !6, it applied cleanly and fixed all reported issues.

    modal_blocks git:(8.x-2.0) CURL https://git.drupalcode.org/project/modal_blocks/-/merge_requests/6.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  3668    0  3668    0     0   7553      0 --:--:-- --:--:-- --:--:--  7804
    patching file README.md
    patching file modal_blocks.module
    patching file src/Plugin/Block/ModalBlock.php
    ➜  modal_blocks git:(8.x-2.0) ✗ cd ..
    ➜  contrib git:(master) ✗ phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig modal_blocks
    ➜  contrib git:(master) ✗

    Will now move this to RTBC

    Thanks,
    Jake

  • Pipeline finished with Success
    5 months ago
    Total: 140s
    #221669
  • Pipeline finished with Success
    5 months ago
    Total: 135s
    #221681
  • Pipeline finished with Success
    5 months ago
    Total: 142s
    #221683
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Pipeline finished with Success
    5 months ago
    Total: 140s
    #221691
  • Pipeline finished with Success
    5 months ago
    #221706
Production build 0.71.5 2024