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

cleancode:util.go #44913

Merged
merged 1 commit into from
May 3, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions federation/pkg/kubefed/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,9 @@ func GetVersionedClientForRBACOrFail(hostFactory cmdutil.Factory) (client.Interf
}
return hostFactory.ClientSetForVersion(&gv)
}
for i := 0; i < len(g.Versions); i++ {
if g.Versions[i].GroupVersion != "" {
gv, err := schema.ParseGroupVersion(g.Versions[i].GroupVersion)
for _, version := range g.Versions {
if version.GroupVersion != "" {
gv, err := schema.ParseGroupVersion(version.GroupVersion)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to say this ... but I don't think this make too much difference. Do you have reason to do this, for example, code style best practice?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In function the original point equals the modification point. However modification is much cleaner and lighter than the original point. First, it does not need len(xxx) to know the loop count, and the index is not necessary for the function. Don't you think so?

if err != nil {
return nil, err
}
Expand Down