feat(parser): support force quit on deduct
This commit is contained in:
		
							parent
							
								
									ecac4986de
								
							
						
					
					
						commit
						24204b47af
					
				|  | @ -14,11 +14,12 @@ type Match struct { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| type Conf struct { | type Conf struct { | ||||||
| 	Score   int | 	Score             int | ||||||
| 	RootDir string `default:"/w"` | 	RootDir           string `default:"/w"` | ||||||
| 	Matches []Match | 	Matches           []Match | ||||||
| 	Stdout  string `default:"stdout"` | 	Stdout            string `default:"stdout"` | ||||||
| 	Stderr  string `default:"stderr"` | 	Stderr            string `default:"stderr"` | ||||||
|  | 	ForceQuitOnDeduct bool   `default:"false"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| type ClangTidy struct{} | type ClangTidy struct{} | ||||||
|  | @ -56,8 +57,13 @@ func (*ClangTidy) Run(results []stage.ExecutorResult, confAny any) ( | ||||||
| 		return nil, true, err | 		return nil, true, err | ||||||
| 	} | 	} | ||||||
| 	var res []stage.ParserResult | 	var res []stage.ParserResult | ||||||
|  | 	forceQuit := false | ||||||
| 	for _, result := range results { | 	for _, result := range results { | ||||||
| 		res = append(res, Parse(result, *conf)) | 		parseRes := Parse(result, *conf) | ||||||
|  | 		if conf.ForceQuitOnDeduct && parseRes.Score < conf.Score { | ||||||
|  | 			forceQuit = true | ||||||
|  | 		} | ||||||
|  | 		res = append(res, parseRes) | ||||||
| 	} | 	} | ||||||
| 	return res, false, nil | 	return res, forceQuit, nil | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -15,10 +15,11 @@ type Match struct { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| type Conf struct { | type Conf struct { | ||||||
| 	Score   int | 	Score             int | ||||||
| 	Matches []Match | 	Matches           []Match | ||||||
| 	Stdout  string `default:"stdout"` | 	Stdout            string `default:"stdout"` | ||||||
| 	Stderr  string `default:"stderr"` | 	Stderr            string `default:"stderr"` | ||||||
|  | 	ForceQuitOnDeduct bool   `default:"false"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| type Record struct { | type Record struct { | ||||||
|  | @ -89,8 +90,13 @@ func (*CppCheck) Run(results []stage.ExecutorResult, confAny any) ( | ||||||
| 		return nil, true, err | 		return nil, true, err | ||||||
| 	} | 	} | ||||||
| 	var res []stage.ParserResult | 	var res []stage.ParserResult | ||||||
|  | 	forceQuit := false | ||||||
| 	for _, result := range results { | 	for _, result := range results { | ||||||
| 		res = append(res, Parse(result, *conf)) | 		parseRes := Parse(result, *conf) | ||||||
|  | 		if conf.ForceQuitOnDeduct && parseRes.Score < conf.Score { | ||||||
|  | 			forceQuit = true | ||||||
|  | 		} | ||||||
|  | 		res = append(res, parseRes) | ||||||
| 	} | 	} | ||||||
| 	return res, false, nil | 	return res, forceQuit, nil | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -15,10 +15,11 @@ type Match struct { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| type Conf struct { | type Conf struct { | ||||||
| 	Score   int | 	Score             int | ||||||
| 	Matches []Match | 	Matches           []Match | ||||||
| 	Stdout  string `default:"stdout"` | 	Stdout            string `default:"stdout"` | ||||||
| 	Stderr  string `default:"stderr"` | 	Stderr            string `default:"stderr"` | ||||||
|  | 	ForceQuitOnDeduct bool   `default:"false"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| type Cpplint struct{} | type Cpplint struct{} | ||||||
|  | @ -88,8 +89,13 @@ func (*Cpplint) Run(results []stage.ExecutorResult, confAny any) ( | ||||||
| 		return nil, true, err | 		return nil, true, err | ||||||
| 	} | 	} | ||||||
| 	var res []stage.ParserResult | 	var res []stage.ParserResult | ||||||
|  | 	forceQuit := false | ||||||
| 	for _, result := range results { | 	for _, result := range results { | ||||||
| 		res = append(res, Parse(result, *conf)) | 		parseRes := Parse(result, *conf) | ||||||
|  | 		if conf.ForceQuitOnDeduct && parseRes.Score < conf.Score { | ||||||
|  | 			forceQuit = true | ||||||
|  | 		} | ||||||
|  | 		res = append(res, parseRes) | ||||||
| 	} | 	} | ||||||
| 	return res, false, nil | 	return res, forceQuit, nil | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user