mirror of
https://github.com/mgechev/revive.git
synced 2025-11-27 22:18:41 +02:00
Fix the same-line comments detection in the empty-lines rule
Fixes #84.
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
package fixtures
|
package fixtures
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
func f1(x *int) bool { // MATCH /extra empty line at the start of a block/
|
func f1(x *int) bool { // MATCH /extra empty line at the start of a block/
|
||||||
|
|
||||||
return x > 2
|
return x > 2
|
||||||
@@ -127,3 +129,34 @@ func f18(x *int) bool {
|
|||||||
|
|
||||||
return false
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -100,10 +100,12 @@ func (w lintEmptyLines) commentBetween(position token.Position, node ast.Node) b
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
commentStart := w.position(comments[0].Pos())
|
for _, comment := range comments {
|
||||||
if commentStart.Line-position.Line == 1 || commentStart.Line-position.Line == -1 {
|
start, end := w.position(comment.Pos()), w.position(comment.End())
|
||||||
|
if start.Line-position.Line == 1 || position.Line-end.Line == 1 {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user