mirror of
https://github.com/mgechev/revive.git
synced 2024-11-24 08:32:22 +02:00
parent
226c8c1285
commit
9d5ed110c9
@ -31,3 +31,38 @@ func bare4(a string, b int) string {
|
||||
func bare5(a string, b int) {
|
||||
return
|
||||
}
|
||||
|
||||
// NR tests for issue #280
|
||||
func f280_1() (err error) {
|
||||
func() {
|
||||
return
|
||||
}()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func f280_2() (err error) {
|
||||
func() (r int) {
|
||||
return // MATCH /avoid using bare returns, please add return expressions/
|
||||
}()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func f280_3() (err error) {
|
||||
func() (r int) {
|
||||
return 1
|
||||
}()
|
||||
|
||||
return // MATCH /avoid using bare returns, please add return expressions/
|
||||
}
|
||||
|
||||
func f280_4() (err error) {
|
||||
func() (r int) {
|
||||
return func() (r int) {
|
||||
return // MATCH /avoid using bare returns, please add return expressions/
|
||||
}()
|
||||
}()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -58,6 +58,13 @@ type bareReturnFinder struct {
|
||||
}
|
||||
|
||||
func (w bareReturnFinder) Visit(node ast.Node) ast.Visitor {
|
||||
_, ok := node.(*ast.FuncLit)
|
||||
if ok {
|
||||
// skip analysing function literals
|
||||
// they will analyzed by the lintBareReturnRule.Visit method
|
||||
return nil
|
||||
}
|
||||
|
||||
rs, ok := node.(*ast.ReturnStmt)
|
||||
if !ok {
|
||||
return w
|
||||
|
Loading…
Reference in New Issue
Block a user