Skip to content

Commit eeacced

Browse files
authored
Add go vet as a check to the Github commit actions (#31461)
* Add go vet as a check to the Github commit actions * deliberately break to test * fix after successful test * Use directly * fix more errors
1 parent dacd04c commit eeacced

File tree

9 files changed

+19
-9
lines changed

9 files changed

+19
-9
lines changed

Diff for: .github/workflows/checks.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ jobs:
191191
192192
- name: "Code consistency checks"
193193
run: |
194-
make fmtcheck importscheck copyright generate staticcheck exhaustive protobuf
194+
make fmtcheck importscheck vetcheck copyright generate staticcheck exhaustive protobuf
195195
if [[ -n "$(git status --porcelain)" ]]; then
196196
echo >&2 "ERROR: Generated files are inconsistent. Run 'make generate' and 'make protobuf' locally and then commit the updated files."
197197
git >&2 status --porcelain

Diff for: Makefile

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ fmtcheck:
2020
importscheck:
2121
"$(CURDIR)/scripts/goimportscheck.sh"
2222

23+
vetcheck:
24+
@echo "==> Checking that the code complies with go vet requirements"
25+
@go vet ./...
26+
2327
staticcheck:
2428
"$(CURDIR)/scripts/staticcheck.sh"
2529

@@ -52,4 +56,4 @@ website/build-local:
5256
# under parallel conditions.
5357
.NOTPARALLEL:
5458

55-
.PHONY: fmtcheck importscheck generate protobuf staticcheck syncdeps website website/local website/build-local
59+
.PHONY: fmtcheck importscheck vetcheck generate protobuf staticcheck syncdeps website website/local website/build-local

Diff for: internal/addrs/module_instance_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ func TestModuleInstanceEqual_false(t *testing.T) {
8484
func BenchmarkStringShort(b *testing.B) {
8585
addr, _ := ParseModuleInstanceStr(`module.foo`)
8686
for n := 0; n < b.N; n++ {
87-
addr.String()
87+
_ = addr.String()
8888
}
8989
}
9090

9191
func BenchmarkStringLong(b *testing.B) {
9292
addr, _ := ParseModuleInstanceStr(`module.southamerica-brazil-region.module.user-regional-desktops.module.user-name`)
9393
for n := 0; n < b.N; n++ {
94-
addr.String()
94+
_ = addr.String()
9595
}
9696
}
9797

Diff for: internal/addrs/module_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ func TestModuleString(t *testing.T) {
8787
func BenchmarkModuleStringShort(b *testing.B) {
8888
module := Module{"a", "b"}
8989
for n := 0; n < b.N; n++ {
90-
module.String()
90+
_ = module.String()
9191
}
9292
}
9393

9494
func BenchmarkModuleStringLong(b *testing.B) {
9595
module := Module{"southamerica-brazil-region", "user-regional-desktop", "user-name"}
9696
for n := 0; n < b.N; n++ {
97-
module.String()
97+
_ = module.String()
9898
}
9999
}

Diff for: internal/command/apply_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,10 @@ func TestApply_parallelism(t *testing.T) {
293293
// to proceed in unison.
294294
beginCtx, begin := context.WithCancel(context.Background())
295295

296+
// This just makes go vet happy, in reality the function will never exit if
297+
// begin() isn't called inside ApplyResourceChangeFn.
298+
defer begin()
299+
296300
// Since our mock provider has its own mutex preventing concurrent calls
297301
// to ApplyResourceChange, we need to use a number of separate providers
298302
// here. They will all have the same mock implementation function assigned

Diff for: internal/command/plan_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -1429,6 +1429,10 @@ func TestPlan_parallelism(t *testing.T) {
14291429
// to proceed in unison.
14301430
beginCtx, begin := context.WithCancel(context.Background())
14311431

1432+
// This just makes go vet happy, in reality the function will never exit if
1433+
// begin() isn't called inside ApplyResourceChangeFn.
1434+
defer begin()
1435+
14321436
// Since our mock provider has its own mutex preventing concurrent calls
14331437
// to ApplyResourceChange, we need to use a number of separate providers
14341438
// here. They will all have the same mock implementation function assigned

Diff for: internal/configs/config.go

-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ func (c *Config) TargetExists(target addrs.Targetable) bool {
229229
default:
230230
panic(fmt.Errorf("unrecognized targetable type: %d", target.AddrType()))
231231
}
232-
return true
233232
}
234233

235234
// EntersNewPackage returns true if this call is to an external module, either

Diff for: internal/grpcwrap/provider6.go

-1
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,6 @@ func (p *provider6) CloseEphemeralResource(_ context.Context, req *tfplugin6.Clo
519519

520520
func (p *provider6) GetFunctions(context.Context, *tfplugin6.GetFunctions_Request) (*tfplugin6.GetFunctions_Response, error) {
521521
panic("unimplemented")
522-
return nil, nil
523522
}
524523

525524
func (p *provider6) CallFunction(_ context.Context, req *tfplugin6.CallFunction_Request) (*tfplugin6.CallFunction_Response, error) {

Diff for: internal/moduletest/hcl/variable_cache_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TestFileVariables(t *testing.T) {
6868
FileVariables: func() map[string]hcl.Expression {
6969
vars := make(map[string]hcl.Expression)
7070
for name, value := range tc.Values {
71-
expr, diags := hclsyntax.ParseExpression([]byte(value), "test.tf", hcl.Pos{0, 0, 0})
71+
expr, diags := hclsyntax.ParseExpression([]byte(value), "test.tf", hcl.Pos{Line: 0, Column: 0, Byte: 0})
7272
if len(diags) > 0 {
7373
t.Fatalf("unexpected errors: %v", diags)
7474
}

0 commit comments

Comments
 (0)