style: run modernize -fix ./...
All checks were successful
submodules sync / sync (push) Successful in 37s
build / build (push) Successful in 2m9s
build / trigger-build-image (push) Successful in 14s

This commit is contained in:
张泊明518370910136 2025-03-25 07:34:44 -04:00
parent 8e8c018f09
commit fd583c5b7a
GPG Key ID: D47306D7062CDA9D
5 changed files with 25 additions and 35 deletions

View File

@ -16,7 +16,7 @@ type ConfStage struct {
}
Parsers []struct {
Name string
With interface{}
With any
}
}

View File

@ -113,10 +113,7 @@ func ToRlimit(cmd stage.Cmd) ([]syscall.Rlimit, []int, error) {
if err := syscall.Getrlimit(syscall.RLIMIT_CPU, &current); err != nil {
return nil, nil, fmt.Errorf("getrlimit RLIMIT_CPU failed: %w", err)
}
userTimeLimit := (uint64(cmd.CPULimit) + 1e9 - 1) / 1e9 // ns to s
if userTimeLimit > current.Max {
userTimeLimit = current.Max
}
userTimeLimit := min((uint64(cmd.CPULimit)+1e9-1)/1e9, current.Max) // ns to s
rlimits = append(rlimits, syscall.Rlimit{
Cur: userTimeLimit,
Max: current.Max,
@ -128,10 +125,7 @@ func ToRlimit(cmd stage.Cmd) ([]syscall.Rlimit, []int, error) {
if err := syscall.Getrlimit(syscall.RLIMIT_DATA, &current); err != nil {
return nil, nil, fmt.Errorf("getrlimit RLIMIT_DATA failed: %w", err)
}
userMemLimit := cmd.MemoryLimit
if userMemLimit > current.Max {
userMemLimit = current.Max
}
userMemLimit := min(cmd.MemoryLimit, current.Max)
rlimits = append(rlimits, syscall.Rlimit{
Cur: userMemLimit,
Max: current.Max,
@ -143,10 +137,7 @@ func ToRlimit(cmd stage.Cmd) ([]syscall.Rlimit, []int, error) {
if err := syscall.Getrlimit(syscall.RLIMIT_STACK, &current); err != nil {
return nil, nil, fmt.Errorf("getrlimit RLIMIT_STACK failed: %w", err)
}
userStackLimit := cmd.StackLimit
if userStackLimit > current.Max {
userStackLimit = current.Max
}
userStackLimit := min(cmd.StackLimit, current.Max)
rlimits = append(rlimits, syscall.Rlimit{
Cur: userStackLimit,
Max: current.Max,

View File

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log/slog"
"maps"
"github.com/criyle/go-judge/pb"
"github.com/joint-online-judge/JOJ3/internal/stage"
@ -46,9 +47,7 @@ func (e *Sandbox) Run(cmds []stage.Cmd) ([]stage.ExecutorResult, error) {
}
results := convertPBResult(pbRet.Results)
for _, result := range results {
for fileName, fileID := range result.FileIDs {
e.cachedMap[fileName] = fileID
}
maps.Copy(e.cachedMap, result.FileIDs)
}
return results, nil
}

View File

@ -10,10 +10,10 @@ type JsonMessage struct {
Type string `json:"type"`
CheckName string `json:"checkname"`
Description string `json:"description"`
Content map[string]interface{} `json:"content"`
Content map[string]any `json:"content"`
Categories []string `json:"categories"`
Location map[string]interface{} `json:"location"`
Trace map[string]interface{} `json:"trace"`
Location map[string]any `json:"location"`
Trace map[string]any `json:"trace"`
Severity string `json:"severity"`
}
@ -49,7 +49,7 @@ func messagesToText(messages []ClangMessage) []string {
return textLines
}
func extractContent(message ClangMessage) map[string]interface{} {
func extractContent(message ClangMessage) map[string]any {
detailLines := ""
for _, line := range message.detailsLines {
if line == "" {
@ -63,7 +63,7 @@ func extractContent(message ClangMessage) map[string]interface{} {
}
detailLines += (line + "\n")
}
result := map[string]interface{}{
result := map[string]any{
"body": "```\n" + detailLines + "```",
}
return result
@ -140,18 +140,18 @@ func extractCategories(message ClangMessage) []string {
return removeDuplicates(categories)
}
func extractLocation(message ClangMessage) map[string]interface{} {
location := map[string]interface{}{
func extractLocation(message ClangMessage) map[string]any {
location := map[string]any{
"path": message.filepath,
"lines": map[string]interface{}{
"lines": map[string]any{
"begin": message.line,
},
}
return location
}
func extractOtherLocations(message ClangMessage) []map[string]interface{} {
locationList := []map[string]interface{}{}
func extractOtherLocations(message ClangMessage) []map[string]any {
locationList := []map[string]any{}
for _, child := range message.children {
locationList = append(locationList, extractLocation(child))
locationList = append(locationList, extractOtherLocations(child)...)
@ -159,8 +159,8 @@ func extractOtherLocations(message ClangMessage) []map[string]interface{} {
return locationList
}
func extractTrace(message ClangMessage) map[string]interface{} {
result := map[string]interface{}{
func extractTrace(message ClangMessage) map[string]any {
result := map[string]any{
"locations": extractOtherLocations(message),
}
return result

View File

@ -21,8 +21,8 @@ func (*CppCheck) parse(executorResult stage.ExecutorResult, conf Conf) stage.Par
// stdout := executorResult.Files[conf.Stdout]
stderr := executorResult.Files[conf.Stderr]
records := make([]Record, 0)
lines := strings.Split(stderr, "\n")
for _, line := range lines {
lines := strings.SplitSeq(stderr, "\n")
for line := range lines {
if strings.TrimSpace(line) == "" {
continue
}