1
0
mirror of https://github.com/mgechev/revive.git synced 2024-11-24 08:32:22 +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

@ -2,6 +2,8 @@
package fixtures
import "time"
func f1(x *int) bool { // MATCH /extra empty line at the start of a block/
return x > 2
@ -127,3 +129,34 @@ func f18(x *int) bool {
return false
}
func w() {
select {
case <-time.After(dur):
// TODO: Handle Ctrl-C is pressed in `mysql` client.
// return 1 when SLEEP() is KILLed
}
return 0, false, nil
}
func x() {
if tagArray[2] == "req" {
bit := len(u.reqFields)
u.reqFields = append(u.reqFields, name)
reqMask = uint64(1) << uint(bit)
// TODO: if we have more than 64 required fields, we end up
// not verifying that all required fields are present.
// Fix this, perhaps using a count of required fields?
}
if err == nil { // No need to refresh if the stream is over or failed.
// Consider any buffered body data (read from the conn but not
// consumed by the client) when computing flow control for this
// stream.
v := int(cs.inflow.available()) + cs.bufPipe.Len()
if v < transportDefaultStreamFlow-transportDefaultStreamMinRefresh {
streamAdd = int32(transportDefaultStreamFlow - v)
cs.inflow.add(streamAdd)
}
}
}

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