mgechev / revive

🔥 ~6x faster, stricter, configurable, extensible, and beautiful drop-in replacement for golint
https://revive.run
MIT License
4.74k stars 278 forks source link

package-comments position includes the whole file #790

Closed heyvito closed 1 year ago

heyvito commented 1 year ago

Describe the bug When using JSON as the formatter, the package-comments rule reports that the issue starts at the very beginning of the file and spans to the last line, which I think is unexpected.

To Reproduce Steps to reproduce the behavior:

  1. Get latest revive release
  2. Run it against its own codebase, using --formatter json
  3. It should report an issue on main.go, that spans the entire file.
> pwd
/work/revive

> revive --formatter json
[{"Severity":"warning","Failure":"should have a package comment","RuleName":"package-comments","Category":"comments","Position":{"Start":{"Filename":"main.go","Offset":0,"Line":1,"Column":1},"End":{"Filename":"main.go","Offset":86,"Line":7,"Column":2}},"Confidence":1,"ReplacementLine":""}]

Expected behavior Instead, revive should report only the line containing package xyz, which is the target of the missing comment:

> pwd
/work/revive

> revive --formatter json
[{"Severity":"warning","Failure":"should have a package comment","RuleName":"package-comments","Category":"comments","Position":{"Start":{"Filename":"main.go","Offset":0,"Line":1,"Column":1},"End":{"Filename":"main.go","Offset":12,"Line":1,"Column":13}},"Confidence":1,"ReplacementLine":""}]

Logs N/A