Use Dependency Injection on location_selector module

Created on 27 July 2023, almost 2 years ago

Problem/Motivation

below files are not following drupal standred to use Dependency Injection.
src/Form/SettingsForm.php
src/GeoNamesService.php
src/LocationSelectorController.php
src/Plugin/Field/FieldWidget/LocationSelectorWidget.php

Steps to reproduce

during phpcs found below issue.

./vendor/bin/phpcs   --standard="Drupal,DrupalPractice"   --extensions="php,module,inc,install,test,profile,theme" web/modules/contrib/location_selector/

FILE: /home/shivsharma/project/my-drupal10-site/web/modules/contrib/location_selector/src/GeoNamesService.php
----------------------------------------------------------------------------------------------------------------------------------------------
FOUND 3 ERRORS AND 10 WARNINGS AFFECTING 11 LINES
----------------------------------------------------------------------------------------------------------------------------------------------
   6 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Config\ConfigFactoryInterface.
  12 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
  60 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
  98 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 100 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 110 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 174 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 193 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 226 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 248 | WARNING | [x] There must be no blank line following an inline comment
 248 | WARNING | [ ] There must be no blank line following an inline comment
 248 | ERROR   | [x] Inline comments must end in full-stops, exclamation marks, question marks, colons, or closing parentheses
 270 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
----------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------------------------------------------------------------------------------


FILE: /home/shivsharma/project/my-drupal10-site/web/modules/contrib/location_selector/src/LocationSelectorController.php
------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------------
 57 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
 84 | WARNING | \Drupal calls should be avoided in classes, use dependency injection instead
------------------------------------------------------------------------------------------------------------------------


FILE: /home/shivsharma/project/my-drupal10-site/web/modules/contrib/location_selector/src/Form/SettingsForm.php
---------------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 4 WARNINGS AFFECTING 5 LINES
---------------------------------------------------------------------------------------------------------------------------------------------
  7 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Config\ConfigFactoryInterface.
 12 | WARNING | [ ] The class short comment should describe what the class does and not simply repeat the class name
 25 | WARNING | [ ] Possible useless method overriding detected
 67 | WARNING | [ ] t() calls should be avoided in classes, use \Drupal\Core\StringTranslation\StringTranslationTrait and $this->t() instead
 67 | ERROR   | [ ] The array declaration extends to column 170 (the limit is 80). The array content should be split up over multiple lines
 75 | WARNING | [ ] Possible useless method overriding detected
---------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------


FILE: /home/shivsharma/project/my-drupal10-site/web/modules/contrib/location_selector/src/Plugin/Field/FieldWidget/LocationSelectorWidget.php
---------------------------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AND 2 WARNINGS AFFECTING 4 LINES
---------------------------------------------------------------------------------------------------------------------------------------------
   7 | ERROR   | [x] Use statements should be sorted alphabetically. The first wrong one is Drupal\Core\Field\WidgetBase.
 137 | WARNING | [ ] \Drupal calls should be avoided in classes, use dependency injection instead
 191 | ERROR   | [ ] The array declaration extends to column 83 (the limit is 80). The array content should be split up over multiple lines
 210 | WARNING | [x] '@todo: check separate limit level without force deepest option.' should match the format '@todo Fix problem X here.'
---------------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
---------------------------------------------------------------------------------------------------------------------------------------------

Time: 322ms; Memory: 12MB

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Active

Version

1.0

Component

Code

Created by

🇮🇳India Shiv_Sharma

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024