revive icon indicating copy to clipboard operation
revive copied to clipboard

Bug: error-string work only for punctuation

Open burdiyan opened this issue 3 years ago • 4 comments

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 avatar Aug 15 '22 15:08 burdiyan

@burdiyan would you want to open a PR with a fix?

mgechev avatar Aug 18 '22 19:08 mgechev

@mgechev Unfortunately, no. I'm very short on time lately.

burdiyan avatar Aug 20 '22 08:08 burdiyan

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?

chavacava avatar Sep 03 '22 12:09 chavacava

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.

burdiyan avatar Sep 11 '22 21:09 burdiyan

Unable to reproduce the problem. Closing for now.

chavacava avatar Oct 22 '22 07:10 chavacava