Skip to content

Commit

Permalink
all: resolve a few more staticcheck warnings
Browse files Browse the repository at this point in the history
Continuing to slowly chip away at these where it makes sense,
rather than big sweeping changes which are hard to review
and sure to cause conflicts.

None of the changes below change behavior in any way;
they only remove unused code or simplify code.

Signed-off-by: Daniel Martí <[email protected]>
Change-Id: I19b063f8b0d3dac2e80be88af295937dbf7dc255
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1202112
Reviewed-by: Roger Peppe <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
  • Loading branch information
mvdan committed Oct 7, 2024
1 parent 84646f6 commit 50ed297
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 29 deletions.
6 changes: 1 addition & 5 deletions cue/interpreter/wasm/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,7 @@ func encNumber(typ cue.Value, val cue.Value) (r uint64) {
}

func decBool(v uint64) bool {
u := api.DecodeU32(v)
if u == 1 {
return true
}
return false
return api.DecodeU32(v) == 1
}

// decNumber decodes the the Wasm/System V ABI encoding of the
Expand Down
5 changes: 0 additions & 5 deletions encoding/openapi/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ type buildContext struct {
// TODO: consider an option in the CUE API where optional fields are
// recursively evaluated.
cycleNodes []*adt.Vertex

// imports caches values as returned by cue.Value.ReferencePath
// for use by ReferenceFunc. It's only initialised when ReferenceFunc
// is non-nil.
imports map[cue.Value]*cue.Instance
}

type externalType struct {
Expand Down
9 changes: 0 additions & 9 deletions internal/core/adt/disjunct2.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,15 +578,6 @@ outer:
return append(a, x)
}

// isPartialNode reports whether a node must be evaluated as a partial node.
func isPartialNode(d *nodeContext) bool {
if d.node.status == finalized {
return true
}
// TODO: further optimizations
return false
}

// findIntersections reports the closeContext, relative to the two given
// disjunction holds, that should be used in comparing the arc set.
// x and y MUST both be originating from the same disjunct hole. This ensures
Expand Down
7 changes: 2 additions & 5 deletions internal/core/adt/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ func (c *OpContext) Stats() *stats.Counts {
// return e.NewContext(v)
// }

var structSentinel = &StructMarker{}

var incompleteSentinel = &Bottom{
Code: IncompleteError,
Err: errors.Newf(token.NoPos, "incomplete"),
Expand Down Expand Up @@ -1582,7 +1580,6 @@ type envList struct {
id CloseInfo
ignore bool // has a self-referencing comprehension and is postponed
self bool // was added as a postponed self-referencing comprehension
index int
}

type envCheck struct {
Expand Down Expand Up @@ -2517,8 +2514,8 @@ outer:
IsOpen: isOpen,
})
} else {
if expr, _ := m.Src.(ast.Expr); expr != nil {
sources = append(sources, expr)
if m.Src != nil {
sources = append(sources, m.Src)
}
m.Src = ast.NewBinExpr(token.AND, sources...)
m.IsOpen = m.IsOpen && isOpen
Expand Down
2 changes: 1 addition & 1 deletion internal/core/adt/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func TestX(t *testing.T) {
LogEval: 1, // Uncomment to turn logging off
}

var version internal.EvaluatorVersion
version := internal.DefaultVersion
version = internal.DevVersion // comment to use default implementation.

in := `
Expand Down
2 changes: 1 addition & 1 deletion internal/core/adt/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (x *FieldTester) Def(sub ...declaration) declaration {
func (x *FieldTester) spawn(t closeNodeType, sub ...declaration) declaration {
return func(cc *closeContext) {
ci := CloseInfo{cc: cc}
ci, dc := ci.spawnCloseContext(x.n.ctx, t)
_, dc := ci.spawnCloseContext(x.n.ctx, t)

dc.incDependent(x.n.ctx, TEST, nil)
for _, sfn := range sub {
Expand Down
3 changes: 0 additions & 3 deletions internal/core/adt/sched_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,6 @@ func TestScheduler(t *testing.T) {

log string // A lot
state string // A textual representation of the task state

// err holds all errors or "" if none.
err string
}

cases := []testCase{{
Expand Down

0 comments on commit 50ed297

Please sign in to comment.