this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

all: resolve a few more staticcheck warnings

Mainly deprecations, but also a few others sprinkled in.
Reduces the number of warnings by 7.

internal/value.ConvertToRuntime is only needed once after this refactor,
and since we're moving away from it, the internal API can go entirely.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I775780e27810a644d4679eacfc93eb30ba5dea1d
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1199870
Reviewed-by: Matthew Sackman <matthew@cue.works>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

+17 -28
+3 -3
cmd/cue/cmd/common.go
··· 36 36 "cuelang.org/go/internal/core/adt" 37 37 "cuelang.org/go/internal/encoding" 38 38 "cuelang.org/go/internal/filetypes" 39 - "cuelang.org/go/internal/value" 40 39 ) 41 40 42 41 var requestedVersion = os.Getenv("CUE_SYNTAX_OVERRIDE") ··· 810 809 inst = cue.Merge(insts...) 811 810 } 812 811 813 - r := value.ConvertToRuntime(inst.Value().Context()) 812 + ctx := inst.Value().Context() 814 813 for _, b := range binst { 815 814 for _, i := range b.Imports { 816 - if _, err := r.Build(i); err != nil { 815 + val := ctx.BuildInstance(i) 816 + if err := val.Err(); err != nil { 817 817 return nil, err 818 818 } 819 819 }
-5
cmd/cue/cmd/flags.go
··· 116 116 117 117 type flagName string 118 118 119 - type unaddedFlagUse struct { 120 - cmd string 121 - flag flagName 122 - } 123 - 124 119 // ensureAdded detects if a flag is being used without it first being 125 120 // added to the flagSet. Because flagNames are global, it is quite 126 121 // easy to accidentally use a flag in a command without adding it to
+3 -1
cmd/cue/cmd/get_go.go
··· 301 301 for i, result := range results { 302 302 resultVars[i] = types.NewParam(token.NoPos, nil, "", result) 303 303 } 304 - return types.NewSignature( 304 + return types.NewSignatureType( 305 + nil, 306 + nil, 305 307 nil, 306 308 types.NewTuple(paramVars...), 307 309 types.NewTuple(resultVars...),
+1 -2
encoding/gocode/generator.go
··· 27 27 28 28 "cuelang.org/go/cue" 29 29 "cuelang.org/go/cue/errors" 30 - "cuelang.org/go/internal/value" 31 30 ) 32 31 33 32 // Config defines options for generation Go code. ··· 154 153 g.decl(iter.Label(), iter.Value()) 155 154 } 156 155 157 - r := value.ConvertToRuntime(val.Context()) 156 + r := (*cue.Runtime)(val.Context()) 158 157 b, err = r.Marshal(&val) 159 158 g.addErr(err) 160 159
+1 -1
encoding/gocode/gocodec/codec.go
··· 95 95 return v.Decode(x) 96 96 } 97 97 98 - var defaultCodec = New(value.ConvertToRuntime(cuecontext.New()), nil) 98 + var defaultCodec = New(cuecontext.New(), nil) 99 99 100 100 // Validate calls Validate on a default Codec for the type of x. 101 101 func Validate(x interface{}) error {
+1 -1
internal/ci/checks/commit.go
··· 51 51 // line because each commit must be signed-off. 52 52 lines := strings.Split(body, "\n") 53 53 if len(lines) > 1 && lines[1] != "" { 54 - return fmt.Errorf("The second line of a commit message must be blank") 54 + return fmt.Errorf("the second line of a commit message must be blank") 55 55 } 56 56 57 57 // All authors, including co-authors, must have a signed-off trailer by email.
+6 -6
internal/envflag/flag.go
··· 67 67 v, err := strconv.ParseBool(valueStr) 68 68 if err != nil { 69 69 // Invalid format, return an error immediately. 70 - return invalidError{ 70 + return errInvalid{ 71 71 fmt.Errorf("invalid bool value for %s: %v", name, err), 72 72 } 73 73 } ··· 85 85 return errors.Join(errs...) 86 86 } 87 87 88 - // An InvalidError indicates a malformed input string. 89 - var InvalidError = errors.New("invalid value") 88 + // An ErrInvalid indicates a malformed input string. 89 + var ErrInvalid = errors.New("invalid value") 90 90 91 - type invalidError struct{ error } 91 + type errInvalid struct{ error } 92 92 93 - func (invalidError) Is(err error) bool { 94 - return err == InvalidError 93 + func (errInvalid) Is(err error) bool { 94 + return err == ErrInvalid 95 95 }
+1 -1
internal/envflag/flag_test.go
··· 36 36 return func(t *testing.T) { 37 37 var x T 38 38 err := Init(&x, "TEST_VAR") 39 - qt.Assert(t, qt.ErrorIs(err, InvalidError)) 39 + qt.Assert(t, qt.ErrorIs(err, ErrInvalid)) 40 40 qt.Assert(t, qt.Equals(x, want)) 41 41 } 42 42 }
+1 -4
internal/pkg/types.go
··· 74 74 } 75 75 // The equivalent code for the old implementation. 76 76 ot := s.node.OptionalTypes() 77 - if ot&^adt.HasDynamic != 0 { 78 - return true 79 - } 80 - return false 77 + return ot&^adt.HasDynamic != 0 81 78 } 82 79 83 80 // A ValidationError indicates an error that is only valid if a builtin is used
-4
internal/value/value.go
··· 27 27 "cuelang.org/go/internal/types" 28 28 ) 29 29 30 - func ConvertToRuntime(c *cue.Context) *cue.Runtime { 31 - return (*cue.Runtime)(c) 32 - } 33 - 34 30 func ConvertToContext[Ctx *cue.Runtime | *cue.Context](ctx Ctx) *cue.Context { 35 31 if ctx, ok := any(ctx).(*cue.Runtime); ok { 36 32 (*runtime.Runtime)(ctx).Init()