Fix the issues reported by phpcs

Created on 3 March 2023, over 1 year ago
Updated 14 February 2024, 4 months ago

Problem/Motivation

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

Steps to reproduce

Run following command

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

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ“Œ Task
Status

Needs review

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 AditiVB
  • ๐Ÿ‡ฎ๐Ÿ‡ณ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 8 months 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 8 months 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

    Please review.

  • Issue was unassigned.
  • Status changed to Needs review 6 months ago
  • Status changed to Needs work 5 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 4 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama

    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...
    
Production build 0.69.0 2024