Skip to content

Commit

Permalink
all: minor code cleanups
Browse files Browse the repository at this point in the history
While skimming the pkg/tool/cli code, I noticed that a switch
can be replaced by a boolean expression.

While here, apply three staticcheck suggestions around unused values.

Signed-off-by: Daniel Martí <[email protected]>
Change-Id: I02b2d768b1fc9176a5f0d913b2de1e9f5ab549ae
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1199478
Unity-Result: CUE porcuepine <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
Reviewed-by: Matthew Sackman <[email protected]>
  • Loading branch information
mvdan committed Aug 14, 2024
1 parent 40da936 commit dc3ba30
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 8 deletions.
1 change: 0 additions & 1 deletion internal/core/compile/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
const supportedByLen = adt.StructKind | adt.BytesKind | adt.StringKind | adt.ListKind

var (
stringParam = adt.Param{Value: &adt.BasicType{K: adt.StringKind}}
structParam = adt.Param{Value: &adt.BasicType{K: adt.StructKind}}
listParam = adt.Param{Value: &adt.BasicType{K: adt.ListKind}}
intParam = adt.Param{Value: &adt.BasicType{K: adt.IntKind}}
Expand Down
1 change: 1 addition & 0 deletions internal/vcs/vcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ func TestGit(t *testing.T) {
err = os.WriteFile(filepath.Join(dir, "bar.txt"), []byte("something else"), 0o666)
qt.Assert(t, qt.IsNil(err))
statuschanged, err := v.Status(ctx)
qt.Assert(t, qt.IsNil(err))
qt.Assert(t, qt.IsTrue(statuschanged.Uncommitted))
status1, err := v.Status(ctx, subdir)
qt.Assert(t, qt.IsNil(err))
Expand Down
2 changes: 1 addition & 1 deletion pkg/path/match.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Pattern:
// Before returning false with no error,
// check that the remainder of the pattern is syntactically valid.
for len(pattern) > 0 {
_, chunk, pattern, err = scanChunk(pattern, os)
_, _, pattern, err = scanChunk(pattern, os)
if err != nil {
return false, err
}
Expand Down
7 changes: 1 addition & 6 deletions pkg/tool/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,7 @@ func (c *askCmd) Run(ctx *task.Context) (res interface{}, err error) {

switch v := ctx.Lookup("response"); v.IncompleteKind() {
case cue.BoolKind:
switch strings.ToLower(response) {
case "yes":
update["response"] = true
default:
update["response"] = false
}
update["response"] = strings.ToLower(response) == "yes"
case cue.StringKind:
// already set above
}
Expand Down

0 comments on commit dc3ba30

Please sign in to comment.