Fix the issues reported by phpcs

Created on 24 April 2023, about 1 year ago
Updated 16 August 2023, 10 months ago

Problem/Motivation

Getting following error/warnings.

FILE: /var/www/html/modules/contrib/widget_type/css/options-filter.css
--------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
--------------------------------------------------------------------------------------------
101 | ERROR | [ ] Style definitions must end with a semicolon
174 | ERROR | [x] CSS colours must be defined in lowercase; expected #eeee but found #EEEE
176 | ERROR | [x] CSS colours must be defined in lowercase; expected #ddd but found #DDD
--------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/widget_type/widget_type.install
-------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------------------
150 | ERROR | [x] Namespaced classes/interfaces/traits should be referenced with use statements
-------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/widget_type/tests/src/Unit/WidgetTypeConfigurationTest.php
----------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------------------------------
35 | ERROR | [x] Missing function doc comment
----------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/widget_type/src/Form/WidgetTypeSettingsForm.php
---------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------------
41 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
---------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/widget_type/src/WidgetRegistrySourceInterface.php
-------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
-------------------------------------------------------------------------------------
17 | ERROR | Return type "array{0: string, 1: string}" must not contain spaces
-------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/widget_type/src/Entity/WidgetType.php
---------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 1 WARNING AFFECTING 3 LINES
---------------------------------------------------------------------------------------------------------------------------
68 | WARNING | [ ] Translatable strings must not begin or end with white spaces, use placeholders with t() for variables
229 | ERROR | [x] Expected newline after closing brace
244 | ERROR | [x] Expected newline after closing brace
---------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/widget_type/src/Plugin/EntityReferenceSelection/WidgetTypeSelection.php
-----------------------------------------------------------------------------------------------------------
FOUND 7 ERRORS AND 1 WARNING AFFECTING 8 LINES
-----------------------------------------------------------------------------------------------------------
6 | WARNING | [x] Unused use statement
22 | ERROR | [x] Missing function doc comment
24 | ERROR | [x] Array indentation error, expected 6 spaces but found 8
25 | ERROR | [x] Array closing indentation error, expected 4 spaces but found 6
77 | ERROR | [x] Expected 1 blank line after function; 2 found
80 | ERROR | [x] Missing function doc comment
106 | ERROR | [x] Expected 1 blank line after function; 0 found
107 | ERROR | [x] The closing brace for the class must have an empty line before it
-----------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 8 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/widget_type/src/Element/WidgetSelectorElement.php
-------------------------------------------------------------------------------------------------------------------------------
FOUND 12 ERRORS AND 1 WARNING AFFECTING 6 LINES
-------------------------------------------------------------------------------------------------------------------------------
27 | ERROR | [ ] Missing short description in doc comment
53 | ERROR | [ ] Missing short description in doc comment
77 | ERROR | [x] Expected newline after closing brace
77 | ERROR | [x] Expected 1 space before "|"; 0 found
77 | ERROR | [x] Expected 1 space after "|"; 0 found
111 | WARNING | [ ] Line exceeds 80 characters; contains 90 characters
111 | ERROR | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
172 | ERROR | [x] Expected newline after closing brace
172 | ERROR | [x] Expected 1 space before "|"; 0 found
172 | ERROR | [x] Expected 1 space after "|"; 0 found
285 | ERROR | [x] Expected newline after closing brace
285 | ERROR | [x] Expected 1 space before "|"; 0 found
285 | ERROR | [x] Expected 1 space after "|"; 0 found
-------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 10 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/widget_type/src/Controller/InteractiveComponents.php
-------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------
12 | WARNING | [x] Unused use statement
87 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
-------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/widget_type/src/WidgetTypeInterface.php
-----------------------------------------------------------------------------------------------------------------------
FOUND 6 ERRORS AFFECTING 5 LINES
-----------------------------------------------------------------------------------------------------------------------
16 | ERROR | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
42 | ERROR | [ ] Doc comment short description must be on a single line, further text should be a separate paragraph
144 | ERROR | [ ] Missing short description in doc comment
145 | ERROR | [ ] Missing parameter comment
145 | ERROR | [ ] Missing parameter type
363 | ERROR | [x] Parameter comment must end with a full stop
-----------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-----------------------------------------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/widget_type/src/WidgetRegistrySourceListBuilder.php
---------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------------------
39 | WARNING | [x] A comma should follow the last multiline array item. Found: ]
---------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------

FILE: /var/www/html/modules/contrib/widget_type/src/WidgetTypeListBuilder.php
------------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
------------------------------------------------------------------------------------------------------------------------------------------
139 | ERROR | [x] Expected newline after closing brace
183 | ERROR | [ ] The array declaration extends to column 96 (the limit is 80). The array content should be split up over multiple lines
191 | ERROR | [ ] The array declaration extends to column 94 (the limit is 80). The array content should be split up over multiple lines
------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------------

Time: 2.87 secs; Memory: 8MB

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/widget_type/

Proposed resolution

Above error/warnings need to be fixed.

📌 Task
Status

RTBC

Version

1.5

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

Comments & Activities

  • Issue created by @samit.310@gmail.com
  • Issue was unassigned.
  • Status changed to Needs review about 1 year ago
  • Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 8
    last update about 1 year ago
    Waiting for branch to pass
  • 🇮🇳India samit.310@gmail.com

    Above errors/warnings has been fixed.

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

    Hi samit.310@gmail.com

    I reviewed patch #2, and confirmed it fixes the errors/warnings that you reported. However, I'm getting these additional 3 warnings when I run the command against Drupal core version 9.5.7, Widget Type 1.5.14.

    FILE: /Users/studenttrainees/Drupal2/drupalsite/docroot/modules/contrib/widget_type/widget_type.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
    -------------------------------------------------------------------------------------------------------------

    Time: 1.21 secs; Memory: 14MB

    Please check.
    Thank You.

  • Status changed to Needs review about 1 year ago
  • 🇮🇳India mrinalini9 New Delhi

    Hi,

    I have checked patch #2, it applied successfully and not getting any errors/warnings as mentioned in #3. Hence, no work is needed here, so moving this to Needs Review.

    Thanks!

  • Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.1 & MySQL 8
    last update 10 months ago
    Waiting for branch to pass
  • Hii, I have Review your patch #2.

    These are the steps I followed:

    1. Took clone from git version 1.x in drupal 10.1.x

    2. Ran this command:

    ./vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig modules/contrib/widget_type/

    But I found errors.

    3. I have fixed that error with phpcbf.

    Ran this command to fix the errors:

    ./vendor/bin/phpcbf --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig modules/contrib/widgets_type/

    Then again checked with phpcs:

    ./vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml,twig modules/contrib/widgets_type/

    Found no errors.

    Please Review.

  • Status changed to RTBC 10 months ago
  • 🇵🇭Philippines roberttabigue

    Hi,

    I have reviewed the changes and confirmed that Patch #5 was applied cleanly to the Widget Type module against 1.5.14 on Drupal 10.1.2.

    Checking patch css/options-filter.css...
    Checking patch src/Controller/InteractiveComponents.php...
    Checking patch src/Element/WidgetSelectorElement.php...
    Checking patch src/Entity/WidgetType.php...
    Checking patch src/Form/WidgetTypeSettingsForm.php...
    Checking patch src/Plugin/EntityReferenceSelection/WidgetTypeSelection.php...
    Checking patch src/WidgetRegistrySourceInterface.php...
    Checking patch src/WidgetRegistrySourceListBuilder.php...
    Checking patch src/WidgetTypeInterface.php...
    Checking patch src/WidgetTypeListBuilder.php...
    Checking patch tests/src/Unit/WidgetTypeConfigurationTest.php...
    Checking patch widget_type.install...
    Applied patch css/options-filter.css cleanly.
    Applied patch src/Controller/InteractiveComponents.php cleanly.
    Applied patch src/Element/WidgetSelectorElement.php cleanly.
    Applied patch src/Entity/WidgetType.php cleanly.
    Applied patch src/Form/WidgetTypeSettingsForm.php cleanly.
    Applied patch src/Plugin/EntityReferenceSelection/WidgetTypeSelection.php cleanly.
    Applied patch src/WidgetRegistrySourceInterface.php cleanly.
    Applied patch src/WidgetRegistrySourceListBuilder.php cleanly.
    Applied patch src/WidgetTypeInterface.php cleanly.
    Applied patch src/WidgetTypeListBuilder.php cleanly.
    Applied patch tests/src/Unit/WidgetTypeConfigurationTest.php cleanly.
    Applied patch widget_type.install cleanly.

    And all PHPCS errors have been fixed.

    I re-ran this command on the module:
    phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml widget_type/

    Please see the attached file for reference.

    I'm moving this now to RTBC.

    Thank you!

Production build 0.69.0 2024