-
Notifications
You must be signed in to change notification settings - Fork 34
Cyclomatic complexity: globalize fetch dependency helper #621
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
Conversation
mandre
left a comment
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.
Thanks, this is great! Would it also be possible to update existing controllers to use this new FetchDependency() function? This would help visualize the changes made to the template.
| Description: string(ptr.Deref(filter.Description, "")), | ||
| {{- range .ImportDependencies }} | ||
| {{ . }}: ptr.Deref({{ . | camelCase }}.Status.ID, ""), | ||
| {{ . }}ID: {{ . | camelCase }}ID, |
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.
Was this a bug in the original template? I'm unclean why this is changed while ImportDependencies remains identical.
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.
Most ID fields in gophercloud uses ResourceID in ListOpts from what I saw so the change seemed appropriate, I can change it back if needed
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.
Gophercloud is not really consistent, so either is fine. We should probably have avoided a functional change in a refactoring PR but that's not the end of the world because anyone using the scaffolding tool will have, at some point, to verify what fields the List() function takes, and LSP will highlight invalid fields anyway when your editor is configured correctly.
|
@mandre sure, I'll work on updating the rest of the controllers tomorrow |
|
/retest |
6709f79 to
7fcbfa9
Compare
- create a dependency helper replacing repetative parts of code - update template to use it
- Remove local getDependencyHelper and wrapper functions from server actuator - Use dependency.FetchDependency directly in CreateResource and ListOSResourcesForImport
winiciusallan
left a comment
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.
Overall, it looks very good to me. Good job, Ella!
mandre
left a comment
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.
Really nice refactoring. Thanks a lot!
To avoid cyclomatic complexity issue I added a global dependency helper that reduces code duplication and complexity across the code (similar to the one I added to the server controller). Now it should be easier to manage dependencies and the code duplication should be (somewhat reduced).