Linter and spelling fixes

This commit is contained in:
Neale Pickett 2020-09-17 19:48:17 -06:00
parent 63f84d1f20
commit 14b92fe617
3 changed files with 29 additions and 32 deletions

View File

@ -106,7 +106,7 @@ func (pc ProviderCommand) CheckAnswer(cat string, points int, answer string) (bo
stdout, err := cmd.Output() stdout, err := cmd.Output()
if ee, ok := err.(*exec.ExitError); ok { if ee, ok := err.(*exec.ExitError); ok {
log.Printf("%s: %s", pc.Path, string(ee.Stderr)) log.Printf("WARNING: %s: %s", pc.Path, string(ee.Stderr))
return false, err return false, err
} else if err != nil { } else if err != nil {
return false, err return false, err
@ -114,9 +114,7 @@ func (pc ProviderCommand) CheckAnswer(cat string, points int, answer string) (bo
result := strings.TrimSpace(string(stdout)) result := strings.TrimSpace(string(stdout))
if result != "correct" { if result != "correct" {
if result == "" { log.Printf("WARNING: %s: Nothing written to stdout", pc.Path)
result = "Nothing written to stdout"
}
return false, nil return false, nil
} }

View File

@ -194,7 +194,7 @@ func TestStateDisabled(t *testing.T) {
s.Remove("initialized") s.Remove("initialized")
s.refresh() s.refresh()
if !s.Enabled { if !s.Enabled {
t.Error("Re-initalizing didn't start event") t.Error("Re-initializing didn't start event")
} }
} }

View File

@ -79,29 +79,28 @@ func (a T) UnmarshalJSON(b []byte) error {
dec.UseNumber() // Don't use floats dec.UseNumber() // Don't use floats
// All this to make sure we get `[` // All this to make sure we get `[`
if t, err := dec.Token(); err != nil { t, err := dec.Token()
if err != nil {
return err return err
} else { }
switch token := t.(type) { switch token := t.(type) {
case json.Delim: case json.Delim:
if token.String() != "[" { if token.String() != "[" {
return &json.UnmarshalTypeError{
Value: token.String(),
Type: reflect.TypeOf(a),
Offset: 0,
}
}
default:
return &json.UnmarshalTypeError{ return &json.UnmarshalTypeError{
Value: fmt.Sprintf("%v", t), Value: token.String(),
Type: reflect.TypeOf(a), Type: reflect.TypeOf(a),
Offset: 0, Offset: 0,
} }
} }
default:
return &json.UnmarshalTypeError{
Value: fmt.Sprintf("%v", t),
Type: reflect.TypeOf(a),
Offset: 0,
}
} }
var num json.Number var num json.Number
var err error
if err := dec.Decode(&num); err != nil { if err := dec.Decode(&num); err != nil {
return err return err
} }
@ -122,25 +121,25 @@ func (a T) UnmarshalJSON(b []byte) error {
} }
// All this to make sure we get `]` // All this to make sure we get `]`
if t, err := dec.Token(); err != nil { t, err = dec.Token()
if err != nil {
return err return err
} else { }
switch token := t.(type) { switch token := t.(type) {
case json.Delim: case json.Delim:
if token.String() != "]" { if token.String() != "]" {
return &json.UnmarshalTypeError{
Value: token.String(),
Type: reflect.TypeOf(a),
Offset: 0,
}
}
default:
return &json.UnmarshalTypeError{ return &json.UnmarshalTypeError{
Value: fmt.Sprintf("%v", t), Value: token.String(),
Type: reflect.TypeOf(a), Type: reflect.TypeOf(a),
Offset: 0, Offset: 0,
} }
} }
default:
return &json.UnmarshalTypeError{
Value: fmt.Sprintf("%v", t),
Type: reflect.TypeOf(a),
Offset: 0,
}
} }
return nil return nil