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

govet: implement analyzers config #697

Merged
merged 4 commits into from
Sep 15, 2019
Merged

Conversation

ernado
Copy link
Member

@ernado ernado commented Sep 14, 2019

Fix #696, #446

Please feel free to request any changes.

@ernado ernado force-pushed the govet-config branch 3 times, most recently from fc1260e to c656992 Compare September 14, 2019 21:10
I'm not sure why CI is failing.
Copy link
Member

@jirfag jirfag left a comment

Choose a reason for hiding this comment

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

thank you! just a few comments

}
for _, n := range cfg.Disable {
if n == name {
return true
Copy link
Member

Choose a reason for hiding this comment

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

I guess it should be

Suggested change
return true
return false

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right, nice catch!
I've also added a corresponding test for that function.

return false
}

func analyzersFromConfig(cfg *config.GovetSettings) []*analysis.Analyzer {
Copy link
Member

Choose a reason for hiding this comment

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

please, add minimal validation to (r *FileReader) validateConfig() by calling something like:

func (cfg *config.GovetSettings) Validate() error {
    if cfg.EnableAll && cfg.DisableAll {
        return errors.New("enable-all and disable-all can't be combined")
    }
    if cfg.EnableAll && len(cfg.Enable) != 0) {
        return errors.New("enable-all and enable can't be combined")
    }
    if cfg.DisableAll && len(cfg.Disable) != 0) {
        return errors.New("disable-all and disable can't be combined")
    }
    return nil
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, thank you.
We probably want to validate that cfg.Enable contains valid analyzer names, but I'm not sure how to do it in that scope.

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.

govet: allow analyzers suite configuration
3 participants