style: run modernize -fix ./...
This commit is contained in:
parent
8e8c018f09
commit
fd583c5b7a
|
@ -16,7 +16,7 @@ type ConfStage struct {
|
|||
}
|
||||
Parsers []struct {
|
||||
Name string
|
||||
With interface{}
|
||||
With any
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -113,10 +113,7 @@ func ToRlimit(cmd stage.Cmd) ([]syscall.Rlimit, []int, error) {
|
|||
if err := syscall.Getrlimit(syscall.RLIMIT_CPU, ¤t); 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, ¤t); 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, ¤t); 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,
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -7,14 +7,14 @@ import (
|
|||
|
||||
// Referenced from https://github.com/yuriisk/clang-tidy-converter/blob/master/clang_tidy_converter/parser/clang_tidy_parser.py
|
||||
type JsonMessage struct {
|
||||
Type string `json:"type"`
|
||||
CheckName string `json:"checkname"`
|
||||
Description string `json:"description"`
|
||||
Content map[string]interface{} `json:"content"`
|
||||
Categories []string `json:"categories"`
|
||||
Location map[string]interface{} `json:"location"`
|
||||
Trace map[string]interface{} `json:"trace"`
|
||||
Severity string `json:"severity"`
|
||||
Type string `json:"type"`
|
||||
CheckName string `json:"checkname"`
|
||||
Description string `json:"description"`
|
||||
Content map[string]any `json:"content"`
|
||||
Categories []string `json:"categories"`
|
||||
Location map[string]any `json:"location"`
|
||||
Trace map[string]any `json:"trace"`
|
||||
Severity string `json:"severity"`
|
||||
}
|
||||
|
||||
func format(messages []ClangMessage) []JsonMessage {
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user