Compare commits

...

2 Commits

Author SHA1 Message Date
f04a471969
chore(parser/elf): better binders capitalization
All checks were successful
submodules sync / sync (push) Successful in 1m9s
build / build (push) Successful in 3m22s
build / trigger-build-image (push) Successful in 13s
2025-06-18 02:59:59 -04:00
698a6193cc
feat(parser/elf): score for each entry 2025-06-18 02:57:29 -04:00
2 changed files with 14 additions and 4 deletions

View File

@ -41,7 +41,7 @@ type Binder struct {
} }
func (b Binder) String() string { func (b Binder) String() string {
return fmt.Sprintf("In the definition of %s (at %s)", b.Binder, b.Pos) return fmt.Sprintf("in the definition of %s (at %s)", b.Binder, b.Pos)
} }
type Binders []Binder type Binders []Binder
@ -51,7 +51,12 @@ func (bs Binders) String() string {
for _, b := range bs { for _, b := range bs {
s = append(s, b.String()) s = append(s, b.String())
} }
return strings.Join(s, "; ") combinedStr := strings.Join(s, "; ")
if len(combinedStr) > 0 && combinedStr[0] == 'i' {
return "I" + combinedStr[1:]
}
return combinedStr
} }
type Source struct { type Source struct {

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>"