feat(parser/elf): score for each entry

This commit is contained in:
张泊明518370910136 2025-06-18 02:57:29 -04:00
parent 18cd2a8c4d
commit 698a6193cc
GPG Key ID: D47306D7062CDA9D

View File

@ -35,14 +35,19 @@ func (p *Elf) parse(executorResult stage.ExecutorResult, conf Conf) stage.Parser
slog.Error("elf parse", "mapstructure decode err", err) slog.Error("elf parse", "mapstructure decode err", err)
} }
comment += fmt.Sprintf("### [%s] %s\n", report.File, report.Name) comment += fmt.Sprintf("### [%s] %s\n", report.File, report.Name)
for _, caseObj := range report.Cases { caseScore := 0
for range report.Cases {
for _, match := range conf.Matches { for _, match := range conf.Matches {
for _, keyword := range match.Keywords { for _, keyword := range match.Keywords {
if strings.Contains(kind, keyword) { if strings.Contains(kind, keyword) {
score += -match.Score caseScore += -match.Score
} }
} }
} }
}
score += caseScore
comment += fmt.Sprintf("%d point(s)\n", caseScore)
for _, caseObj := range report.Cases {
switch kind { switch kind {
case "ParenDep": case "ParenDep":
// "<binders>:\n<context> below reaches a parentheses depths of <depths>:\n<code>" // "<binders>:\n<context> below reaches a parentheses depths of <depths>:\n<code>"