1
0
mirror of https://github.com/mgechev/revive.git synced 2024-11-24 08:32:22 +02:00

fixes issue #280 (#282)

This commit is contained in:
SalvadorC 2019-12-21 21:17:51 +01:00 committed by Minko Gechev
parent 226c8c1285
commit 9d5ed110c9
2 changed files with 42 additions and 0 deletions

View File

@ -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
}

View File

@ -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