init(internal/parsers/cppcheck/) cppcheck
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
29627d2760
commit
33242654ea
9
internal/parsers/cppcheck/meta.go
Normal file
9
internal/parsers/cppcheck/meta.go
Normal file
|
@ -0,0 +1,9 @@
|
|||
package cppcheck
|
||||
|
||||
import "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/stage"
|
||||
|
||||
var name = "cppcheck"
|
||||
|
||||
func init() {
|
||||
stage.RegisterParser(name, &CppCheck{})
|
||||
}
|
48
internal/parsers/cppcheck/parser.go
Normal file
48
internal/parsers/cppcheck/parser.go
Normal file
|
@ -0,0 +1,48 @@
|
|||
package cppcheck
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/stage"
|
||||
"github.com/criyle/go-judge/envexec"
|
||||
)
|
||||
|
||||
type CppCheck struct{}
|
||||
|
||||
type Conf struct {
|
||||
Score int `default:"100"`
|
||||
Comment string `default:""`
|
||||
}
|
||||
|
||||
func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult {
|
||||
// stdout := executorResult.Files["stdout"]
|
||||
stderr := executorResult.Files["stderr"]
|
||||
|
||||
if executorResult.Status != stage.Status(envexec.StatusAccepted) {
|
||||
return stage.ParserResult{
|
||||
Score: 0,
|
||||
Comment: fmt.Sprintf(
|
||||
"Unexpected executor status: %s.\nStderr: %s",
|
||||
executorResult.Status, stderr,
|
||||
),
|
||||
}
|
||||
}
|
||||
return stage.ParserResult{
|
||||
Score: 0,
|
||||
Comment: "",
|
||||
}
|
||||
}
|
||||
|
||||
func (*CppCheck) Run(results []stage.ExecutorResult, confAny any) (
|
||||
[]stage.ParserResult, bool, error,
|
||||
) {
|
||||
conf, err := stage.DecodeConf[Conf](confAny)
|
||||
if err != nil {
|
||||
return nil, true, err
|
||||
}
|
||||
var res []stage.ParserResult
|
||||
for _, result := range results {
|
||||
res = append(res, Parse(result, *conf))
|
||||
}
|
||||
return res, false, nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user