Part of meta-issue #2002650: [meta, no patch] improve maintainability by removing unused local variables
File /core/modules/views_ui/lib/Drupal/views_ui/Tests/DisplayTest.php
Line 123: Unused local variable $path_prefix
File /core/modules/views_ui/lib/Drupal/views_ui/Tests/ViewsUITourTest.php
Line 55: Unused local variable $view_path
| Comment | File | Size | Author |
|---|---|---|---|
| #28 | core-remove-unused-variable-2061397-28.patch | 1.36 KB | baisong |
| #24 | interdiff.txt | 833 bytes | drupalninja99 |
| #24 | core-remove-unused-variable-2061397-24.patch | 3.24 KB | drupalninja99 |
| #18 | 2061397-11-17-interdiff.txt | 681 bytes | Anonymous (not verified) |
| #17 | core-remove-unused-variable-2061397-17.patch | 2.73 KB | Anonymous (not verified) |
Comments
Comment #1
manu4543 commentedComment #2
sergeypavlenko commented"warning: 1 line adds whitespace errors."
Please delete unneeded spaces from a string 124.
Comment #3
giammi commentedComment #4
Anonymous (not verified) commented#3 applies, however I don't believe the variable
$path_prefixis supposed to be unused, I think there's a line missing. The code is as follows:Should be:
Comment #5
Anonymous (not verified) commentedHere's a patch for my suggestion in #4
Comment #6
Anonymous (not verified) commentedFor the sake of consistency in code I've re-rolled the above patch so the blank line appears in the same place as in rest of the code
Comment #7
dawehnerYeah this makes more sense.
Comment #8
alexpottHmmm.... does it?
The
drupalPostForm()here means that we should be on the view edit page. Doing$this->drupalGet($path_prefix);means that we need to make yet another request via the simpletest browser. I'd like to see this patch remove the unnecessary$this->drupalGet($path_prefix);from the other tests.Comment #9
Anonymous (not verified) commentedAh, yes, I see. Thanks!
Comment #10
Anonymous (not verified) commentedHm, I missed some out.
Comment #11
Anonymous (not verified) commentedOk, I think this is the right combination of removing unused variables and unused extra test calls.
Comment #12
parthipanramesh commentedapplied without any issues
Comment #13
webchickBack to alexpott for review.
Comment #14
xjmPlease confirm that all other unused local variables are also removed from the Views UI module. Thanks!
Comment #15
Anonymous (not verified) commentedHaving worked on this issue I saw the update wrt is this the last unused variable so thought I'd check - I didn't notice at the time it was already assigned!
First I checked through #2002650: [meta, no patch] improve maintainability by removing unused local variables for all issues affecting 'views_ui' and found the following which I checked each one and they had all been committed:
#2081193: Remove Unused local variable $display from /core/modules/views_ui/views_ui.module
#2080047: Remove Unused local variable from views_ui module
#2080033: Remove Unused local variable $section from /core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/Display.php
#2062755: Remove Unused local variable $view from /core/modules/views_ui/lib/Drupal/views_ui/Tests/RowUITest.php
#2062179: Remove Unused local variable $view from /core/modules/views_ui/lib/Drupal/views_ui/Tests/StyleUITest.php
#2080413: Remove Unused local variable $view from /core/modules/views_ui/lib/Drupal/views_ui/Tests/RedirectTest.php
#2080035: Remove Unused local variable $name from /core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/RearrangeFilter.php
#2079891: Remove Unused local variable $name from /core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/Rearrange.php
#2079881: Remove Unused local variable $stack from /core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php
#2080079: Remove Unused local variable $display_title from /core/modules/views_ui/lib/Drupal/views_ui/ViewEditFormController.php
Then I applied patch the latest patch from this issue #2061397-11: Remove unused local variables from the Views UI module and used PHPStorm's code inspection to check for any unused variables.
I found two further unused variables, one in a Tour test case so potentially been introduced since these issues were originally created, and another caused by this patch - it removed a variable which was using $view so when that was removed $view became unused too.
I've attached a re-rolled patch with these two new issues - I see a lot of merging has been going on so didn't create new issues however I shall update the summary to reflect these additions.
Now code inspection says no unused variables in views_ui module directory.
Comment #17
Anonymous (not verified) commentedMany apologies, please ignore previous - forgot to test locally and of course $view is needed in the test even though not 'used'. The other unused variable is indeed not used so attached is re-rolled patch from #11 with that in and the used $view variable back in again. Summary also updated.
Comment #18
Anonymous (not verified) commentedAttached 2 patches instead of patch and interdiff, here's the interdiff.
Comment #19
parthipanramesh commentedLooks fine to me!
Comment #20
webchickCool, thanks. One thing...
While this passes, it's only coincidentally so. The assertFalse() down below is making sure that the disabled class it not appearing, which of course it's not, because $this->xpath() is most likely being passed into it a blank string since we haven't actually retrieved an HTML page for it to check. :)
So I think those two need to be removed, but the rest looks fine.
Comment #21
webchickComment #22
Anonymous (not verified) commentedI've read this again and again but I'm still not sure what needs to be done. I understand the issue with the coincidental working of the test but unsure how to fix.
Comment #23
martin107 commented@stevepurkiss what she means is please delete the two lines ( prefixed with '-' )
and the patch is good to go...
- $path_prefix = 'admin/structure/views/view/' . $view['id'] .'/edit';
- $this->drupalGet($path_prefix);
I hope this helps, I assume that you want to do this .. if not, I will lurk on this issue, and sort it out in about a week.
PS the patch still applies
Comment #24
drupalninja99 commentedTaking a crack at it..
Comment #26
Anonymous (not verified) commentedI don't think that is the issue, those lines were taken out already, the patch in #24 erroneously removes in the test remove display function where it is needed.
[edit: hm, not sure why it has file flagged as deleted, wasn't me...!]
Comment #27
drupalninja99 commentedACK! thx
Comment #28
baisongHi, I was just told to look at this issue in core mentoring hours on #drupal IRC.
Patch attached.
Comment #29
baisongComment #30
jayeshanandani commentedLooks good to me! RTBC!
Comment #32
gokulnk commented28: core-remove-unused-variable-2061397-28.patch queued for re-testing.
Comment #33
dawehnerback to RTBC
Comment #34
webchickAll right, let's get this one in.
Committed and pushed to 8.x. Thanks!