golangci-lint: marshaler, strict (#523)

This commit is contained in:
Vincent Serpoul
2021-04-23 22:41:21 +08:00
committed by GitHub
parent e443b4fdb8
commit 466faaab9f
4 changed files with 46 additions and 20 deletions
+9
View File
@@ -18,6 +18,7 @@ func (s *strict) EnterTable(node ast.Node) {
if !s.Enabled {
return
}
s.key.UpdateTable(node)
}
@@ -25,6 +26,7 @@ func (s *strict) EnterArrayTable(node ast.Node) {
if !s.Enabled {
return
}
s.key.UpdateArrayTable(node)
}
@@ -32,6 +34,7 @@ func (s *strict) EnterKeyValue(node ast.Node) {
if !s.Enabled {
return
}
s.key.Push(node)
}
@@ -39,6 +42,7 @@ func (s *strict) ExitKeyValue(node ast.Node) {
if !s.Enabled {
return
}
s.key.Pop(node)
}
@@ -46,6 +50,7 @@ func (s *strict) MissingTable(node ast.Node) {
if !s.Enabled {
return
}
s.missing = append(s.missing, decodeError{
highlight: keyLocation(node),
message: "missing table",
@@ -57,6 +62,7 @@ func (s *strict) MissingField(node ast.Node) {
if !s.Enabled {
return
}
s.missing = append(s.missing, decodeError{
highlight: keyLocation(node),
message: "missing field",
@@ -72,8 +78,11 @@ func (s *strict) Error(doc []byte) error {
err := &StrictMissingError{
Errors: make([]DecodeError, 0, len(s.missing)),
}
for _, derr := range s.missing {
derr := derr
err.Errors = append(err.Errors, *wrapDecodeError(doc, &derr))
}
return err
}