Skip to content

Commit 05f21cd

Browse files
authored
Merge pull request #29492 from hashicorp/jbardin/staticcheck
Add staticcheck to CI
2 parents 7c02ef6 + 863963e commit 05f21cd

31 files changed

+55
-184
lines changed

.circleci/config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ jobs:
2626
steps:
2727
- checkout
2828
- run: go mod verify
29-
- run: make fmtcheck generate
29+
- run: go install honnef.co/go/tools/cmd/staticcheck
30+
- run: make fmtcheck generate staticcheck
3031
- run:
3132
name: verify no code was generated
3233
command: |

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ protobuf:
2020
fmtcheck:
2121
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
2222

23+
staticcheck:
24+
@sh -c "'$(CURDIR)/scripts/staticcheck.sh'"
25+
2326
website:
2427
ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
2528
echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..."
@@ -46,4 +49,4 @@ endif
4649
# under parallel conditions.
4750
.NOTPARALLEL:
4851

49-
.PHONY: fmtcheck generate protobuf website website-test
52+
.PHONY: fmtcheck generate protobuf website website-test staticcheck

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ require (
1414
github.com/Azure/go-autorest/logger v0.2.1 // indirect
1515
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
1616
github.com/Azure/go-ntlmssp v0.0.0-20200615164410-66371956d46c // indirect
17+
github.com/BurntSushi/toml v0.3.1 // indirect
1718
github.com/ChrisTrenkamp/goxpath v0.0.0-20190607011252-c5096ec8773d // indirect
1819
github.com/Masterminds/goutils v1.1.0 // indirect
1920
github.com/Masterminds/semver v1.5.0 // indirect
@@ -172,6 +173,7 @@ require (
172173
gopkg.in/inf.v0 v0.9.0 // indirect
173174
gopkg.in/ini.v1 v1.42.0 // indirect
174175
gopkg.in/yaml.v2 v2.3.0 // indirect
176+
honnef.co/go/tools v0.0.1-2020.1.4
175177
k8s.io/api v0.0.0-20190620084959-7cf5895f2711
176178
k8s.io/apimachinery v0.0.0-20190913080033-27d36303b655
177179
k8s.io/client-go v10.0.0+incompatible

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBp
7474
github.com/Azure/go-ntlmssp v0.0.0-20180810175552-4a21cbd618b4/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU=
7575
github.com/Azure/go-ntlmssp v0.0.0-20200615164410-66371956d46c h1:/IBSNwUN8+eKzUzbJPqhK839ygXJ82sde8x3ogr6R28=
7676
github.com/Azure/go-ntlmssp v0.0.0-20200615164410-66371956d46c/go.mod h1:chxPXzSsl7ZWRAuOIE23GDNzjWuZquvFlgA8xmpunjU=
77+
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
7778
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
7879
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
7980
github.com/ChrisTrenkamp/goxpath v0.0.0-20170922090931-c385f95c6022/go.mod h1:nuWgzSkT5PnyOd+272uUmV0dnAnAn42Mk7PiQC5VzN4=
@@ -1061,6 +1062,7 @@ honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWh
10611062
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
10621063
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
10631064
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
1065+
honnef.co/go/tools v0.0.1-2020.1.4 h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8=
10641066
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
10651067
k8s.io/api v0.0.0-20190620084959-7cf5895f2711 h1:BblVYz/wE5WtBsD/Gvu54KyBUTJMflolzc5I2DTvh50=
10661068
k8s.io/api v0.0.0-20190620084959-7cf5895f2711/go.mod h1:TBhBqb1AWbBQbW3XRusr7n7E4v2+5ZY8r8sAMnyFC5A=

internal/addrs/resource.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,10 @@ func (r AbsResource) absMoveableSigil() {
194194
// AbsResource is moveable
195195
}
196196

197-
type absResourceKey string
198-
199197
func (r AbsResource) UniqueKey() UniqueKey {
200198
return absResourceInstanceKey(r.String())
201199
}
202200

203-
func (rk absResourceKey) uniqueKeySigil() {}
204-
205201
// AbsResourceInstance is an absolute address for a resource instance under a
206202
// given module path.
207203
type AbsResourceInstance struct {

internal/backend/remote/backend.go

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ func (b *Remote) VerifyWorkspaceTerraformVersion(workspaceName string) tfdiags.D
888888

889889
// If the workspace has remote operations disabled, the remote Terraform
890890
// version is effectively meaningless, so we'll skip version verification.
891-
if workspace.Operations == false {
891+
if !workspace.Operations {
892892
return nil
893893
}
894894

@@ -963,22 +963,6 @@ func (b *Remote) IsLocalOperations() bool {
963963
return b.forceLocal
964964
}
965965

966-
// Colorize returns the Colorize structure that can be used for colorizing
967-
// output. This is guaranteed to always return a non-nil value and so useful
968-
// as a helper to wrap any potentially colored strings.
969-
//
970-
// TODO SvH: Rename this back to Colorize as soon as we can pass -no-color.
971-
func (b *Remote) cliColorize() *colorstring.Colorize {
972-
if b.CLIColor != nil {
973-
return b.CLIColor
974-
}
975-
976-
return &colorstring.Colorize{
977-
Colors: colorstring.DefaultColors,
978-
Disable: true,
979-
}
980-
}
981-
982966
func generalError(msg string, err error) error {
983967
var diags tfdiags.Diagnostics
984968

internal/backend/remote/backend_apply_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,7 @@ func TestRemote_applyVersionCheck(t *testing.T) {
15941594
}
15951595

15961596
// RUN: prepare the apply operation and run it
1597-
op, configCleanup, done := testOperationApply(t, "./testdata/apply")
1597+
op, configCleanup, _ := testOperationApply(t, "./testdata/apply")
15981598
defer configCleanup()
15991599

16001600
streams, done := terminal.StreamsForTesting(t)

internal/command/apply.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ func (c *ApplyCommand) Run(rawArgs []string) int {
4545

4646
// Instantiate the view, even if there are flag errors, so that we render
4747
// diagnostics according to the desired view
48-
var view views.Apply
49-
view = views.NewApply(args.ViewType, c.Destroy, c.View)
48+
view := views.NewApply(args.ViewType, c.Destroy, c.View)
5049

5150
if diags.HasErrors() {
5251
view.Diagnostics(diags)

internal/command/apply_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,6 +1779,7 @@ func TestApply_terraformEnvNonDefault(t *testing.T) {
17791779
},
17801780
}
17811781
if code := newCmd.Run([]string{"test"}); code != 0 {
1782+
t.Fatal("error creating workspace")
17821783
}
17831784
}
17841785

@@ -1792,6 +1793,7 @@ func TestApply_terraformEnvNonDefault(t *testing.T) {
17921793
},
17931794
}
17941795
if code := selCmd.Run(args); code != 0 {
1796+
t.Fatal("error switching workspace")
17951797
}
17961798
}
17971799

internal/command/format/diff.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func ResourceChange(
7070
buf.WriteString(color.Color(fmt.Sprintf("[bold] # %s[reset] will be [bold][red]destroyed", dispAddr)))
7171
if change.DeposedKey != states.NotDeposed {
7272
// Some extra context about this unusual situation.
73-
buf.WriteString(color.Color(fmt.Sprint("\n # (left over from a partially-failed replacement of this instance)")))
73+
buf.WriteString(color.Color("\n # (left over from a partially-failed replacement of this instance)"))
7474
}
7575
default:
7676
// should never happen, since the above is exhaustive
@@ -755,8 +755,6 @@ func (p *blockBodyDiffPrinter) writeNestedAttrDiff(
755755
p.buf.WriteString(" -> (known after apply)")
756756
}
757757
}
758-
759-
return
760758
}
761759

762760
func (p *blockBodyDiffPrinter) writeNestedBlockDiffs(name string, blockS *configschema.NestedBlock, old, new cty.Value, blankBefore bool, indent int, path cty.Path) int {

0 commit comments

Comments
 (0)