fix: keywords group score
This commit is contained in:
		
							parent
							
								
									654e94b094
								
							
						
					
					
						commit
						4b9e74467c
					
				|  | @ -1,16 +1,17 @@ | ||||||
| from joj3_config_generator.models import joj1, repo, result, task | from typing import List | ||||||
|  | 
 | ||||||
|  | from joj3_config_generator.lib.repo import getHealthcheckConfig | ||||||
| from joj3_config_generator.lib.task import ( | from joj3_config_generator.lib.task import ( | ||||||
|     fix_comment, |     fix_comment, | ||||||
|     fix_diff, |     fix_diff, | ||||||
|     fix_keyword, |     fix_keyword, | ||||||
|     fix_result_detail,  |     fix_result_detail, | ||||||
|     get_executorWithConfig, |  | ||||||
|     get_conf_stage, |     get_conf_stage, | ||||||
|  |     get_executorWithConfig, | ||||||
| ) | ) | ||||||
| from joj3_config_generator.lib.repo import getHealthcheckConfig | from joj3_config_generator.models import joj1, repo, result, task | ||||||
| from typing import List | 
 | ||||||
| 
 | 
 | ||||||
| # FIXME: LLM generated convert function, only for demostration |  | ||||||
| def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: | def convert(repo_conf: repo.Config, task_conf: task.Config) -> result.Config: | ||||||
|     # Create the base ResultConf object |     # Create the base ResultConf object | ||||||
|     result_conf = ResultConfig( |     result_conf = ResultConfig( | ||||||
|  |  | ||||||
|  | @ -107,8 +107,11 @@ def get_executorWithConfig( | ||||||
|     return (executor_with_config, cached) |     return (executor_with_config, cached) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def fix_keyword(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: | # FIXME: fix severity and "keywords" | ||||||
|     keyword_parser = ["clangtidy", "keyword", "cppcheck"]  # TODO: may add cpplint | def fix_keyword( | ||||||
|  |     task_stage: task.Stage, conf_stage: result.StageDetail | ||||||
|  | ) -> result.StageDetail: | ||||||
|  |     keyword_parser = ["clangtidy", "keyword", "cppcheck", "cpplint"] | ||||||
|     if task_stage.parsers is not None: |     if task_stage.parsers is not None: | ||||||
|         for parser in task_stage.parsers: |         for parser in task_stage.parsers: | ||||||
|             if parser in keyword_parser: |             if parser in keyword_parser: | ||||||
|  | @ -117,12 +120,22 @@ def fix_keyword(task_stage: TaskStage, conf_stage: ResultStage) -> ResultStage: | ||||||
|                 ) |                 ) | ||||||
|                 keyword_weight = [] |                 keyword_weight = [] | ||||||
|                 if getattr(task_stage, parser, None) is not None: |                 if getattr(task_stage, parser, None) is not None: | ||||||
|                     for _, keyword in enumerate(getattr(task_stage, parser).keyword): |                     unique_weight = list(set(getattr(task_stage, parser).weight)) | ||||||
|                         keyword_weight.append({"keyword": [keyword], "score": 0}) |                     for score in unique_weight: | ||||||
|                     for idx, weight in enumerate(getattr(task_stage, parser).weight): |                         keyword_weight.append({"keywords": [], "score": score}) | ||||||
|                         keyword_weight[idx]["score"] = weight |  | ||||||
| 
 | 
 | ||||||
|                 keyword_parser_.with_.update({"match": keyword_weight}) |                     for idx, score in enumerate(unique_weight): | ||||||
|  |                         for idx_, score_ in enumerate( | ||||||
|  |                             getattr(task_stage, parser).weight | ||||||
|  |                         ): | ||||||
|  |                             if score == score_: | ||||||
|  |                                 keyword_weight[idx]["keywords"].append( | ||||||
|  |                                     getattr(task_stage, parser).keyword[idx_] | ||||||
|  |                                 ) | ||||||
|  |                             else: | ||||||
|  |                                 continue | ||||||
|  | 
 | ||||||
|  |                 keyword_parser_.with_.update({"matches": keyword_weight}) | ||||||
|             else: |             else: | ||||||
|                 continue |                 continue | ||||||
|     return conf_stage |     return conf_stage | ||||||
|  |  | ||||||
|  | @ -57,8 +57,7 @@ class Stage(BaseModel): | ||||||
|     clangtidy: Optional[ParserKeyword] = ParserKeyword() |     clangtidy: Optional[ParserKeyword] = ParserKeyword() | ||||||
|     cppcheck: Optional[ParserKeyword] = ParserKeyword() |     cppcheck: Optional[ParserKeyword] = ParserKeyword() | ||||||
|     # FIXME: determine cpplint type |     # FIXME: determine cpplint type | ||||||
|     # cpplint: Optional[ParserKeyword] = ParserKeyword() |     cpplint: Optional[ParserKeyword] = ParserKeyword() | ||||||
|     cpplint: Optional[ParserDummy] = ParserDummy() |  | ||||||
|     result_detail: Optional[ParserResultDetail] = Field( |     result_detail: Optional[ParserResultDetail] = Field( | ||||||
|         ParserResultDetail(), alias="result-detail" |         ParserResultDetail(), alias="result-detail" | ||||||
|     ) |     ) | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| { | { | ||||||
|     "name": "h4 ex1", |     "name": "Homework 1 exercise 2", | ||||||
|     "logPath": "h4-ex1.log", |     "logPath": "Homework-1-exercise-2.log", | ||||||
|     "expireUnixTimestamp": 1728748740, |     "expireUnixTimestamp": 1728748740, | ||||||
|     "stage": { |     "stage": { | ||||||
|         "sandboxExecServer": "172.17.0.1:5051", |         "sandboxExecServer": "172.17.0.1:5051", | ||||||
|  | @ -18,7 +18,7 @@ | ||||||
|                                 "/<function", |                                 "/<function", | ||||||
|                                 "get_temp_directory", |                                 "get_temp_directory", | ||||||
|                                 "at", |                                 "at", | ||||||
|                                 "0x7f5f9b524860>/repo-health-checker", |                                 "0x7efe709e4180>/repo-health-checker", | ||||||
|                                 "-root=.", |                                 "-root=.", | ||||||
|                                 "-repoSize=50.5", |                                 "-repoSize=50.5", | ||||||
|                                 "-meta=main.py", |                                 "-meta=main.py", | ||||||
|  | @ -70,8 +70,8 @@ | ||||||
|                             "cpuRateLimit": 0, |                             "cpuRateLimit": 0, | ||||||
|                             "cpuSetLimit": "", |                             "cpuSetLimit": "", | ||||||
|                             "copyIn": { |                             "copyIn": { | ||||||
|                                 "//tmp/repo-checker-h1q4gec9/repo-health-checker": { |                                 "//tmp/repo-checker-d89rnuip/repo-health-checker": { | ||||||
|                                     "src": "//tmp/repo-checker-nprjqigk/repo-health-checker", |                                     "src": "//tmp/repo-checker-tk3cqa0k/repo-health-checker", | ||||||
|                                     "content": null, |                                     "content": null, | ||||||
|                                     "fileId": null, |                                     "fileId": null, | ||||||
|                                     "name": null, |                                     "name": null, | ||||||
|  | @ -348,15 +348,15 @@ | ||||||
|                     { |                     { | ||||||
|                         "name": "keyword", |                         "name": "keyword", | ||||||
|                         "with": { |                         "with": { | ||||||
|                             "match": [ |                             "matches": [ | ||||||
|                                 { |                                 { | ||||||
|                                     "keyword": [ |                                     "keywords": [ | ||||||
|                                         "max" |                                         "max" | ||||||
|                                     ], |                                     ], | ||||||
|                                     "score": 50 |                                     "score": 50 | ||||||
|                                 }, |                                 }, | ||||||
|                                 { |                                 { | ||||||
|                                     "keyword": [ |                                     "keywords": [ | ||||||
|                                         "recommend" |                                         "recommend" | ||||||
|                                     ], |                                     ], | ||||||
|                                     "score": 20 |                                     "score": 20 | ||||||
|  | @ -378,7 +378,7 @@ | ||||||
|                             "showFiles": [ |                             "showFiles": [ | ||||||
|                                 "stderr" |                                 "stderr" | ||||||
|                             ], |                             ], | ||||||
|                             "showExitStatus": false, |                             "showExitStatus": true, | ||||||
|                             "showRuntime": false, |                             "showRuntime": false, | ||||||
|                             "showMemory": false |                             "showMemory": false | ||||||
|                         } |                         } | ||||||
|  | @ -463,87 +463,37 @@ | ||||||
|                     { |                     { | ||||||
|                         "name": "clangtidy", |                         "name": "clangtidy", | ||||||
|                         "with": { |                         "with": { | ||||||
|                             "match": [ |                             "matches": [ | ||||||
|                                 { |                                 { | ||||||
|                                     "keyword": [ |                                     "keywords": [ | ||||||
|                                         "codequality-no-global-variables" |  | ||||||
|                                     ], |  | ||||||
|                                     "score": 10 |  | ||||||
|                                 }, |  | ||||||
|                                 { |  | ||||||
|                                     "keyword": [ |  | ||||||
|                                         "codequality-no-header-guard" |  | ||||||
|                                     ], |  | ||||||
|                                     "score": 10 |  | ||||||
|                                 }, |  | ||||||
|                                 { |  | ||||||
|                                     "keyword": [ |  | ||||||
|                                         "readability-function-size" |  | ||||||
|                                     ], |  | ||||||
|                                     "score": 50 |  | ||||||
|                                 }, |  | ||||||
|                                 { |  | ||||||
|                                     "keyword": [ |  | ||||||
|                                         "readability-duplicate-include" |  | ||||||
|                                     ], |  | ||||||
|                                     "score": 10 |  | ||||||
|                                 }, |  | ||||||
|                                 { |  | ||||||
|                                     "keyword": [ |  | ||||||
|                                         "readability-identifier-naming" |  | ||||||
|                                     ], |  | ||||||
|                                     "score": 5 |  | ||||||
|                                 }, |  | ||||||
|                                 { |  | ||||||
|                                     "keyword": [ |  | ||||||
|                                         "readability-redundant" |  | ||||||
|                                     ], |  | ||||||
|                                     "score": 5 |  | ||||||
|                                 }, |  | ||||||
|                                 { |  | ||||||
|                                     "keyword": [ |  | ||||||
|                                         "readability-misleading-indentation" |  | ||||||
|                                     ], |  | ||||||
|                                     "score": 10 |  | ||||||
|                                 }, |  | ||||||
|                                 { |  | ||||||
|                                     "keyword": [ |  | ||||||
|                                         "readability-misplaced-array-index" |  | ||||||
|                                     ], |  | ||||||
|                                     "score": 5 |  | ||||||
|                                 }, |  | ||||||
|                                 { |  | ||||||
|                                     "keyword": [ |  | ||||||
|                                         "cppcoreguidelines-init-variables" |  | ||||||
|                                     ], |  | ||||||
|                                     "score": 5 |  | ||||||
|                                 }, |  | ||||||
|                                 { |  | ||||||
|                                     "keyword": [ |  | ||||||
|                                         "bugprone-suspicious-string-compare" |                                         "bugprone-suspicious-string-compare" | ||||||
|                                     ], |                                     ], | ||||||
|                                     "score": 8 |                                     "score": 8 | ||||||
|                                 }, |                                 }, | ||||||
|                                 { |                                 { | ||||||
|                                     "keyword": [ |                                     "keywords": [ | ||||||
|                                         "google-global-names-in-headers" |                                         "codequality-no-global-variables", | ||||||
|  |                                         "codequality-no-header-guard", | ||||||
|  |                                         "readability-duplicate-include", | ||||||
|  |                                         "readability-misleading-indentation" | ||||||
|                                     ], |                                     ], | ||||||
|                                     "score": 5 |                                     "score": 10 | ||||||
|                                 }, |                                 }, | ||||||
|                                 { |                                 { | ||||||
|                                     "keyword": [ |                                     "keywords": [ | ||||||
|                                         "clang-diagnostic" |                                         "readability-function-size" | ||||||
|                                     ], |                                     ], | ||||||
|                                     "score": 5 |                                     "score": 50 | ||||||
|                                 }, |                                 }, | ||||||
|                                 { |                                 { | ||||||
|                                     "keyword": [ |                                     "keywords": [ | ||||||
|                                         "clang-analyzer" |                                         "readability-identifier-naming", | ||||||
|                                     ], |                                         "readability-redundant", | ||||||
|                                     "score": 5 |                                         "readability-misplaced-array-index", | ||||||
|                                 }, |                                         "cppcoreguidelines-init-variables", | ||||||
|                                 { |                                         "google-global-names-in-headers", | ||||||
|                                     "keyword": [ |                                         "clang-diagnostic", | ||||||
|  |                                         "clang-analyzer", | ||||||
|                                         "misc performance" |                                         "misc performance" | ||||||
|                                     ], |                                     ], | ||||||
|                                     "score": 5 |                                     "score": 5 | ||||||
|  | @ -654,36 +604,26 @@ | ||||||
|                     { |                     { | ||||||
|                         "name": "cppcheck", |                         "name": "cppcheck", | ||||||
|                         "with": { |                         "with": { | ||||||
|                             "match": [ |                             "matches": [ | ||||||
|                                 { |                                 { | ||||||
|                                     "keyword": [ |                                     "keywords": [ | ||||||
|  |                                         "warning", | ||||||
|  |                                         "style" | ||||||
|  |                                     ], | ||||||
|  |                                     "score": 10 | ||||||
|  |                                 }, | ||||||
|  |                                 { | ||||||
|  |                                     "keywords": [ | ||||||
|                                         "error" |                                         "error" | ||||||
|                                     ], |                                     ], | ||||||
|                                     "score": 20 |                                     "score": 20 | ||||||
|                                 }, |                                 }, | ||||||
|                                 { |                                 { | ||||||
|                                     "keyword": [ |                                     "keywords": [ | ||||||
|                                         "warning" |                                         "portability", | ||||||
|                                     ], |  | ||||||
|                                     "score": 10 |  | ||||||
|                                 }, |  | ||||||
|                                 { |  | ||||||
|                                     "keyword": [ |  | ||||||
|                                         "portability" |  | ||||||
|                                     ], |  | ||||||
|                                     "score": 15 |  | ||||||
|                                 }, |  | ||||||
|                                 { |  | ||||||
|                                     "keyword": [ |  | ||||||
|                                         "performance" |                                         "performance" | ||||||
|                                     ], |                                     ], | ||||||
|                                     "score": 15 |                                     "score": 15 | ||||||
|                                 }, |  | ||||||
|                                 { |  | ||||||
|                                     "keyword": [ |  | ||||||
|                                         "style" |  | ||||||
|                                     ], |  | ||||||
|                                     "score": 10 |  | ||||||
|                                 } |                                 } | ||||||
|                             ] |                             ] | ||||||
|                         } |                         } | ||||||
|  | @ -787,7 +727,36 @@ | ||||||
|                     { |                     { | ||||||
|                         "name": "cpplint", |                         "name": "cpplint", | ||||||
|                         "with": { |                         "with": { | ||||||
|                             "comment": "" |                             "keyword": [ | ||||||
|  |                                 "runtime", | ||||||
|  |                                 "readability", | ||||||
|  |                                 "build" | ||||||
|  |                             ], | ||||||
|  |                             "weight": [ | ||||||
|  |                                 10, | ||||||
|  |                                 20, | ||||||
|  |                                 15 | ||||||
|  |                             ], | ||||||
|  |                             "matches": [ | ||||||
|  |                                 { | ||||||
|  |                                     "keywords": [ | ||||||
|  |                                         "runtime" | ||||||
|  |                                     ], | ||||||
|  |                                     "score": 10 | ||||||
|  |                                 }, | ||||||
|  |                                 { | ||||||
|  |                                     "keywords": [ | ||||||
|  |                                         "readability" | ||||||
|  |                                     ], | ||||||
|  |                                     "score": 20 | ||||||
|  |                                 }, | ||||||
|  |                                 { | ||||||
|  |                                     "keywords": [ | ||||||
|  |                                         "build" | ||||||
|  |                                     ], | ||||||
|  |                                     "score": 15 | ||||||
|  |                                 } | ||||||
|  |                             ] | ||||||
|                         } |                         } | ||||||
|                     }, |                     }, | ||||||
|                     { |                     { | ||||||
|  |  | ||||||
|  | @ -1,5 +1,5 @@ | ||||||
| # general task configuration | # general task configuration | ||||||
| task="h4 ex1" # task name | task="Homework 1 exercise 2" # task name | ||||||
| 
 | 
 | ||||||
| release.deadline = 2024-10-12 23:59:00+08:00 | release.deadline = 2024-10-12 23:59:00+08:00 | ||||||
| release.stages = [ "compile" ] | release.stages = [ "compile" ] | ||||||
|  | @ -29,7 +29,7 @@ files.import = [ "tools/file-length" ] | ||||||
| parsers = [ "keyword", "dummy", "result-detail" ] | parsers = [ "keyword", "dummy", "result-detail" ] | ||||||
| keyword.keyword = [ "max", "recommend"] # keywords caught by corresponding JOJ plugin | keyword.keyword = [ "max", "recommend"] # keywords caught by corresponding JOJ plugin | ||||||
| keyword.weight = [ 50, 20 ] # weight of each keyword | keyword.weight = [ 50, 20 ] # weight of each keyword | ||||||
| result-detail.exitstatus = false | result-detail.exitstatus = true | ||||||
| result-detail.stderr = true | result-detail.stderr = true | ||||||
| result-detail.time = false | result-detail.time = false | ||||||
| result-detail.mem = false | result-detail.mem = false | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user