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