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

regexpMust: for const patterns like v3PeerRegex, use regexp.MustCompile (gocritic) linting error #96

Closed
atc0005 opened this issue Nov 9, 2021 · 1 comment · Fixed by #98
Assignees
Labels
bug Something isn't working linting
Milestone

Comments

@atc0005
Copy link
Owner

atc0005 commented Nov 9, 2021

This linting error was surfaced from an upgraded golangci-lint:

internal/lockss/peers.go:82:25: regexpMust: for const patterns like v3PeerRegex, use regexp.MustCompile (gocritic)
	re, regExCompileErr := regexp.Compile(v3PeerRegex)
	                       ^
make: *** [Makefile:114: linting] Error 1
Error: Process completed with exit code 2.
@atc0005 atc0005 added bug Something isn't working linting labels Nov 9, 2021
@atc0005 atc0005 added this to the Next Release milestone Nov 9, 2021
@atc0005 atc0005 self-assigned this Nov 9, 2021
@atc0005 atc0005 changed the title regexpMust: for const patterns like v3PeerRegex, use regexp.MustCompile (gocritic) regexpMust: for const patterns like v3PeerRegex, use regexp.MustCompile (gocritic) linting error Nov 9, 2021
@atc0005
Copy link
Owner Author

atc0005 commented Nov 9, 2021

Somewhat on the fence regarding "fixing" this.

I was already checking for regex compilation error and immediately failing with an error message noting the problem, so I'm not sure if causing a panic is any more useful.

atc0005 added a commit that referenced this issue Nov 9, 2021
I am already checking for the regex compile error and
immediately returning the error if it occurs. I expect
that the error wrapping I am providing will be more
readable to users than an intentional panic induced
stack trace would be.

refs GH-96
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working linting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant