Skip to content
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

Merged

Conversation

AparnaKarve
Copy link
Contributor

Fixed the navigation to Services maintab issue reproduced with the steps below -

  1. Navigate to Services -> My Services -> Select the Service with the GO instance
  2. Click on the GO Instances count in the Summary screen
  3. Pick a GO Instance to view in detail
  4. Click on the Services maintab on the left

https://bugzilla.redhat.com/show_bug.cgi?id=1523396

@AparnaKarve
Copy link
Contributor Author

@miq-bot add_label bug,gaprindashvili/yes

@AparnaKarve
Copy link
Contributor Author

@lgalis Can you review/test this?
Thanks.

@AparnaKarve AparnaKarve force-pushed the bz1523396_fix_go_service_navigate_away branch from dba9615 to 292a0ca Compare December 9, 2017 03:01
@lgalis
Copy link
Contributor

lgalis commented Dec 11, 2017

@AparnaKarve - looks good, tested in the UI

@miq-bot
Copy link
Member

miq-bot commented Dec 11, 2017

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
3 files checked, 0 offenses detected
Everything looks fine. ⭐

@AparnaKarve
Copy link
Contributor Author

@lgalis Thanks for testing this.

@dclarizio I have addressed 1 of the 2 code climate issues.
The current code climate issue above would need a more involved refactoring and hence not considering resolving it now.

@dclarizio dclarizio self-assigned this Dec 11, 2017
@dclarizio dclarizio merged commit f4d4d43 into ManageIQ:master Dec 11, 2017
@dclarizio dclarizio added this to the Sprint 75 Ending Dec 11, 2017 milestone Dec 11, 2017
simaishi pushed a commit that referenced this pull request Dec 11, 2017
…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
@simaishi
Copy link
Contributor

Gaprindashvili backport details:

$ git log -1
commit 5e560f59a2e6ce8cd6af8d8a177fa8ff61f59564
Author: Dan Clarizio <[email protected]>
Date:   Mon Dec 11 11:13:07 2017 -0800

    Merge pull request #2992 from AparnaKarve/bz1523396_fix_go_service_navigate_away
    
    Fix the navigation to Services maintab after viewing a Generic Object item via Services Explorer
    (cherry picked from commit f4d4d4388a0b9c072e7fdcc7d3919c17a8764a40)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1524715

@@ -42,11 +42,11 @@ def show
@lastaction = "show"

@gtl_url = "/show"
@display = params[:display] if params[:display]

set_display
Copy link
Member

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:

  1. 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.
  2. 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 named set_* or get_*.

Thank you!

Copy link
Contributor Author

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.

Copy link
Member

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.

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

Copy link
Contributor Author

@AparnaKarve AparnaKarve Jan 9, 2018

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.

Copy link
Member

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.

Copy link
Contributor Author

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

@AparnaKarve AparnaKarve deleted the bz1523396_fix_go_service_navigate_away branch January 9, 2018 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants