Skip to content

Commit 18ef52d

Browse files
committed
make staticcheck happy
1 parent 4f906bf commit 18ef52d

File tree

8 files changed

+11
-37
lines changed

8 files changed

+11
-37
lines changed

cmd/goose/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func writeFileIfChanged(name string, data []byte, perm os.FileMode) error {
2323
return os.WriteFile(name, data, perm)
2424
}
2525
// file has correct contents, return
26-
if bytes.Compare(contents, data) == 0 {
26+
if bytes.Equal(contents, data) {
2727
return nil
2828
}
2929
return os.WriteFile(name, data, perm)

errors.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ type ConversionError struct {
9999
func (e *ConversionError) Error() string {
100100
lines := []string{
101101
fmt.Sprintf("[%s]: %s", e.Category, e.Message),
102-
fmt.Sprintf("%s", e.GoCode),
102+
e.GoCode,
103103
fmt.Sprintf(" %s", e.GooseCaller),
104104
fmt.Sprintf(" src: %s", e.GoSrcFile),
105105
}

goose.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ func (ctx Ctx) basicLiteral(e *ast.BasicLit) coq.Expr {
901901
return coq.StringLiteral{Value: s}
902902
}
903903
if e.Kind == token.INT {
904-
info, ok := getIntegerType(ctx.typeOf(e))
904+
info, _ := getIntegerType(ctx.typeOf(e))
905905
v := ctx.info.Types[e].Value
906906
n, ok := constant.Uint64Val(v)
907907
if !ok {
@@ -1259,7 +1259,6 @@ func (ctx Ctx) stmts(ss []ast.Stmt, usage ExprValUsage) coq.BlockExpr {
12591259
case *ast.IfStmt:
12601260
bindings = append(bindings, ctx.ifStmt(s, c.Remainder(), usage))
12611261
finalized = true
1262-
break // This would happen anyway since we consumed the iterator via "Remainder"
12631262
default:
12641263
// All other statements are translated one-by-one
12651264
if c.HasNext() {
@@ -2165,7 +2164,7 @@ func (ctx Ctx) maybeDecls(d ast.Decl) []coq.Decl {
21652164
cvs = ctx.stmtInterface(cvs, stmt, d)
21662165
}
21672166
fd := ctx.funcDecl(d)
2168-
results := []coq.Decl{}
2167+
var results []coq.Decl
21692168
if len(cvs) > 0 {
21702169
results = append(cvs, fd)
21712170
} else {

idents.go

-11
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,6 @@ func newIdentCtx() identCtx {
3434
return identCtx{info: make(map[scopedName]identInfo)}
3535
}
3636

37-
func (ctx Ctx) lookupIdentScope(ident *ast.Ident) scopedName {
38-
obj, ok := ctx.info.Uses[ident]
39-
if !ok {
40-
return scopedName{nil, ""}
41-
}
42-
useScope := obj.Parent()
43-
name := ident.Name
44-
defScope, _ := useScope.LookupParent(name, ident.Pos())
45-
return scopedName{scope: defScope, name: name}
46-
}
47-
4837
func (idents identCtx) lookupName(scope *types.Scope, name string) identInfo {
4938
if scope == types.Universe {
5039
return identInfo{

interface.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,7 @@ func (ctx Ctx) Decls(fs ...NamedFile) (imports coq.ImportDecls, decls []coq.Decl
118118

119119
for fi, f := range fs {
120120
if len(fs) > 1 {
121-
decls = append(decls,
122-
coq.NewComment(fmt.Sprintf("%s", f.Name())))
121+
decls = append(decls, coq.NewComment(f.Name()))
123122
}
124123
if f.Ast.Doc != nil {
125124
decls = append(decls, coq.NewComment(f.Ast.Doc.Text()))

internal/coq/coq.go

+2-15
Original file line numberDiff line numberDiff line change
@@ -315,15 +315,11 @@ type FuncType struct {
315315

316316
func (t FuncType) Coq(needs_paren bool) string {
317317
var args []string
318-
for _, a := range t.Params {
319-
args = append(args, a)
320-
}
318+
args = append(args, t.Params...)
321319
if len(t.Params) == 0 {
322320
args = []string{"unitT"}
323321
}
324-
for _, a := range t.Results {
325-
args = append(args, a)
326-
}
322+
args = append(args, t.Results...)
327323
if len(args) == 0 {
328324
args = []string{"<>"}
329325
}
@@ -1160,15 +1156,6 @@ func (f File) autogeneratedNotice() CommentDecl {
11601156
return CommentDecl(comment)
11611157
}
11621158

1163-
func stringInSlice(a string, list []string) bool {
1164-
for _, b := range list {
1165-
if b == a {
1166-
return true
1167-
}
1168-
}
1169-
return false
1170-
}
1171-
11721159
// Write outputs the Coq source for a File.
11731160
// noinspection GoUnhandledErrorResult
11741161
func (f File) Write(w io.Writer) {

internal/go_test/go_test.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ func TestGoPassingArrayCopies(t *testing.T) {
2424

2525
type S struct {
2626
a uint64
27-
b uint32
28-
c bool
2927
}
3028

3129
func (s *S) SetA() {
@@ -178,7 +176,7 @@ func TestGoSendBlocks(t *testing.T) {
178176
time.Sleep(200 * time.Millisecond)
179177
x := <-c
180178
assert.Equal(t, chanV, x)
181-
assert.Greater(t, time.Now().Sub(start).Milliseconds(), int64(100))
179+
assert.Greater(t, time.Since(start).Milliseconds(), int64(100))
182180
}
183181

184182
func TestGoRecvBlocks(t *testing.T) {
@@ -190,7 +188,7 @@ func TestGoRecvBlocks(t *testing.T) {
190188
}()
191189
x := <-c
192190
assert.Equal(t, chanV, x)
193-
assert.Greater(t, time.Now().Sub(start).Milliseconds(), int64(100))
191+
assert.Greater(t, time.Since(start).Milliseconds(), int64(100))
194192
}
195193

196194
func TestGoRecvOnNil(t *testing.T) {

machine/proph.go

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ package machine
66
// does not actually carry any data, but in GooseLang we store the ProphId.
77
// However, making a type opaque in Go seems to be tricky. Let's hope adding a
88
// private field helps.
9+
//
10+
//lint:ignore U1000 p is unused, see above comment.
911
type prophId struct{ p struct{} }
1012
type ProphId = *prophId
1113

0 commit comments

Comments
 (0)