mirror of
				https://github.com/mgechev/revive.git
				synced 2025-10-30 23:37:49 +02:00 
			
		
		
		
	fixes false positive in unconditional-recursion
This commit is contained in:
		| @@ -61,8 +61,10 @@ func (w lintUnconditionalRecursionRule) Visit(node ast.Node) ast.Visitor { | ||||
| 	case *ast.FuncDecl: | ||||
| 		var rec *ast.Ident | ||||
| 		switch { | ||||
| 		case n.Recv == nil || n.Recv.NumFields() < 1 || len(n.Recv.List[0].Names) < 1: | ||||
| 		case n.Recv == nil: | ||||
| 			rec = nil | ||||
| 		case n.Recv.NumFields() < 1 || len(n.Recv.List[0].Names) < 1: | ||||
| 			rec = &ast.Ident{Name: "_"} | ||||
| 		default: | ||||
| 			rec = n.Recv.List[0].Names[0] | ||||
| 		} | ||||
|   | ||||
							
								
								
									
										9
									
								
								testdata/unconditional-recursion.go
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										9
									
								
								testdata/unconditional-recursion.go
									
									
									
									
										vendored
									
									
								
							| @@ -178,3 +178,12 @@ func urn17(ch chan int) { | ||||
| 	} | ||||
| 	urn17(ch) // MATCH /unconditional recursive call/ | ||||
| } | ||||
|  | ||||
| // Tests for #596 | ||||
| func (*fooType) BarFunc() { | ||||
| 	BarFunc() | ||||
| } | ||||
|  | ||||
| func (_ *fooType) BazFunc() { | ||||
| 	BazFunc() | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user