Compare commits

...

3 Commits

Author SHA1 Message Date
a6353dfed8
chore(parser): remove unused conf parts
Some checks failed
build / build (push) Failing after 1s
submodules sync / sync (push) Failing after 0s
build / trigger-build-image (push) Has been skipped
2025-01-27 21:08:41 -05:00
a82f8eb90c
chore(internal/conf): remove group from desc 2025-01-21 02:50:01 -05:00
17f098a6dc
chore(healthcheck): remove unused cli args 2025-01-13 04:44:17 -05:00
6 changed files with 1 additions and 118 deletions

View File

@ -41,11 +41,9 @@ func setupSlog() {
var (
rootDir string
repoSize float64
localList string
checkFileNameList string
checkFileSumList string
metaFile []string
gitWhitelist []string
confPath string
showVersion *bool
Version string
@ -55,13 +53,9 @@ func init() {
showVersion = flag.Bool("version", false, "print current version")
flag.StringVar(&rootDir, "root", ".", "root dir for forbidden files check")
flag.Float64Var(&repoSize, "repoSize", 2, "maximum size of the repo in MiB")
// TODO: remove localList, it is only for backward compatibility now
flag.StringVar(&localList, "localList", "", "local file list for non-ascii file check")
flag.StringVar(&checkFileNameList, "checkFileNameList", "", "comma-separated list of files to check")
flag.StringVar(&checkFileSumList, "checkFileSumList", "", "comma-separated list of expected checksums")
parseMultiValueFlag(&metaFile, "meta", "meta files to check")
// TODO: remove gitWhitelist, it is only for backward compatibility now
parseMultiValueFlag(&gitWhitelist, "whitelist", "[DEPRECATED] will be ignored")
flag.StringVar(&confPath, "confPath", "", "path to conf file for teapot check")
}
@ -109,7 +103,6 @@ func main() {
slog.Info("start repo-health-checker", "version", Version)
slog.Debug("cli args",
"repoSize", repoSize,
"localList", localList,
"checkFileNameList", checkFileNameList,
"checkFileSumList", checkFileSumList,
"meta", metaFile,

View File

@ -331,7 +331,6 @@ func MatchGroups(conf *Conf, conventionalCommit *ConventionalCommit) []string {
seen := make(map[string]bool)
keywords := []string{}
loweredCommitGroup := strings.ToLower(conventionalCommit.Group)
loweredCommitDescription := strings.ToLower(conventionalCommit.Description)
for i, stage := range conf.Stage.Stages {
if loweredCommitGroup == "all" {
conf.Stage.Stages[i].Group = ""
@ -348,8 +347,7 @@ func MatchGroups(conf *Conf, conventionalCommit *ConventionalCommit) []string {
slog.Info("group keywords from stages", "keywords", keywords)
groups := []string{}
for _, keyword := range keywords {
if strings.Contains(loweredCommitGroup, keyword) ||
strings.Contains(loweredCommitDescription, keyword) { // TODO: remove me
if strings.Contains(loweredCommitGroup, keyword) {
groups = append(groups, keyword)
}
}

View File

@ -10,7 +10,6 @@ import (
type Match struct {
Keywords []string
Severity []string // TODO: remove me
Score int
}

View File

@ -2,7 +2,6 @@ package cppcheck
import (
"fmt"
"log/slog"
"sort"
"strings"
)
@ -20,68 +19,9 @@ const (
UNKNOWN
)
func severityFromString(severityString string) (Severity, error) {
switch severityString {
case "error":
return ERROR, nil
case "warning":
return WARNING, nil
case "portability":
return PORTABILITY, nil
case "performance":
return PERFORMANCE, nil
case "style":
return STYLE, nil
case "information":
return INFORMATION, nil
case "debug":
return DEBUG, nil
default:
return UNKNOWN, fmt.Errorf("unknown severity type \"%s\" for cppcheck", severityString)
}
}
func GetResult(records []Record, conf Conf) (string, int, error) {
score := conf.Score
comment := "### Test results summary\n\n"
var severityCounts [UNKNOWN + 1]int
// TODO: remove me
var severityScore [UNKNOWN + 1]int
for _, match := range conf.Matches {
severities := match.Severity
score := match.Score
for _, severityString := range severities {
severity, err := severityFromString(severityString)
if err != nil {
return "", 0, err
}
severityScore[int(severity)] = score
}
}
totalSeverityScore := 0
for _, score := range severityScore {
totalSeverityScore += score
}
if totalSeverityScore != 0 {
for _, record := range records {
if record.File == "nofile" {
continue
}
severity, err := severityFromString(record.Severity)
if err != nil {
slog.Error("parse severity", "error", err)
}
severityCounts[int(severity)] += 1
score -= severityScore[int(severity)]
}
comment += fmt.Sprintf("1. error: %d\n", severityCounts[0])
comment += fmt.Sprintf("2. warning: %d\n", severityCounts[1])
comment += fmt.Sprintf("3. portability: %d\n", severityCounts[2])
comment += fmt.Sprintf("4. performance: %d\n", severityCounts[3])
comment += fmt.Sprintf("5. style: %d\n", severityCounts[4])
comment += fmt.Sprintf("6. information: %d\n", severityCounts[5])
comment += fmt.Sprintf("7. debug: %d\n", severityCounts[6])
}
matchCount := make(map[string]int)
scoreChange := make(map[string]int)
for _, record := range records {

View File

@ -2,14 +2,11 @@ package cpplint
import (
"fmt"
"log/slog"
"regexp"
"sort"
"strconv"
"strings"
"github.com/joint-online-judge/JOJ3/internal/stage"
"github.com/joint-online-judge/JOJ3/pkg/utils"
)
type Match struct {
@ -34,7 +31,6 @@ func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult {
regexMatches := re.FindAllStringSubmatch(stderr, -1)
score := conf.Score
comment := "### Test results summary\n\n"
categoryCount := make(map[string]int)
matchCount := make(map[string]int)
scoreChange := make(map[string]int)
for _, regexMatch := range regexMatches {
@ -49,24 +45,6 @@ func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult {
// }
// message := regexMatch[3]
category := regexMatch[4]
// TODO: remove me
if len(conf.Matches) == 0 {
confidence, err := strconv.Atoi(regexMatch[5])
if err != nil {
slog.Error("parse confidence", "error", err)
return stage.ParserResult{
Score: 0,
Comment: fmt.Sprintf("Unexpected parser error: %s.", err),
}
}
score -= confidence
}
parts := strings.Split(category, "/")
if len(parts) > 0 {
category := parts[0]
categoryCount[category] += 1
}
// TODO: remove me ends
for _, match := range conf.Matches {
for _, keyword := range match.Keywords {
if strings.Contains(category, keyword) {
@ -77,18 +55,6 @@ func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult {
}
}
}
// TODO: remove me
sortedMap := utils.SortMap(categoryCount,
func(i, j utils.Pair[string, int]) bool {
if i.Value == j.Value {
return i.Key < j.Key
}
return i.Value > j.Value
})
for i, kv := range sortedMap {
comment += fmt.Sprintf("%d. %s: %d\n", i+1, kv.Key, kv.Value)
}
// TODO: remove me ends
type Result struct {
Keyword string
Count int

View File

@ -10,14 +10,12 @@ import (
type Match struct {
Keywords []string
Keyword string // TODO: remove me
Score int
MaxMatchCount int
}
type Conf struct {
Score int
FullScore int // TODO: remove me
Files []string
ForceQuitOnDeduct bool `default:"false"`
Matches []Match
@ -83,17 +81,6 @@ func (*Keyword) Run(results []stage.ExecutorResult, confAny any) (
if err != nil {
return nil, true, err
}
// TODO: remove me on Matches.Keyword field removed
for i := range conf.Matches {
match := &conf.Matches[i]
if match.Keyword != "" && len(match.Keywords) == 0 {
match.Keywords = []string{match.Keyword}
}
}
// TODO: remove me on FullScore field removed
if conf.FullScore != 0 && conf.Score == 0 {
conf.Score = conf.FullScore
}
var res []stage.ParserResult
forceQuit := false
for _, result := range results {