revive
revive copied to clipboard
Bug: error-string work only for punctuation
Describe the bug
The lint rule error-strings has two check, error strings should not be capitalized, and should not end with punctuation. It seems to be ignoring the case of capitalization.
To Reproduce
var errHello = errors.New("Hello world")
Expected behavior
Linter should complain about capitalized error string.
Desktop (please complete the following information):
- OS: macOS Big Sur.
- go version go1.18.2 darwin/amd64
Additional context
If I add a dot to the error string linter starts complaining as expected.
@burdiyan would you want to open a PR with a fix?
@mgechev Unfortunately, no. I'm very short on time lately.
Hi @burdiyan, I'm trying to reproduce the problem but without success at the moment.
Target file (deleteme.go)
// Some nice doc for the pkg...
package main
import "errors"
var errHello = errors.New("Hello world")
var errWorld = errors.New("hello world.")
Config file
ignoreGeneratedHeader = false
severity = "warning"
confidence = 0.1
errorCode = 0
warningCode = 0
[rule.error-strings]
Run revive with:
./revive -config deleteme2.toml -formatter stylish deleteme.go
Result:
deleteme.go
(6, 27) https://revive.run/r#error-strings error strings should not be capitalized or end with punctuation or a newline
(7, 27) https://revive.run/r#error-strings error strings should not be capitalized or end with punctuation or a newline
✖ 2 problems (0 errors) (2 warnings)
@burdiyan could you please provide more information on how (config, command line, ...) you run revive to get the behavior you describe in the issue?
I was using revive via golangci-lint. And I made sure this particular rule is not disabled by their own config somehow. Will try to prepare more exact steps to reproduce. I believe I also tried doing this with revive itself (precisely to make sure it was revive issue and not something external), and it was also reproducing the same issue, but I’m not quite sure at this point.
Unfortunately I’m a bit short on time lately, but I’ll try to provide more details as soon as I can.
Unable to reproduce the problem. Closing for now.