-
Notifications
You must be signed in to change notification settings - Fork 140
Factor out exclusion flags into a separate struct #189
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
main.go
Outdated
if *ignore != "" { | ||
fmt.Fprintf(os.Stderr, "error: -ignore flag is deprecated, please use -exclude and/or -ignorepkg instead") | ||
return nil, exitFatalError | ||
} |
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.
Can you alias -ignore to another flag, or trivially transform it somehow?
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.
I don't see how I can do it without adding a special field to Exclusions struct. I tried making a special case in logic that processes Exclusions.Packages, however for that, -ignore would had to treat the absence of :<regexp>
portion at the end of each of the strings in the list as just the package name, whereas it does entirely the opposite: it assumes entire string is the regexp per https://github.com/kisielk/errcheck/blob/master/main.go#L46
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.
My concern is that it would break peoples' workflows to make this change. I know that it's been deprecated, but I feel that we should keep it, or go to 2.0.
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.
Functionality restored, PTAL
I've taken the liberty of modifying the incoming changes somewhat. The UpdateNonVendoredIgnore function has been renamed, unexported, and made to return data instead of setting it.
errcheck/errcheck.go
Outdated
|
||
// Verbose causes extra information to be output to stdout. | ||
Verbose bool | ||
// Symbols lists regular expression patterns that exclude package symbols. |
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.
Hold on a second... these are not regular expressions
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.
Fixed comment
errcheck/errcheck.go
Outdated
// getNonVendoredIgnores gets the ignore expressions for non-vendored packages. | ||
// They are returned as a map from package path names to '.*' regular | ||
// expressions. | ||
func (c *Checker) getNonVendoredIgnores() map[string]*regexp.Regexp { |
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.
This could be a standalone function that takes []string
since the only dependency it uses is c.Exclusions.Packages
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.
Refactored; this function was dissolved altogether.
Independent of whether go mod is used or not, simply strip off vendor directory prefix from both imports and excludes if it was found.
Simplify vendored package resolution.
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.
No description provided.