Fix the issues reported by phpcs

Created on 10 January 2023, over 1 year ago
Updated 10 April 2024, 3 months ago

Problem/Motivation

Getting following errors and warnings.

FILE: /app/modules/contrib/better_exposed_filters/README.md
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
42 | WARNING | Line exceeds 80 characters; contains 94 characters
----------------------------------------------------------------------

FILE: ...s/contrib/better_exposed_filters/better_exposed_filters.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: ...es/contrib/better_exposed_filters/better_exposed_filters.install
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
223 | WARNING | Line exceeds 80 characters; contains 84 characters
227 | WARNING | Line exceeds 80 characters; contains 83 characters
----------------------------------------------------------------------

FILE: ...les/contrib/better_exposed_filters/better_exposed_filters.module
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
31 | ERROR | [x] Each index in a multi-line array must be on a new
| | line
32 | ERROR | [x] Each index in a multi-line array must be on a new
| | line
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ...better_exposed_filters/includes/better_exposed_filters.theme.inc
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
162 | WARNING | '@todo' should match the format '@todo Fix problem X
| | here.'
----------------------------------------------------------------------

FILE: ...ontrib/better_exposed_filters/src/BetterExposedFiltersHelper.php
----------------------------------------------------------------------
FOUND 1 ERROR AND 3 WARNINGS AFFECTING 3 LINES
----------------------------------------------------------------------
46 | ERROR | [x] list(...) is forbidden, use [...] instead.
80 | WARNING | [ ] Unused variable $value.
80 | WARNING | [ ] Unused variable $value.
83 | WARNING | [ ] Unused variable $value.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ...er_exposed_filters/src/Plugin/BetterExposedFiltersWidgetBase.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 1 LINE
----------------------------------------------------------------------
159 | WARNING | Unused bound variable $form.
159 | WARNING | Unused bound variable $element.
----------------------------------------------------------------------

FILE: ...filters/src/Plugin/better_exposed_filters/filter/DatePickers.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
41 | WARNING | [ ] Unused variable $element.
110 | WARNING | [x] '@todo: To be honest, I'm not sure this is
| | needed. Can you set a' should match the format
| | '@todo Fix problem X here.'
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ...rs/src/Plugin/better_exposed_filters/filter/FilterWidgetBase.php
----------------------------------------------------------------------
FOUND 1 ERROR AND 4 WARNINGS AFFECTING 5 LINES
----------------------------------------------------------------------
116 | WARNING | [ ] Only string literals should be passed to t()
| | where possible
185 | WARNING | [ ] Only string literals should be passed to t()
| | where possible
251 | WARNING | [ ] Line exceeds 80 characters; contains 104
| | characters
258 | ERROR | [x] Expected newline after closing brace
259 | WARNING | [ ] Line exceeds 80 characters; contains 84
| | characters
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ...osed_filters/src/Plugin/better_exposed_filters/filter/Single.php
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 1 LINE
----------------------------------------------------------------------
61 | ERROR | [x] Use null coalesce operator instead of ternary
| | operator.
61 | ERROR | [x] Use null coalesce operator instead of ternary
| | operator.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

FILE: ...d_filters/src/Plugin/views/exposed_form/BetterExposedFilters.php
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
924 | ERROR | The array declaration extends to column 94 (the limit
| | is 80). The array content should be split up over
| | multiple lines
925 | ERROR | The array declaration extends to column 99 (the limit
| | is 80). The array content should be split up over
| | multiple lines
----------------------------------------------------------------------

FILE: .../better_exposed_filters/tests/modules/bef_test/bef_test.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: ...ters/tests/src/FunctionalJavascript/BetterExposedFiltersTest.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
----------------------------------------------------------------------
79 | WARNING | Unused variable $display.
135 | WARNING | Unused variable $display.
136 | WARNING | Unused variable $block.
192 | WARNING | Unused variable $display.
----------------------------------------------------------------------

FILE: ...osed_filters/tests/src/Kernel/BetterExposedFiltersKernelTest.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
26 | WARNING | Unused variable $display.
51 | WARNING | Unused variable $display.
----------------------------------------------------------------------

FILE: ...ilters/tests/src/Kernel/Plugin/filter/FilterWidgetKernelTest.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
----------------------------------------------------------------------
81 | WARNING | Unused variable $display.
125 | WARNING | Unused variable $display.
----------------------------------------------------------------------

FILE: .../tests/src/Kernel/Plugin/filter/HiddenFilterWidgetKernelTest.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
27 | WARNING | Unused variable $display.
----------------------------------------------------------------------

FILE: .../tests/src/Kernel/Plugin/filter/SingleFilterWidgetKernelTest.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
27 | WARNING | Unused variable $display.
----------------------------------------------------------------------

FILE: ...lters/tests/src/Kernel/Plugin/sort/LinksSortWidgetKernelTest.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
27 | WARNING | Unused variable $display.
----------------------------------------------------------------------

FILE: ...ests/src/Kernel/Plugin/sort/RadioButtonsSortWidgetKernelTest.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
27 | WARNING | Unused variable $display.
----------------------------------------------------------------------

Time: 1.9 secs; Memory: 16MB

Steps to reproduce

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

Proposed resolution

Fix the errors by running Phpcbf.

📌 Task
Status

Closed: outdated

Version

6.0

Component

Code

Created by

🇮🇳India shivam-kumar

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

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇳India rajneeshb New Delhi

    Patch #2 doesn't apply.

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

    Rerolled patch #3, please review it.

    Thanks!

  • Status changed to Needs work over 1 year ago
  • 🇮🇳India rajneeshb New Delhi

    Patch #5 applied but there are still coding standard issues
    FILE: /modules/contrib/better_exposed_filters/tests/src/FunctionalJavascript/BetterExposedFiltersTest.php
    --------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
    --------------------------------------------------------------------------------------------------------------------------------------------------
    79 | WARNING | Unused variable $display.
    135 | WARNING | Unused variable $display.
    136 | WARNING | Unused variable $block.
    192 | WARNING | Unused variable $display.
    --------------------------------------------------------------------------------------------------------------------------------------------------

    FILE: /modules/contrib/better_exposed_filters/tests/src/Kernel/Plugin/sort/LinksSortWidgetKernelTest.php
    -------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------------------------------
    27 | WARNING | Unused variable $display.
    -------------------------------------------------------------------------------------------------------------------------------------------------

    FILE: /modules/contrib/better_exposed_filters/tests/src/Kernel/Plugin/sort/RadioButtonsSortWidgetKernelTest.php
    --------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------------------------------------------------------
    27 | WARNING | Unused variable $display.
    --------------------------------------------------------------------------------------------------------------------------------------------------------

    FILE: /modules/contrib/better_exposed_filters/tests/src/Kernel/Plugin/filter/SingleFilterWidgetKernelTest.php
    ------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------------------------------------
    27 | WARNING | Unused variable $display.
    ------------------------------------------------------------------------------------------------------------------------------------------------------

    FILE: /modules/contrib/better_exposed_filters/tests/src/Kernel/Plugin/filter/FilterWidgetKernelTest.php
    ------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    ------------------------------------------------------------------------------------------------------------------------------------------------
    81 | WARNING | Unused variable $display.
    125 | WARNING | Unused variable $display.
    ------------------------------------------------------------------------------------------------------------------------------------------------

    FILE: /modules/contrib/better_exposed_filters/tests/src/Kernel/Plugin/filter/HiddenFilterWidgetKernelTest.php
    ------------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------------------------------------
    27 | WARNING | Unused variable $display.
    ------------------------------------------------------------------------------------------------------------------------------------------------------

    FILE: /modules/contrib/better_exposed_filters/tests/src/Kernel/BetterExposedFiltersKernelTest.php
    ------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    ------------------------------------------------------------------------------------------------------------------------------------------
    26 | WARNING | Unused variable $display.
    51 | WARNING | Unused variable $display.
    ------------------------------------------------------------------------------------------------------------------------------------------

    FILE: /modules/contrib/better_exposed_filters/includes/better_exposed_filters.theme.inc
    --------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------------------------------------
    162 | WARNING | '@todo' should match the format '@todo Fix problem X here.'
    --------------------------------------------------------------------------------------------------------------------------------

    FILE: /modules/contrib/better_exposed_filters/README.md
    ------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------
    42 | WARNING | Line exceeds 80 characters; contains 94 characters
    ------------------------------------------------------------------------------------------------

    FILE: /modules/contrib/better_exposed_filters/better_exposed_filters.install
    ---------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    ---------------------------------------------------------------------------------------------------------------------
    223 | WARNING | Line exceeds 80 characters; contains 84 characters
    227 | WARNING | Line exceeds 80 characters; contains 83 characters
    ---------------------------------------------------------------------------------------------------------------------

    FILE: /modules/contrib/better_exposed_filters/src/Plugin/better_exposed_filters/filter/DatePickers.php
    -----------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------------------
    41 | WARNING | Unused variable $element.
    -----------------------------------------------------------------------------------------------------------------------------------------------

    FILE: /modules/contrib/better_exposed_filters/src/Plugin/better_exposed_filters/filter/FilterWidgetBase.php
    ----------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
    ----------------------------------------------------------------------------------------------------------------------------------------------------
    116 | WARNING | Only string literals should be passed to t() where possible
    185 | WARNING | Only string literals should be passed to t() where possible
    251 | WARNING | Line exceeds 80 characters; contains 104 characters
    260 | WARNING | Line exceeds 80 characters; contains 84 characters
    ----------------------------------------------------------------------------------------------------------------------------------------------------

    FILE: /modules/contrib/better_exposed_filters/src/Plugin/BetterExposedFiltersWidgetBase.php
    ------------------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------------------
    159 | WARNING | Unused bound variable $form.
    159 | WARNING | Unused bound variable $element.
    ------------------------------------------------------------------------------------------------------------------------------------

    FILE: /modules/contrib/better_exposed_filters/src/Plugin/views/exposed_form/BetterExposedFilters.php
    ---------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    ---------------------------------------------------------------------------------------------------------------------------------------------
    924 | ERROR | The array declaration extends to column 94 (the limit is 80). The array content should be split up over multiple lines
    925 | ERROR | The array declaration extends to column 99 (the limit is 80). The array content should be split up over multiple lines
    ---------------------------------------------------------------------------------------------------------------------------------------------

    FILE: /modules/contrib/better_exposed_filters/src/BetterExposedFiltersHelper.php
    -------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 2 LINES
    -------------------------------------------------------------------------------------------------------------------------
    80 | WARNING | Unused variable $value.
    80 | WARNING | Unused variable $value.
    83 | WARNING | Unused variable $value.
    -------------------------------------------------------------------------------------------------------------------------

  • First commit to issue fork.
  • Assigned to urvashi_vora
  • 🇮🇳India urvashi_vora Madhya Pradesh, India

    I am working on this.

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇮🇳India urvashi_vora Madhya Pradesh, India

    Please review, thanks.

  • 🇮🇹Italy apaderno Brescia, 🇮🇹
  • Status changed to Needs work over 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    -  // Push jquery_ui_touch_punch module for installation if it isn't enabled already.
    +  // Push jquery_ui_touch_punch module for
    +  // installation if it isn't enabled already.

    That comment is useless, since it describes what the code already makes clear. Actually, the code is clearer, as pushing a module is not a phrase that makes sense, at least to me.
    That comment should be removed, not edited.

    -                $(this).prop('checked', true);
    +                $(this).prop('checked', TRUE);
                     // @TODO:
                     // _bef_highlight(this, context);

    I think that the formatting for @todo is also valid for JavaScript files.

    -   * @todo: To be honest, I'm not sure this is needed.  Can you set a
    +   * @todo To be honest, I'm not sure this is needed.  Can you set a
        * Date API field to accept anything other than Y-m-d? Well, better
        * safe than sorry...

    Since that comment is changed, the sentence following @todo should also be changed, for example to Verify this is really needed.

    -        // Determine if wrapper element has min or max fields or if collapsible, if so then update type.
    +        // Determine if wrapper element has min or max fields
    +        // or if collapsible, if so then update type.

    The first if should be replaced with it is.
    The comma needs to be replaced by a semicolon.
    There are missing articles to add.

    Determine if the wrapper element has min or max fields or it is collapsible; if so, then update the type.

    -    $display = &$view->storage->getDisplay('default');
    -
    +    // $display = &$view->storage->getDisplay('default');

    Patches/MRs for these issues should never comment out code. Either the code is fixed, removed, or it is left as it is.
    In the case of a variable that is initialized but never used, the code should be removed.

  • 🇮🇳India urvashi_vora Madhya Pradesh, India

    Thanks for your valuable feedback, will make the appropriate changes in next patch.

  • Status changed to Needs review over 1 year ago
  • 🇮🇳India urvashi_vora Madhya Pradesh, India
  • Status changed to Needs work over 1 year ago
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    -                $(this).prop('checked', true);
    -                // @TODO:
    -                // _bef_highlight(this, context);
    +                $(this).prop('checked', TRUE);
    +                // @todo: _bef_highlight(this, context);

    If the _bef_highlight() function exists, @todo can be removed. If that function does not exist, the sentence after @todo should be explicit and say Implement _bef_highlight(). for example.

    -      // @TODO: Put this somewhere else...
    +      // @todo: Put this somewhere else...

    The colon after @todo is not necessary. The sentence should end with a period; the ellipsis is not necessary, in that case.

    -            $this.parents('ul').siblings('div').find('input:checkbox').prop('checked', false);
    +            $this.parents('ul').siblings('div').find('input:checkbox').prop('checked', FALSE);

    That is a change for PHP code. On JavaScript, it is different. (See big_pipe.js, for example.)

    +   * @todo to Verify this is really needed
    +   * 
    +   * If we could set a Date API field to accept anything 
    +   * other than Y-m-d? 
    +   * 

    Remove to and add the period at the end of the sentence.
    The other sentence is not necessary.

  • PHPCS fixed and exclude js in phpcs command. some error are still open to fix.

    FILE: /var/www/html/modules/contrib/better_exposed_filters/src/BetterExposedFiltersHelper.php
    ---------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 2 LINES
    ---------------------------------------------------------------------------------------------
     80 | WARNING | Unused variable $value.
     80 | WARNING | Unused variable $value.
     83 | WARNING | Unused variable $value.
    ---------------------------------------------------------------------------------------------
    
    
    FILE: /var/www/html/modules/contrib/better_exposed_filters/src/Plugin/better_exposed_filters/filter/DatePickers.php
    -------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------
     41 | WARNING | Unused variable $element.
    -------------------------------------------------------------------------------------------------------------------
  • 🇮🇹Italy apaderno Brescia, 🇮🇹
    +   * @todo to Verify this is really needed
    +   * If we could set a Date API field to accept anything
    +   * other than Y-m-d?
    

    to before Verify must be removed.
    The sentence does not end with a period.
    The other sentence should be completely changed in a question.

    -        // Determine if wrapper element has min or max fields or if collapsible, if so then update type.
    +        // Determine if wrapper element has min or max fields
    +        // or it is collapsible, if so then update type.
    

    That is an example of comma-split sentence (to avoid).
    An article is missing before wrapper element.

  • 🇮🇳India Shreyas gowda

    ERRORS are fixed but still left with some warnings

    FILE: ...p64\www\contribution\better_exposed_filters\better_exposed_filters.install
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
    --------------------------------------------------------------------------------
    223 | WARNING | Line exceeds 80 characters; contains 84 characters
    227 | WARNING | Line exceeds 80 characters; contains 83 characters
    --------------------------------------------------------------------------------

    FILE: ...tribution\better_exposed_filters\includes\better_exposed_filters.theme.inc
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------------
    162 | WARNING | '@todo' should match the format '@todo Fix problem X here.'
    --------------------------------------------------------------------------------

    FILE: C:\wamp64\www\contribution\better_exposed_filters\README.md
    ----------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------
    42 | WARNING | Line exceeds 80 characters; contains 94 characters
    ----------------------------------------------------------------------

    FILE: ...osed_filters\src\Plugin\better_exposed_filters\filter\FilterWidgetBase.php
    --------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
    --------------------------------------------------------------------------------
    116 | WARNING | Only string literals should be passed to t() where possible
    185 | WARNING | Only string literals should be passed to t() where possible
    251 | WARNING | Line exceeds 80 characters; contains 104 characters
    260 | WARNING | Line exceeds 80 characters; contains 84 characters

  • Status changed to Needs review 4 months ago
  • 🇮🇳India chaitanyadessai

    Patch added please review.

  • Status changed to Closed: outdated 3 months ago
  • 🇺🇸United States smustgrave

    Will be handled else where.

Production build 0.69.0 2024