Fix the issues reported by phpcs

Created on 5 January 2023, almost 2 years ago
Updated 31 July 2024, 5 months ago

Problem/Motivation

Getting following error/warnings

FILE: /app/modules/contrib/mass_contact/mass_contact.install
------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------------------------------------------------
25 | ERROR | [x] Whitespace found at end of line
30 | ERROR | [x] No space found before comment text; expected "// Removing mass_contact_opt_out field." but found "//Removing mass_contact_opt_out field."
------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/mass_contact/mass_contact.module
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------
55 | ERROR | The array declaration extends to column 249 (the limit is 80). The array content should be split up over multiple lines
--------------------------------------------------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/mass_contact/src/Form/AdminSettingsForm.php
---------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
---------------------------------------------------------------------------------
114 | WARNING | #options values usually have to run through t() for translation
115 | WARNING | #options values usually have to run through t() for translation
---------------------------------------------------------------------------------

FILE: /app/modules/contrib/mass_contact/src/Form/CategoryForm.php
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 3 LINES
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
15 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
138 | WARNING | [ ] Line exceeds 80 characters; contains 111 characters
138 | WARNING | [x] 'TODO: Drupal Rector Notice: Please delete the following comment after you've made any necessary changes.' should match the format '@todo Fix problem
| | X here.'
139 | WARNING | [ ] Line exceeds 80 characters; contains 218 characters
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/mass_contact/src/Form/EmailBodyForm.php
---------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------------------------
111 | ERROR | The array declaration extends to column 343 (the limit is 80). The array content should be split up over multiple lines
---------------------------------------------------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/mass_contact/src/Form/MassContactForm.php
--------------------------------------------------------------------------------------------------
FOUND 10 ERRORS AND 1 WARNING AFFECTING 10 LINES
--------------------------------------------------------------------------------------------------
53 | ERROR | [ ] Missing parameter comment
53 | ERROR | [x] Expected 1 spaces after parameter type; 10 found
56 | ERROR | [x] Expected 1 spaces after parameter type; 10 found
58 | ERROR | [x] Expected 1 spaces after parameter type; 10 found
60 | ERROR | [x] Expected 1 spaces after parameter type; 9 found
62 | ERROR | [x] Expected 1 spaces after parameter type; 14 found
175 | ERROR | [ ] Unnecessarily gendered language in a comment
265 | ERROR | [x] Array indentation error, expected 10 spaces but found 8
266 | ERROR | [x] Array indentation error, expected 10 spaces but found 8
345 | ERROR | [x] Array indentation error, expected 10 spaces but found 8
430 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
--------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/mass_contact/src/MassContact.php
----------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------------
280 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/mass_contact/src/Plugin/MassContact/GroupingMethod/Role.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------------
142 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
------------------------------------------------------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/mass_contact/src/Tests/Form/EmailBodyFormTest.php
----------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------
34 | WARNING | '@todo' should match the format '@todo Fix problem X here.'
----------------------------------------------------------------------------

FILE: /app/modules/contrib/mass_contact/tests/src/Functional/Form/CategoryFormTest.php
---------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 10 WARNINGS AFFECTING 10 LINES
---------------------------------------------------------------------------------------------------------------------------------------------
5 | WARNING | [x] Unused use statement
26 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
27 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
30 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
33 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
36 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
37 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
50 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
71 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
97 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
---------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/mass_contact/tests/src/Functional/Form/MassContactFormTest.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 9 WARNINGS AFFECTING 10 LINES
------------------------------------------------------------------------------------------------------------------------------------------
55 | ERROR | The array declaration extends to column 116 (the limit is 80). The array content should be split up over multiple lines
147 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
184 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
193 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
230 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
261 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
272 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
305 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
336 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
457 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
------------------------------------------------------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/mass_contact/tests/src/Kernel/CategoryAccessControlHandlerTest.php
---------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------
3 | ERROR | [x] There must be one blank line after the namespace declaration
---------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/mass_contact/tests/src/Kernel/CategoryCreationTrait.php
----------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------
5 | WARNING | [x] Unused use statement
----------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------

FILE: /app/modules/contrib/mass_contact/tests/src/Kernel/Entity/MassContactCategoryTest.php
--------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------------------------------------------------------------
67 | ERROR | The array declaration extends to column 115 (the limit is 80). The array content should be split up over multiple lines
--------------------------------------------------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/mass_contact/tests/src/Kernel/OptOutTest.php
---------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
---------------------------------------------------------------------------------------------------------------------------------------
152 | ERROR | The array declaration extends to column 107 (the limit is 80). The array content should be split up over multiple lines
---------------------------------------------------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/mass_contact/tests/src/Unit/MassContactTest.php
--------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------
31 | ERROR | [x] Expected 1 blank line before function; 0 found
--------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------

Time: 6.14 secs; Memory: 14MB

Steps to reproduce

Run following command

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

Proposed resolution

Above error/warnings need to be fixed

๐Ÿ“Œ Task
Status

Needs review

Version

1.0

Component

Code

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia samit.310@gmail.com

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.

  • Needs reroll

    The patch will have to be re-rolled with new suggestions/changes described in the comments in the issue.

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.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Charchil Khandelwal

    Charchil Khandelwal โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Charchil Khandelwal

    Created MR for this issue.
    Please review.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น
  • Hi, reviewed the patch #4, applied cleanly and fixes all the reported phpcs errors/warnings.
    Thank you!

  • Status changed to Needs work 5 months ago
  • Hi @everyone,

    Applied the patch provided on the comment #4, it was applied successfully but what comment #9 said was false because errors were still reported. Please see:

    mass_contact git:(8.x-1.x) curl https://www.drupal.org/files/issues/2023-01-05/3331228-4.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 28602  100 28602    0     0   265k      0 --:--:-- --:--:-- --:--:--  285k
    patching file mass_contact.install
    patching file mass_contact.module
    patching file mass_contact.services.yml
    patching file src/Form/AdminSettingsForm.php
    patching file src/Form/CategoryForm.php
    patching file src/Form/EmailBodyForm.php
    patching file src/Form/MassContactForm.php
    patching file src/MassContact.php
    patching file src/Plugin/MassContact/GroupingMethod/Role.php
    patching file src/Tests/Form/EmailBodyFormTest.php
    patching file tests/src/Functional/Form/CategoryFormTest.php
    patching file tests/src/Functional/Form/MassContactFormTest.php
    patching file tests/src/Kernel/CategoryAccessControlHandlerTest.php
    patching file tests/src/Kernel/CategoryCreationTrait.php
    patching file tests/src/Kernel/Entity/MassContactCategoryTest.php
    patching file tests/src/Kernel/OptOutTest.php
    patching file tests/src/Unit/MassContactTest.php
    โžœ  mass_contact git:(8.x-1.x) โœ— cd ..
    โžœ  contrib git:(master) โœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig mass_contact
    
    FILE: ...sue-v9/web/modules/contrib/mass_contact/tests/src/Unit/MassContactTest.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     6 | ERROR | [x] Use statements should be sorted alphabetically. The first
       |       |     wrong one is Drupal\Core\Config\ConfigFactoryInterface.
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    
    FILE: ...les/contrib/mass_contact/tests/src/Functional/Form/MassContactFormTest.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     11 | ERROR | [x] Use statements should be sorted alphabetically. The first
        |       |     wrong one is Drupal\mass_contact\MassContactInterface.
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    
    FILE: ...al-orgissue-v9/web/modules/contrib/mass_contact/src/Form/EmailBodyForm.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     6 | ERROR | [x] Use statements should be sorted alphabetically. The first
       |       |     wrong one is Drupal\Core\Config\ConfigFactoryInterface.
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    
    FILE: ...eb/modules/contrib/mass_contact/src/Form/MassContactMessageConfirmForm.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     9 | ERROR | [x] Use statements should be sorted alphabetically. The first
       |       |     wrong one is Drupal\mass_contact\MassContactInterface.
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    
    FILE: ...es/contrib/mass_contact/src/ParamConverter/MassContactConfirmConverter.php
    --------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------
     7 | ERROR | [x] Use statements should be sorted alphabetically. The first
       |       |     wrong one is
       |       |     Drupal\Core\ParamConverter\ParamConverterInterface.
    --------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------
    
    Time: 1.36 secs; Memory: 14MB

    Kindly check

    Thanks,
    Jake

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly apaderno Brescia, ๐Ÿ‡ฎ๐Ÿ‡น

    Let's use a merge request, now that patches are no longer tested.

  • Pipeline finished with Success
    5 months ago
    Total: 268s
    #239445
  • Status changed to Needs review 5 months ago
Production build 0.71.5 2024