1
0
mirror of https://github.com/mgechev/revive.git synced 2025-03-17 20:57:58 +02:00

fix bug #739: empty-lines false positive (#742)

This commit is contained in:
chavacava 2022-08-27 13:18:17 +02:00 committed by GitHub
parent a4add4a769
commit 553604eace
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -51,7 +51,7 @@ func (w lintEmptyLines) checkStart(block *ast.BlockStmt) {
firstNode := block.List[0]
firstStmt := w.position(firstNode.Pos())
firstBlockLineIsStmt := firstStmt.Line-(blockStart.Line+1) == 0
firstBlockLineIsStmt := firstStmt.Line-(blockStart.Line+1) <= 0
_, firstBlockLineIsComment := w.cmap[blockStart.Line+1]
if firstBlockLineIsStmt || firstBlockLineIsComment {
return
@ -70,7 +70,7 @@ func (w lintEmptyLines) checkEnd(block *ast.BlockStmt) {
lastNode := block.List[len(block.List)-1]
lastStmt := w.position(lastNode.End())
lastBlockLineIsStmt := (blockEnd.Line-1)-lastStmt.Line == 0
lastBlockLineIsStmt := (blockEnd.Line-1)-lastStmt.Line <= 0
_, lastBlockLineIsComment := w.cmap[blockEnd.Line-1]
if lastBlockLineIsStmt || lastBlockLineIsComment {
return

View File

@ -168,3 +168,6 @@ func ShouldNotWarn() {
// comment
}
// NR test for issue #739
func NotWarnInSingleLineFunction() { println("foo") }