-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the navigation to Services maintab after viewing a Generic Object item via Services Explorer #2992
Fix the navigation to Services maintab after viewing a Generic Object item via Services Explorer #2992
Conversation
@miq-bot add_label bug,gaprindashvili/yes |
@lgalis Can you review/test this? |
dba9615
to
292a0ca
Compare
@AparnaKarve - looks good, tested in the UI |
Checked commits AparnaKarve/manageiq-ui-classic@a967317~...644ad84 with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0 |
@lgalis Thanks for testing this. @dclarizio I have addressed 1 of the 2 code climate issues. |
…vigate_away Fix the navigation to Services maintab after viewing a Generic Object item via Services Explorer (cherry picked from commit f4d4d43) https://bugzilla.redhat.com/show_bug.cgi?id=1524715
Gaprindashvili backport details:
|
@@ -42,11 +42,11 @@ def show | |||
@lastaction = "show" | |||
|
|||
@gtl_url = "/show" | |||
@display = params[:display] if params[:display] | |||
|
|||
set_display |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AparnaKarve, @dclarizio : don't do/merge such things, please.
Problems with this:
- the show methods have certain structure. I and other people are working to refactor them all in the same way. If we refactor one of them in a different way, the situation is not getting any better. On the contrary. Anyone grepping the sources for patterns will miss this one. Also the automated tools looking for similar code will miss this one.
- This change replaces one issue with another. The 2 extracted lines are moved into method named
set_display
. That immediately creates an issue because methods should not be namedset_*
orget_*
.
Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change was done to address cyclomatic complexity in the method.
Usually Rubocop explicitly mentions about set_
or get_
usage in method names -- but as you can see, in this case, Rubocop is all clean.
Has the set_
/get_
method name restriction been removed? -- we are not getting those warnings anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change was done to address cyclomatic complexity in the method.
I can see that in the commit message. However I don't find that information relevant in the context of my comment.
Usually Rubocop explicitly mentions about set_ or get_ usage in method names -- but as you can see, in this case, Rubocop is all clean.
I am not aware of such change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@martinpovolny can you recommend the right way to fix this so we can change it upstream with a follow up PR? Thx, Dan
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this particular case, where the choice is between keeping an existing pattern that exists in the other controllers Vs fixing the cyclomatic complexity, I would favor fixing the cyclomatic complexity.
(content edited)
I think it is a good idea to have a separate method that sets @display
, which has a special significance in the code, rather than blending it up with rest of the show
method
Maybe the other controllers should be having a dedicated method for setting @display
too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this particular case, where the choice is between keeping an existing pattern that exists in the other controllers Vs fixing the cyclomatic complexity, I would favor fixing the cyclomatic complexity.
I would not.
It all boils down to a simple fact: If we refactor similar stuff differently in different places, we increase the cost of maintenance from that point in time until a point where someone actually unifies the similar places back.
I hope that it's clear that maintaining 2 different routines that do the same thing is more expensive than maintaining one.
Also the cost of refactoring that piece increases. Someone will have to find the places (that look less similar now), reason about why these are different: Is there some functional difference? Is there a bug? Then probably unify the code back and then replace it with refactored code.
I can try to reword the reasons behind that or I can show you a number of examples.
If you compare the cost of the above vs the cost of keeping the "cyclomatic complexity" warning in place would you still prefer "fixing" the problem?
I urge everyone to think in the context of the whole app. Not in the context of a single method or controller. If the controllers or methods in them that do the very same thing differ too much due to people refactoring each piece in a different way the project will not be maintainable at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, noted the above.
To remove this cyclomatic complexity fix in upstream, we could simply revert 644ad84
Fixed the navigation to Services maintab issue reproduced with the steps below -
https://bugzilla.redhat.com/show_bug.cgi?id=1523396