1
0
mirror of https://github.com/mgechev/revive.git synced 2025-11-23 22:04:49 +02:00

Fix the same-line comments detection in the empty-lines rule

Fixes #84.
This commit is contained in:
Genadi Samokovarov
2018-10-13 09:47:29 -07:00
parent 04516d2f82
commit b7d9bce0b6
2 changed files with 38 additions and 3 deletions

View File

@@ -100,9 +100,11 @@ func (w lintEmptyLines) commentBetween(position token.Position, node ast.Node) b
return false
}
commentStart := w.position(comments[0].Pos())
if commentStart.Line-position.Line == 1 || commentStart.Line-position.Line == -1 {
return true
for _, comment := range comments {
start, end := w.position(comment.Pos()), w.position(comment.End())
if start.Line-position.Line == 1 || position.Line-end.Line == 1 {
return true
}
}
return false