Skip to content

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
Contributor

@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
Contributor

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
Contributor

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