Keep libs/dyn unchanged; annotate with //nolint:errcheck

This commit is contained in:
Denis Bilenko 2024-12-10 11:25:49 +01:00
parent 3b99cdf21a
commit 16d412aa67
6 changed files with 11 additions and 28 deletions

View File

@ -126,8 +126,7 @@ func fromTypedStruct(src reflect.Value, ref dyn.Value, options ...fromTypedOptio
// Either if the key was set in the reference or the field is not zero-valued, we include it.
if ok || nv.Kind() != dyn.KindNil {
// QQQ log error?
_ = out.Set(refk, nv)
out.Set(refk, nv) // nolint:errcheck
}
}
@ -185,8 +184,7 @@ func fromTypedMap(src reflect.Value, ref dyn.Value) (dyn.Value, error) {
// Every entry is represented, even if it is a nil.
// Otherwise, a map with zero-valued structs would yield a nil as well.
// QQQ log error?
_ = out.Set(refk, nv)
out.Set(refk, nv) //nolint:errcheck
}
return dyn.V(out), nil

View File

@ -116,9 +116,7 @@ func (n normalizeOptions) normalizeStruct(typ reflect.Type, src dyn.Value, seen
}
}
if err := out.Set(pk, nv); err != nil {
return dyn.InvalidValue, diag.FromErr(err)
}
out.Set(pk, nv) //nolint:errcheck
}
// Return the normalized value if missing fields are not included.
@ -164,9 +162,7 @@ func (n normalizeOptions) normalizeStruct(typ reflect.Type, src dyn.Value, seen
continue
}
if v.IsValid() {
if err := out.Set(dyn.V(k), v); err != nil {
return dyn.InvalidValue, diag.FromErr(err)
}
out.Set(dyn.V(k), v) // nolint:errcheck
}
}
@ -205,9 +201,7 @@ func (n normalizeOptions) normalizeMap(typ reflect.Type, src dyn.Value, seen []r
}
}
if err := out.Set(pk, nv); err != nil {
return dyn.InvalidValue, diag.FromErr(err)
}
out.Set(pk, nv) //nolint:errcheck
}
return dyn.NewValue(out, src.Locations()), diags

View File

@ -70,8 +70,7 @@ func decodeValue(decoder *json.Decoder, o *Offset) (dyn.Value, error) {
return invalidValueWithLocation(decoder, o), err
}
// QQQ log this?
_ = obj.Set(keyVal, val)
obj.Set(keyVal, val) //nolint:errcheck
}
// Consume the closing '}'
if _, err := decoder.Token(); err != nil {

View File

@ -41,8 +41,7 @@ func newMappingWithSize(size int) Mapping {
func newMappingFromGoMap(vin map[string]Value) Mapping {
m := newMappingWithSize(len(vin))
for k, v := range vin {
// QQQ log error or panic?
_ = m.Set(V(k), v)
m.Set(V(k), v) //nolint:errcheck
}
return m
}
@ -145,7 +144,6 @@ func (m Mapping) Clone() Mapping {
// Merge merges the key-value pairs from another Mapping into the current Mapping.
func (m *Mapping) Merge(n Mapping) {
for _, p := range n.pairs {
// QQQ log error or panic?
_ = m.Set(p.Key, p.Value)
m.Set(p.Key, p.Value) //nolint:errcheck
}
}

View File

@ -88,14 +88,10 @@ func mergeMap(a, b dyn.Value) (dyn.Value, error) {
if err != nil {
return dyn.InvalidValue, err
}
if err := out.Set(pk, merged); err != nil {
return dyn.InvalidValue, err
}
out.Set(pk, merged) //nolint:errcheck
} else {
// Otherwise, just set the value.
if err := out.Set(pk, pv); err != nil {
return dyn.InvalidValue, err
}
out.Set(pk, pv) //nolint:errcheck
}
}

View File

@ -41,9 +41,7 @@ func SetByPath(v Value, p Path, nv Value) (Value, error) {
// Return an updated map value.
m = m.Clone()
if err := m.Set(V(component.key), nv); err != nil {
return InvalidValue, err
}
m.Set(V(component.key), nv) //nolint:errcheck
return Value{
v: m,
k: KindMap,