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

Implement -ignore #11

Closed
wants to merge 1 commit into from
Closed

Implement -ignore #11

wants to merge 1 commit into from

Conversation

jgautheron
Copy link

This PR implements the possibility to ignore files that match the given regular expression.
Fixes #9, #4 (generic approach).

Example:

$ gocyclo -ignore "yacc|\.pb\.|Godeps" .

if len(*ignore) == 0 {
return false
}
match, err := regexp.MatchString(*ignore, path)
Copy link

Choose a reason for hiding this comment

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

you should really use regexp.MustCompile here or manually panic on error. This currently behaves badly on malformed regexes

Copy link
Author

Choose a reason for hiding this comment

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

Indeed, this can be misleading: fixed.

Copy link

Choose a reason for hiding this comment

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

Did you mean to fix this?

EDIT: ah, you're manually panicking.

Copy link

Choose a reason for hiding this comment

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

Actually, you should probably implement the flag.Value interface for a regexp while you're here.

}
match, err := regexp.MatchString(*ignore, path)
if err != nil {
log.Fatal(err)
Copy link

Choose a reason for hiding this comment

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

looks like exitError is used elsewhere

nevermind, that was an old rev

@tamird
Copy link

tamird commented Feb 8, 2016

LGTM. @fzipp any chance of merging this?

@GregorioDiStefano
Copy link

You can also use something like:

`"~/go/bin/gocyclo -avg `find . -iname '*.go' | grep -v 'Godeps' | grep -v '_test.go'`"`

@LasTshaMAN
Copy link

Why this still isn't merged ?

@bkielbasa
Copy link

Hi! I'm working on the alternative for this project https://github.com/bkielbasa/cyclop
If you want to contribute, just do it :) I'll be happy to hear about ideas and PRs.

fzipp added a commit that referenced this pull request Oct 17, 2020
@fzipp
Copy link
Owner

fzipp commented Oct 17, 2020

Fixed by 4a36b7d

@fzipp fzipp closed this Oct 17, 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.

ignore generated code
6 participants