In core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php, testSchemaMapping() initializes $a without using it.
The variable should be removed from testSchemaMapping().
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3156070-2.patch | 777 bytes | hardik_patel_12 |
Comments
Comment #2
hardik_patel_12 commentedComment #3
siddhant.bhosale commentedComment #4
siddhant.bhosale commentedHi, I have tested the patch and the test runs successfully.
Looks good to be merged.
Comment #5
alexpottThank you for your work on cleaning up Drupal core's code style!
In order to fix core coding standards in a maintainable way, all our coding standards issues should be done on a per-rule basis across all of core, rather than fixing standards in individual modules or files. We should also separate fixes where we need to write new documentation from fixes where we need to correct existing standards. This all should be done as part of #2571965: [meta] Fix PHP coding standards in core, stage 1. A good place to for unused variables is #3106216: Remove unused variables from core.
For background information on why we usually will not commit coding standards fixes that aren't scoped in that way, see the core issue scope guidelines, especially the note about coding standards cleanups. That document also includes numerous suggestions for scoping issues including documentation coding standards cleanups.
Contributing to the overall plan above will help ensure that your fixes for core's coding standards remain in core the long term.
Comment #6
avpadernoComment #7
avpadernoI guess this issue should be re-opened in the same way other similar issues have been re-opened.
See the comment left for similar issues, for example #3156040: Avoid initializing a local variable to an empty array before adding items to that array.
Comment #8
avpadernoLooking at the core/tests/Drupal/KernelTests/Core/Config/ConfigSchemaTest.php can also help to understand when that variable was introduced, and how the current code needs to be fixed.
Comment #9
avpadernoThe
$a = \Drupal::config('config_test.dynamic.third_party');line was added in the patch provided in #2432791: Skip Config::save schema validation of config data for trusted data.It seems it's not anymore necessary, since removing that line doesn't cause any test failure.
Comment #10
avpadernoI would use a different name for the
$testvariable, but it would be an off-topic change that doesn't add much.Comment #11
alexpottThis looks some debug I might have added - oops.
Committed and pushed 700b1c92f1 to 9.1.x and b2b3ddbba5 to 9.0.x and 583402844d to 8.9.x. Thanks!
Comment #15
jungleBTW, just field one inspired by this one #3160169: Unused variable $a in \Drupal\taxonomy\Plugin\Validation\Constraint\TaxonomyTermHierarchyConstraintValidator::validate()