\Drupal calls should be avoided in classes, use dependency injection instead

Created on 7 March 2024, 9 months ago
Updated 30 July 2024, 4 months ago

Problem/Motivation

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

šŸ“Œ Task
Status

RTBC

Version

3.0

Component

Code

Created by

šŸ‡®šŸ‡³India chaitanyadessai Goa

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 @chaitanyadessai
  • Status changed to Needs review 9 months ago
  • Open in Jenkins ā†’ Open on Drupal.org ā†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 9 months ago
    14 pass
  • šŸ‡®šŸ‡³India chaitanyadessai Goa

    Please review.

  • šŸ‡®šŸ‡³India Ashutosh Ahirwal India

    Hi I have reviewed the patch and it fixes all the issue related to dependency injection but still there are so many issue found related to phpcs
    Moving to RTBC.

    Used command
    ./vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md,css,js,yml web/modules/custom/rate

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/rate/js/w-thumbsup.js
    ----------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------
    18 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
    ----------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/rate/js/w-yesno.js
    -------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------
    18 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
    -------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/rate/js/w-fivestar.js
    ----------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------
    24 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
    ----------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/rate/js/w-numberupdown.js
    --------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------
    18 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
    --------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/rate/js/unvote-helper.js
    -------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------
    23 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "FALSE" but found "false"
    -------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/rate/js/w-custom.js
    --------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------
    18 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
    --------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/rate/js/w-emotion.js
    ---------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ---------------------------------------------------------------------------------------------
    18 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
    ---------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ---------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/rate/js/w-thumbsupdown.js
    --------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------------------------------
    18 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
    --------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/rate/rate.api.php
    ------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------
    3 | ERROR | Missing short description in doc comment
    ------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/rate/src/Controller/WidgetResultsController.php
    ------------------------------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ------------------------------------------------------------------------------------------------------------------------
    102 | WARNING | Unused variable $id.
    ------------------------------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/rate/src/RateWidgetForm.php
    ----------------------------------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    ----------------------------------------------------------------------------------------------------
    292 | WARNING | Unused variable $plugin_id.
    ----------------------------------------------------------------------------------------------------

    Time: 1.79 secs; Memory: 18MB

  • Open in Jenkins ā†’ Open on Drupal.org ā†’
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update 8 months ago
    PHPLint Failed
  • šŸ‡®šŸ‡³India pray_12

    Hi,
    Addressed the remaining errors and warnings in the updated patch; we can ignore these 2 errors for readability purposes.

    FILE: .../src/Plugin/RateWidgetBase.php
    ----------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    ----------------------------------------------------------------------------
     290 | ERROR | The array declaration extends to column 118 (the limit is
         |       | 80). The array content should be split up over multiple
         |       | lines
     296 | ERROR | The array declaration extends to column 103 (the limit is
         |       | 80). The array content should be split up over multiple
         |       | lines
    ----------------------------------------------------------------------------
    
  • Status changed to RTBC 4 months ago
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi @pray_12,

    I applied patch#4, it was applied smoothly and fixed the phpcs issues.

    āžœ  rate git:(3.0.x) curl https://www.drupal.org/files/issues/2024-03-18/3426250-4.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 11619  100 11619    0     0  30663      0 --:--:-- --:--:-- --:--:-- 30738
    patching file js/unvote-helper.js
    patching file js/w-custom.js
    patching file js/w-emotion.js
    patching file js/w-fivestar.js
    patching file js/w-numberupdown.js
    patching file js/w-thumbsup.js
    patching file js/w-thumbsupdown.js
    patching file js/w-yesno.js
    patching file rate.api.php
    patching file rate.module
    patching file src/Controller/WidgetResultsController.php
    patching file src/Form/RateWidgetBaseForm.php
    patching file src/Plugin/RateBotDetector.php
    patching file src/Plugin/migrate/source/RateWidget.php
    patching file src/RatePermissions.php
    patching file src/RateWidgetForm.php
    āžœ  rate git:(3.0.x) āœ— ..
    āžœ  contrib phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml rate
    āžœ  contrib

    Thank you.

Production build 0.71.5 2024