Skip to content

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

Merged
merged 10 commits into from
Oct 23, 2020

Conversation

dtcaciuc
Copy link
Collaborator

No description provided.

@dtcaciuc dtcaciuc changed the title Factoring out exclusion flags into separate struct Factor out exclusion flags into separate struct Aug 19, 2020
@dtcaciuc dtcaciuc changed the title Factor out exclusion flags into separate struct Factor out exclusion flags into a separate struct Aug 19, 2020
@dtcaciuc dtcaciuc marked this pull request as ready for review August 19, 2020 03:47
main.go Outdated
Comment on lines 106 to 109
if *ignore != "" {
fmt.Fprintf(os.Stderr, "error: -ignore flag is deprecated, please use -exclude and/or -ignorepkg instead")
return nil, exitFatalError
}
Copy link
Collaborator

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?

Copy link
Collaborator Author

@dtcaciuc dtcaciuc Aug 20, 2020

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

Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

// Verbose causes extra information to be output to stdout.
Verbose bool
// Symbols lists regular expression patterns that exclude package symbols.
Copy link
Owner

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed comment

// 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 {
Copy link
Owner

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

Copy link
Collaborator Author

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.

dtcaciuc and others added 4 commits October 9, 2020 22:38
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.
Copy link
Collaborator

@echlebek echlebek left a comment

Choose a reason for hiding this comment

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

worms

@echlebek echlebek merged commit 720fbcb into kisielk:publish-api Oct 23, 2020
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