Fix the issues reported by PHPCS

Created on 13 April 2023, over 1 year ago
Updated 27 April 2023, over 1 year ago

Problem/Motivation

FILE: ...ontribution/drupal10/web/modules/contrib/consent_popup/js/consent-popup.js
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
46 | ERROR | [x] Inline control structures are not allowed
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: ...ntribution/drupal10/web/modules/contrib/consent_popup/consent_popup.module
--------------------------------------------------------------------------------
FOUND 7 ERRORS AND 2 WARNINGS AFFECTING 9 LINES
--------------------------------------------------------------------------------
7 | ERROR | [x] Additional blank lines found at end of doc comment
9 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 1
11 | ERROR | [x] Line indented incorrectly; expected 0 spaces, found 2
12 | ERROR | [x] Expected 3 space(s) before asterisk; 1 found
13 | ERROR | [x] Expected 3 space(s) before asterisk; 1 found
41 | ERROR | [x] Line indented incorrectly; expected 2 spaces, found 1
46 | WARNING | [x] A comma should follow the last multiline array item. Found:
| | 'consent-popup'
47 | WARNING | [x] A comma should follow the last multiline array item. Found:
| | ]
49 | ERROR | [x] Expected 1 newline at end of file; 0 found
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 9 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: ...www/html/contribution/drupal10/web/modules/contrib/consent_popup/README.md
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
7 | WARNING | Line exceeds 80 characters; contains 89 characters
--------------------------------------------------------------------------------

FILE: ...0/web/modules/contrib/consent_popup/src/Plugin/Block/ConsentPopupBlock.php
--------------------------------------------------------------------------------
FOUND 40 ERRORS AND 23 WARNINGS AFFECTING 46 LINES
--------------------------------------------------------------------------------
3 | ERROR | [x] There must be one blank line after the namespace
| | declaration
25 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency
| | injection instead
37 | ERROR | [x] Expected 1 space before "?"; 2 found
37 | ERROR | [x] Whitespace found at end of line
38 | ERROR | [x] Expected 1 space after ":"; 2 found
39 | WARNING | [x] A comma should follow the last multiline array item.
| | Found: true
39 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE"
| | but found "true"
44 | ERROR | [x] Expected 1 space before "?"; 2 found
44 | ERROR | [x] Whitespace found at end of line
45 | ERROR | [x] Whitespace found at end of line
47 | WARNING | [x] A comma should follow the last multiline array item.
| | Found: true
47 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE"
| | but found "true"
52 | ERROR | [x] Expected 1 space before "?"; 2 found
54 | WARNING | [x] A comma should follow the last multiline array item.
| | Found: true
54 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE"
| | but found "true"
59 | ERROR | [x] Expected 1 space before "?"; 2 found
61 | WARNING | [x] A comma should follow the last multiline array item.
| | Found: true
61 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE"
| | but found "true"
64 | ERROR | [x] Expected 1 space after "="; 0 found
67 | WARNING | [x] A comma should follow the last multiline array item.
| | Found: )
72 | ERROR | [x] Expected 1 space before "?"; 2 found
73 | WARNING | [ ] Translatable strings must not begin or end with white
| | spaces, use placeholders with t() for variables
74 | WARNING | [x] A comma should follow the last multiline array item.
| | Found: true
74 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE"
| | but found "true"
79 | ERROR | [x] Expected 1 space before "?"; 2 found
81 | WARNING | [x] A comma should follow the last multiline array item.
| | Found: true
81 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE"
| | but found "true"
83 | ERROR | [x] Expected 1 space after "="; 0 found
86 | WARNING | [x] A comma should follow the last multiline array item.
| | Found: )
91 | ERROR | [x] Expected 1 space before "?"; 2 found
93 | WARNING | [x] A comma should follow the last multiline array item.
| | Found: true
93 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE"
| | but found "true"
98 | ERROR | [x] Expected 1 space before "?"; 2 found
99 | WARNING | [x] A comma should follow the last multiline array item.
| | Found: )
101 | ERROR | [x] Expected 1 space after "="; 0 found
104 | WARNING | [x] A comma should follow the last multiline array item.
| | Found: )
106 | ERROR | [x] Short array syntax must be used to define arrays
114 | WARNING | [ ] t() calls should be avoided in classes, use
| | \Drupal\Core\StringTranslation\StringTranslationTrait and
| | $this->t() instead
122 | ERROR | [x] Expected 1 space before "?"; 2 found
123 | WARNING | [ ] Translatable strings must not begin or end with white
| | spaces, use placeholders with t() for variables
123 | WARNING | [x] A comma should follow the last multiline array item.
| | Found: )
126 | ERROR | [x] Expected 1 blank line after function; 2 found
127 | ERROR | [x] Whitespace found at end of line
142 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency
| | injection instead
148 | ERROR | [x] Concat operator must be surrounded by a single space
148 | ERROR | [x] Concat operator must be surrounded by a single space
148 | ERROR | [x] Concat operator must be surrounded by a single space
148 | ERROR | [x] Concat operator must be surrounded by a single space
148 | ERROR | [x] Concat operator must be surrounded by a single space
148 | ERROR | [x] Concat operator must be surrounded by a single space
148 | ERROR | [x] Concat operator must be surrounded by a single space
148 | ERROR | [x] Concat operator must be surrounded by a single space
149 | ERROR | [x] Expected one space after the comma, 0 found
150 | ERROR | [x] Expected 1 space after "="; 2 found
157 | WARNING | [x] A comma should follow the last multiline array item.
| | Found: ]
159 | ERROR | [x] Expected 1 space after "=>"; 0 found
161 | WARNING | [x] A comma should follow the last multiline array item.
| | Found: 'consent_popup/consent_popup'
169 | WARNING | [x] A comma should follow the last multiline array item.
| | Found: $blurElements
170 | WARNING | [x] A comma should follow the last multiline array item.
| | Found: ]
171 | WARNING | [x] A comma should follow the last multiline array item.
| | Found: ]
172 | WARNING | [x] A comma should follow the last multiline array item.
| | Found: ]
175 | ERROR | [x] Expected 1 blank line after function; 0 found
176 | ERROR | [x] The closing brace for the class must have an empty line
| | before it
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 58 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

FILE: ...ww/html/contribution/drupal10/web/modules/contrib/consent_popup/README.txt
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
15 | WARNING | Line exceeds 80 characters; contains 89 characters
--------------------------------------------------------------------------------

FILE: ...upal10/web/modules/contrib/consent_popup/templates/consent-popup.html.twig
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
8 | ERROR | [x] Expected 1 newline at end of file; 0 found
--------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------

Time: 429ms; Memory: 10MB

Steps to reproduce

Execute the command: phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,js,info,txt,md,yml,twig consent_popup/

Proposed resolution

Resolve all issues for Drupal and DrupalPractice coding standards

Remaining tasks

Patch review and fix remaining issues
FILE: ...0/web/modules/contrib/consent_popup/src/Plugin/Block/ConsentPopupBlock.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
--------------------------------------------------------------------------------
26 | WARNING | \Drupal calls should be avoided in classes, use dependency
| | injection instead
142 | WARNING | \Drupal calls should be avoided in classes, use dependency
| | injection instead
--------------------------------------------------------------------------------

Time: 419ms; Memory: 10MB

๐Ÿ“Œ Task
Status

Fixed

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia urvashi_vora Madhya Pradesh, India

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

Comments & Activities

  • Issue created by @urvashi_vora
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines kenyoOwen

    Hi urvashi_vora

    I applied the patch โ†’ to the โ€œConsent Popupโ€ module against Version 1.0.x-dev and there is 12 errors and 2 warnings left. Please see the screenshots attached.

    For your review.
    Thank you.

  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Akram Khan Cuttack, Odisha

    added updated patch and it fixed remaining issue

  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines kenyoOwen

    Hi Akram Khan

    I applied the patch #3 to the โ€œConsent Popupโ€ module against Version 1.0.x-dev and confirmed that it fixed the remaining issue. Please see the screenshots attached.

    For your review.
    Thank you.

  • Status changed to RTBC over 1 year ago
  • ๐Ÿ‡ต๐Ÿ‡ญPhilippines kenyoOwen
  • ๐Ÿ‡ต๐Ÿ‡นPortugal kallado

    Fixed in 1.0.1, Thanks guys.

  • Status changed to Fixed over 1 year ago
  • ๐Ÿ‡ต๐Ÿ‡นPortugal kallado
  • ๐Ÿ‡ต๐Ÿ‡นPortugal kallado

    Guys this breaks the module see:
    https://www.drupal.org/project/consent_popup/issues/3356742#comment-1502... ๐Ÿ› Unable to add Consent Popup block Fixed
    Patch created there.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia urvashi_vora Madhya Pradesh, India

    Hey @kallado,

    As per the error message in https://www.drupal.org/project/consent_popup/issues/3356742 ๐Ÿ› Unable to add Consent Popup block Fixed
    ArgumentCountError: Drupal\consent_popup\Plugin\Block\ConsentPopupBlock->__construct() ๅ†… Too few arguments to function Drupal\consent_popup\Plugin\Block\ConsentPopupBlock::__construct(), 3 passed in /var/www/html/web/core/lib/Drupal/Core/Plugin/Factory/ContainerFactory.php on line 25 and exactly 4 expected (/var/www/html/web/modules/contrib/consent_popup/src/Plugin/Block/ConsentPopupBlock.php ใฎ 40 ่กŒ็›ฎ)

    Which says too few arguments, passed 3, expected 4.

    I believe, this line is creating the issue
    parent::__construct($configuration, $plugin_id, $plugin_definition);

    As we can see, in function there are 4 params used in patch #3.

      public function __construct(array $configuration, $plugin_id, $plugin_definition, LanguageManagerInterface $language_manager) {
        parent::__construct($configuration, $plugin_id, $plugin_definition);
        $this->languageManager = $language_manager;
      }
    

    But, I don't want to be quick to make any statement, thus, I would like to have suggestions of others too.

  • ๐Ÿ‡ต๐Ÿ‡นPortugal kallado

    @Urvashi Vora The patch is already created here https://www.drupal.org/project/consent_popup/issues/3356742 ๐Ÿ› Unable to add Consent Popup block Fixed . The Class definition was missing "implements ContainerFactoryPluginInterface". and aldso had a couple of typos, but thanks.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia urvashi_vora Madhya Pradesh, India

    Ohh, yes!!

    Went through the patch.

    Don't know how I missed it!!

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024