From 48c2e135383f7e4ae5ec4f9b6e1adea47d85c03c Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Tue, 1 Aug 2023 11:50:18 -0700 Subject: [PATCH] lint(all): Fix golangci-lint issues Before using golangci-lint-action, lint failures were ignored as the check was: make lint-golang || true This fixes the issues found by the linter minus revive's "unused parameter" check which is not something we agree with. This matches what we've done in pulumi/pulumi. --- .golangci.yml | 7 +++++++ pkg/pulumiyaml/analyser.go | 3 +-- pkg/tests/integration_test.go | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index fd93fa9f..50a70516 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -21,3 +21,10 @@ linters: - lll - staticcheck # Disabled due to OOM errors in golangci-lint@v1.18.0 - megacheck # Disabled due to OOM errors in golangci-lint@v1.18.0 + +issues: + exclude-rules: + # Don't warn on unused parameters. + # Parameter names are useful; replacing them with '_' is undesirable. + - linters: [revive] + text: 'unused-parameter: parameter \S+ seems to be unused, consider removing or renaming it as _' diff --git a/pkg/pulumiyaml/analyser.go b/pkg/pulumiyaml/analyser.go index 345fa141..1427d878 100644 --- a/pkg/pulumiyaml/analyser.go +++ b/pkg/pulumiyaml/analyser.go @@ -1099,9 +1099,8 @@ func (tc *typeCache) typeConfig(r *Runner, node configNode) bool { ctx.errorf(node.key(), `config key "%s" cannot have conflicting types %v, %v`, k, codegen.UnwrapType(typExisting), codegen.UnwrapType(typCurrent)) return false - } else { - typCurrent = typExisting } + typCurrent = typExisting } tc.configuration[k] = typCurrent return true diff --git a/pkg/tests/integration_test.go b/pkg/tests/integration_test.go index f72d4269..ccfd0302 100644 --- a/pkg/tests/integration_test.go +++ b/pkg/tests/integration_test.go @@ -29,6 +29,7 @@ func TestTypeCheckError(t *testing.T) { }) } +//nolint:paralleltest // uses parallel programtest func TestMismatchedConfigType(t *testing.T) { testWrapper(t, integrationDir("mismatched-config-type"), ExpectFailure, StderrValidator{ f: func(t *testing.T, stderr string) { @@ -38,6 +39,7 @@ func TestMismatchedConfigType(t *testing.T) { }) } +//nolint:paralleltest // uses parallel programtest func TestProjectConfigRef(t *testing.T) { testWrapper(t, integrationDir("project-config-ref"), ExpectFailure, StderrValidator{ f: func(t *testing.T, stderr string) {