fix: keep only typecheck issues (#4640)
This commit is contained in:
		
							parent
							
								
									40d4872704
								
							
						
					
					
						commit
						44c070af08
					
				| @ -22,16 +22,20 @@ func (InvalidIssue) Name() string { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (p InvalidIssue) Process(issues []result.Issue) ([]result.Issue, error) { | func (p InvalidIssue) Process(issues []result.Issue) ([]result.Issue, error) { | ||||||
|  | 	tcIssues := filterIssues(issues, func(issue *result.Issue) bool { | ||||||
|  | 		return issue.FromLinter == "typecheck" | ||||||
|  | 	}) | ||||||
|  | 
 | ||||||
|  | 	if len(tcIssues) > 0 { | ||||||
|  | 		return tcIssues, nil | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	return filterIssuesErr(issues, p.shouldPassIssue) | 	return filterIssuesErr(issues, p.shouldPassIssue) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (InvalidIssue) Finish() {} | func (InvalidIssue) Finish() {} | ||||||
| 
 | 
 | ||||||
| func (p InvalidIssue) shouldPassIssue(issue *result.Issue) (bool, error) { | func (p InvalidIssue) shouldPassIssue(issue *result.Issue) (bool, error) { | ||||||
| 	if issue.FromLinter == "typecheck" { |  | ||||||
| 		return true, nil |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	if issue.FilePath() == "" { | 	if issue.FilePath() == "" { | ||||||
| 		p.log.Warnf("no file path for the issue: probably a bug inside the linter %q: %#v", issue.FromLinter, issue) | 		p.log.Warnf("no file path for the issue: probably a bug inside the linter %q: %#v", issue.FromLinter, issue) | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -31,6 +31,21 @@ func TestInvalidIssue_Process(t *testing.T) { | |||||||
| 				{FromLinter: "typecheck"}, | 				{FromLinter: "typecheck"}, | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
|  | 		{ | ||||||
|  | 			desc: "keep only typecheck issues if any exist", | ||||||
|  | 			issues: []result.Issue{ | ||||||
|  | 				{FromLinter: "typecheck"}, | ||||||
|  | 				{ | ||||||
|  | 					FromLinter: "example", | ||||||
|  | 					Pos: token.Position{ | ||||||
|  | 						Filename: "test.go", | ||||||
|  | 					}, | ||||||
|  | 				}, | ||||||
|  | 			}, | ||||||
|  | 			expected: []result.Issue{ | ||||||
|  | 				{FromLinter: "typecheck"}, | ||||||
|  | 			}, | ||||||
|  | 		}, | ||||||
| 		{ | 		{ | ||||||
| 			desc: "Go file", | 			desc: "Go file", | ||||||
| 			issues: []result.Issue{ | 			issues: []result.Issue{ | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Ludovic Fernandez
						Ludovic Fernandez