File::load calls should be avoided in classes, use dependency injection instead

Created on 28 June 2023, over 1 year ago
Updated 23 July 2024, 5 months ago

FILE: D:\xampp\htdocs\drupal_10\web\modules\contrib\file_browser\src\Plugin\Block\ImageEmbedBlock.php
-----------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 4 WARNINGS AFFECTING 4 LINES
-----------------------------------------------------------------------------------------------------
121 | WARNING | File::load calls should be avoided in classes, use dependency injection instead
123 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
216 | WARNING | File::load calls should be avoided in classes, use dependency injection instead
219 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
-----------------------------------------------------------------------------------------------------

šŸ“Œ Task
Status

Needs work

Version

1.0

Component

Code

Created by

šŸ‡®šŸ‡³India arti_parmar

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 @arti_parmar
  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • šŸ‡®šŸ‡³India arti_parmar

    Kindly review patch.

  • Status changed to Needs work 11 months ago
  • šŸ‡®šŸ‡³India ashutosh ahirwal India

    Provided patch in #2 applied cleanly but still there are error found by phpcs

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

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/file_browser/js/file_browser.view.js
    -------------------------------------------------------------------------------------------------------------
    FOUND 2 ERRORS AFFECTING 2 LINES
    -------------------------------------------------------------------------------------------------------------
    70 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
    71 | ERROR | [x] TRUE, FALSE and NULL must be uppercase; expected "TRUE" but found "true"
    -------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -------------------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/file_browser/file_browser.module
    -----------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------
    9 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Form\FormStateInterface.
    -----------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/file_browser/tests/src/Functional/InstallTest.php
    -------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------------------------------
    20 | ERROR | Do not disable strict config schema checking in tests. Instead ensure your module properly declares its schema for configurations.
    -------------------------------------------------------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/file_browser/file_browser.install
    --------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 5 ERRORS AND 1 WARNING AFFECTING 6 LINES
    --------------------------------------------------------------------------------------------------------------------------------------------
    11 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\File\FileSystemInterface.
    101 | ERROR | [ ] The array declaration extends to column 95 (the limit is 80). The array content should be split up over multiple lines
    104 | WARNING | [ ] Unused variable $text.
    123 | ERROR | [ ] The array declaration extends to column 95 (the limit is 80). The array content should be split up over multiple lines
    223 | ERROR | [ ] The array declaration extends to column 97 (the limit is 80). The array content should be split up over multiple lines
    245 | ERROR | [ ] The array declaration extends to column 95 (the limit is 80). The array content should be split up over multiple lines
    --------------------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/file_browser/src/Plugin/views/field/FileBrowserPreview.php
    -----------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -----------------------------------------------------------------------------------------------------------------------------------
    72 | ERROR | [x] list(...) is forbidden, use [...] instead.
    -----------------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    -----------------------------------------------------------------------------------------------------------------------------------

    FILE: /Users/ashutoshahirwal/Sites/lando/contribution/web/modules/custom/file_browser/src/Plugin/Block/ImageEmbedBlock.php
    ----------------------------------------------------------------------------------------------------------------------------
    FOUND 6 ERRORS AND 1 WARNING AFFECTING 7 LINES
    ----------------------------------------------------------------------------------------------------------------------------
    8 | WARNING | [x] Unused use statement
    9 | ERROR | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Image\ImageFactory.
    23 | ERROR | [x] Whitespace found at end of line
    38 | ERROR | [ ] Parameter $entity_type_manager is not described in comment
    86 | ERROR | [x] Use null coalesce operator instead of ternary operator.
    189 | ERROR | [x] Use null coalesce operator instead of ternary operator.
    270 | ERROR | [x] Use null coalesce operator instead of ternary operator.
    ----------------------------------------------------------------------------------------------------------------------------
    PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------------------------------------------------------------

    Time: 299ms; Memory: 12MB

  • Assigned to PrabuEla
  • šŸ‡®šŸ‡³India PrabuEla chennai
  • Status changed to Needs review 7 months ago
  • šŸ‡®šŸ‡³India dev16.addweb

    Hello,
    Created a patch based on comment #3. Please review.

  • Status changed to Needs work 5 months ago
  • šŸ‡µšŸ‡­Philippines cleavinjosh

    Hi @silvi.addweb,

    I applied patch #5, it was applied smoothly and fixed some of the phpcs issues.

    However, I still encountered some issues after I ran phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml.

    āžœ  file_browser git:(8.x-1.x) curl https://www.drupal.org/files/issues/2024-06-04/file_browser-33710580-5.patch | patch -p1
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  6662  100  6662    0     0   8791      0 --:--:-- --:--:-- --:--:--  8788
    patching file file_browser.install
    patching file file_browser.module
    patching file src/Plugin/Block/ImageEmbedBlock.php
    patching file src/Plugin/views/field/FileBrowserPreview.php
    patching file tests/src/Functional/InstallTest.php
    āžœ  file_browser git:(8.x-1.x) āœ— ..
    āžœ  contrib phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml file_browser
    
    FILE: /Users/interns/Demo-site/drupal-org-issues/web/modules/contrib/file_browser/tests/src/Functional/InstallTest.php
    -------------------------------------------------------------------------------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    -------------------------------------------------------------------------------------------------------------------------------------------------
     22 | ERROR | Do not disable strict config schema checking in tests. Instead ensure your module properly declares its schema for configurations.
    -------------------------------------------------------------------------------------------------------------------------------------------------
    
    Time: 316ms; Memory: 12MB
    
    āžœ  contrib

    Thank you.

Production build 0.71.5 2024