Fix the issues reported by phpcs

Created on 21 December 2022, over 1 year ago
Updated 27 June 2024, about 23 hours ago

Problem/Motivation

Getting following error/warnings

FILE: /app/modules/contrib/workbench_email/src/EventSubscriber/ContentModerationStateChangedEvent.php
-----------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------
32 | ERROR | [x] Expected "string|false" but found "string|FALSE" for @var tag in member variable comment
-----------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/workbench_email/src/EventSubscriber/WorkbenchTransitionEventSubscriber.php
-----------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-----------------------------------------------------------------------------------------------------------------
57 | ERROR | Type hint "\Drupal\content_moderation\Event\ContentModerationStateChangedEvent" missing for $event
-----------------------------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/workbench_email/src/Form/TemplateForm.php
------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 3 WARNINGS AFFECTING 5 LINES
------------------------------------------------------------------------------------------------------------------------
18 | WARNING | [x] Unused use statement
26 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
71 | ERROR | [ ] Parameter $module_handler is not described in comment
71 | ERROR | [ ] Parameter $messenger is not described in comment
83 | ERROR | [ ] Type hint "\Drupal\content_moderation\ModerationInformationInterface" missing for $moderation_info
285 | WARNING | [ ] Workflow::loadMultiple calls should be avoided in classes, use dependency injection instead
------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/workbench_email/src/Plugin/Derivative/WorkbenchEmailDeriver.php
-----------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-----------------------------------------------------------------------------------------------------------------------------
28 | ERROR | [x] Do not append variable name "$moderation_information" to the type declaration in a member variable comment
40 | ERROR | [ ] Type hint "\Drupal\content_moderation\ModerationInformationInterface" missing for $moderation_info
-----------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/workbench_email/src/Plugin/QueueWorker/WorkbenchEmailProcessor.php
---------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------
126 | WARNING | [x] Inline @var declarations should use the /** */ delimiters
---------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/workbench_email/src/Plugin/RecipientType/EmailField.php
----------------------------------------------------------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 4 LINES
----------------------------------------------------------------------------------------------------------------------
69 | ERROR | [ ] Type hint "\Drupal\content_moderation\ModerationInformationInterface" missing for $moderation_info
141 | ERROR | [x] list(...) is forbidden, use [...] instead.
145 | ERROR | [x] list(...) is forbidden, use [...] instead.
168 | ERROR | [x] list(...) is forbidden, use [...] instead.
----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/workbench_email/src/Plugin/RecipientType/FixedEmail.php
----------------------------------------------------------------------------------
FOUND 1 ERROR AND 5 WARNINGS AFFECTING 6 LINES
----------------------------------------------------------------------------------
5 | WARNING | [x] Unused use statement
7 | WARNING | [x] Unused use statement
9 | WARNING | [x] Unused use statement
10 | WARNING | [x] Unused use statement
13 | WARNING | [x] Unused use statement
16 | ERROR | [x] Doc comment short description must end with a full stop
----------------------------------------------------------------------------------
PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------

FILE: /app/modules/contrib/workbench_email/src/Plugin/RecipientType/RolesWithAccess.php
----------------------------------------------------------------------------------------
FOUND 4 ERRORS AND 3 WARNINGS AFFECTING 7 LINES
----------------------------------------------------------------------------------------
6 | WARNING | [x] Unused use statement
8 | WARNING | [x] Unused use statement
9 | WARNING | [x] Unused use statement
10 | ERROR | [x] There must be one blank line after the last USE statement; 2 found;
24 | ERROR | [x] There must be exactly one newline after the class comment
53 | ERROR | [x] Expected 1 blank line after function; 0 found
54 | ERROR | [x] The closing brace for the class must have an empty line before it
----------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------

FILE: /app/modules/contrib/workbench_email/src/Plugin/RecipientTypeBase.php
---------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------
38 | WARNING | Line exceeds 80 characters; contains 84 characters
---------------------------------------------------------------------------

FILE: /app/modules/contrib/workbench_email/src/Plugin/RecipientTypeInterface.php
-------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
-------------------------------------------------------------------------------------
17 | WARNING | [x] 'TODO Docs.' should match the format '@todo Fix problem X here.'
-------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------

FILE: /app/modules/contrib/workbench_email/src/RecipientTypePluginCollection.php
--------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------
26 | WARNING | Possible useless method overriding detected
--------------------------------------------------------------------------------

FILE: /app/modules/contrib/workbench_email/src/TemplateInterface.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
99 | WARNING | Line exceeds 80 characters; contains 104 characters
----------------------------------------------------------------------

FILE: /app/modules/contrib/workbench_email/tests/src/Functional/WorkbenchEmailTest.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
------------------------------------------------------------------------------------------------------------------------------------------
302 | 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
348 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
370 | WARNING | t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
------------------------------------------------------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/workbench_email/tests/src/Kernel/ConfigDependenciesTest.php
--------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------------------
67 | WARNING | Unused variable $node_type.
--------------------------------------------------------------------------------------

FILE: /app/modules/contrib/workbench_email/tests/src/Kernel/RecipientTypePluginsTest.php
----------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------------------------
85 | WARNING | Unused variable $node_type.
----------------------------------------------------------------------------------------

FILE: /app/modules/contrib/workbench_email/workbench_email.module
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 2 WARNINGS AFFECTING 5 LINES
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
73 | WARNING | [ ] Format should be "* Implements hook_foo().", "* Implements hook_foo_BAR_ID_bar() for xyz_bar().",, "* Implements hook_foo_BAR_ID_bar() for
| | xyz-bar.html.twig.", "* Implements hook_foo_BAR_ID_bar() for xyz-bar.tpl.php.", or "* Implements hook_foo_BAR_ID_bar() for block templates."
82 | WARNING | [ ] Format should be "* Implements hook_foo().", "* Implements hook_foo_BAR_ID_bar() for xyz_bar().",, "* Implements hook_foo_BAR_ID_bar() for
| | xyz-bar.html.twig.", "* Implements hook_foo_BAR_ID_bar() for xyz-bar.tpl.php.", or "* Implements hook_foo_BAR_ID_bar() for block templates."
100 | ERROR | [x] Additional blank lines found at end of doc comment
101 | ERROR | [ ] Expected type hint "EntityInterface"; found "ContentModerationState" for $entity
113 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

FILE: /app/modules/contrib/workbench_email/workbench_email.post_update.php
--------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 1 LINE
--------------------------------------------------------------------------
41 | ERROR | [x] There should be no white space after an opening "{"
41 | ERROR | [x] There should be no white space before a closing "}"
41 | ERROR | [x] Closing brace must be on a line by itself
--------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------

Time: 7.6 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/workbench_email/

Proposed resolution

Above error/warnings need to be fixed

Note:

I also removed public function &get($instance_id) function from
workbench_email/src/RecipientTypePluginCollection.php file as it is only called it's parent get function.

šŸ“Œ Task
Status

Fixed

Version

3.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.

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, šŸ‡®šŸ‡¹
      /**
    -   * An associative array containing the configured settings of this recipient type.
    +   * An associative array containing the configured settings of this
    +   * recipient type.
        *
        * @var array

    Short descriptions must be only a line.

    - * TODO Docs.
    + * @todo Docs.

    What follows @todo is a sentence. Docs. does not say much about what needs to be done.

      /**
        * Test node type.
    +   *
    +   * @var nodeType
        */
       protected NodeTypeInterface $nodeType;

    nodeType is not a valid PHP type and it cannot be used with @var.

    I am not sure the fact phpcbf can fix some warnings/errors is a valid reason not to change those lines in the patch. Maintainers are not supposed to apply the patch and then run phpcbf; they are supposed to apply the patch, or merge the MR.

  • Assigned to arpitk
  • šŸ‡®šŸ‡³India arpitk

    Updating patch with reference to #10

  • Status changed to Needs review about 1 year ago
  • Open in Jenkins ā†’ Open on Drupal.org ā†’
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    9 pass
  • šŸ‡®šŸ‡³India arpitk

    Tried the patch #5 it failed with 3.x-dev. However it works with 3.0.0. Updated the patch with reference from #10. Please review.

    Thanks!

  • Open in Jenkins ā†’ Open on Drupal.org ā†’
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update about 1 year ago
    9 pass
  • Issue was unassigned.
  • First commit to issue fork.
  • Merge request !24Issue#3328490: Fixing phpcs issues. ā†’ (Merged) created by ankitv18
  • Pipeline finished with Success
    about 1 month ago
    Total: 183s
    #184873
  • Status changed to RTBC 29 days ago
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi @ankitv18,

    I applied MR!24, it was applied smoothly and fixed all phpcs issues.

    āžœ  workbench_email git:(3.x) curl https://git.drupalcode.org/project/workbench_email/-/merge_requests/24.diff | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  6122    0  6122    0     0   9177      0 --:--:-- --:--:-- --:--:--  9178
    patching file src/Form/TemplateForm.php
    patching file src/Plugin/RecipientTypeBase.php
    patching file src/RecipientTypePluginCollection.php
    patching file src/TemplateInterface.php
    patching file tests/src/Kernel/ConfigDependenciesTest.php
    patching file tests/src/Kernel/RecipientTypePluginsTest.php
    patching file workbench_email.module
    āžœ  workbench_email git:(3.x) āœ— ..
    āžœ  contrib git:(main) āœ— phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml workbench_email
    āžœ  contrib git:(main) āœ—

    Thank you.

  • šŸ‡¦šŸ‡ŗAustralia larowlan šŸ‡¦šŸ‡ŗšŸ.au GMT+10

    Thanks will look at this later in the week

  • Status changed to Needs work 23 days ago
  • šŸ‡¦šŸ‡ŗAustralia larowlan šŸ‡¦šŸ‡ŗšŸ.au GMT+10

    Thanks folks, left a review on the MR

  • Assigned to ankitv18
  • šŸ‡®šŸ‡³India ankitv18

    Will rebase with dev branch and check for further phpcs report & do a suggested fix.

  • Pipeline finished with Failed
    23 days ago
    Total: 146s
    #191583
  • Pipeline finished with Failed
    23 days ago
    Total: 146s
    #191598
  • Pipeline finished with Skipped
    22 days ago
    #192220
  • Status changed to Fixed 22 days ago
  • šŸ‡¦šŸ‡ŗAustralia larowlan šŸ‡¦šŸ‡ŗšŸ.au GMT+10
  • Issue was unassigned.
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024