Skip to content

Add gometalinter#102

Merged
febbraro merged 7 commits intodevelopfrom
feature/gometalinter
Oct 29, 2017
Merged

Add gometalinter#102
febbraro merged 7 commits intodevelopfrom
feature/gometalinter

Conversation

@febbraro
Copy link
Member

added linting and addressed all feedback (and ignored 3)

Addresses #92

@febbraro febbraro requested review from grayside and tekante October 27, 2017 22:03
if err == nil {
dataUsage := strings.TrimSpace(string(output))
if i, err := strconv.Atoi(dataUsage); err == nil {
if i, e := strconv.Atoi(dataUsage); e == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why e?

Copy link
Member Author

Choose a reason for hiding this comment

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

The linter was giving warnings about the second err shadowing the one from it's parent scope.

return runtime.GOOS == "linux"
}

// IsMac detects if we are running on the darwin platform
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we have IsLinux?
Making the other checks more feature driven seems a fine followup

Copy link
Member Author

Choose a reason for hiding this comment

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

Are you sugesting an IsLinux in addition to SupportsNativeDocker()? Most of the linux checks are for a feature (native docker support) where as some of the mac checks were for things like which route command to use or this process to kill to restart dns resolution. So there is a bit of the mix in platform name and feature detection. This is the quicked line to remove linter warnings and also make the code more readable (and centralized if for some crazy reason the string "darwin" goes away.

Copy link
Contributor

Choose a reason for hiding this comment

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

My thinking was for API completeness if we have checks for the OS's we may as well have one for each that we support.

@grayside
Copy link
Contributor

Did I miss travis config?

@febbraro
Copy link
Member Author

I didn;t add travis configuration yet. I was not sure if we wanted to fail the build on linter warnings. Maybe we should? I had to exempt 3 functions from linting, one due to some nested error conditions that was not ready mentally to unpack and 2 for cyclomatic complexity. They should all be reworked but I wanted to get the superficial warnings covered and then take an separate PR to attack the complexity issues in Doctor and ProjectConfig validation.

@febbraro
Copy link
Member Author

Added travis integration for the linter

Copy link
Contributor

@grayside grayside left a comment

Choose a reason for hiding this comment

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

To answer the last question, my take on it is that we add it to Travis so that gometalinter's recommendations are forced into how rig is built, and therefore into how we write go code. We can choose to exempt code on a case by case basis if it's necessary.

Let's also file a follow-up issue for each TODO.

@febbraro febbraro merged commit 3a2e143 into develop Oct 29, 2017
@febbraro febbraro deleted the feature/gometalinter branch October 29, 2017 17:31
@grayside grayside added this to the v2.0 milestone Oct 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants