pulumi / pulumi-yaml

YAML language provider for Pulumi
Apache License 2.0
38 stars 11 forks source link

ci/lint: Enable staticcheck and other linters #487

Closed abhinav closed 1 year ago

abhinav commented 1 year ago

Enables nearly all the same linters that are used in pulumi/pulumi, disabling deprecated or unused linters (per pulumi/pulumi).

The following linters were not enabled:

Fixes the following issues as part of enabling the linters:

pkg/pulumiyaml/ast/template.go:67:34: S1019: should use make([]*StringExpr, list.Len()) instead (gosimple)
pkg/pulumiyaml/ast/template.go:102:36: S1019: should use make([]ConfigMapEntry, obj.Len()) instead (gosimple)
pkg/pulumiyaml/ast/template.go:157:39: S1019: should use make([]VariablesMapEntry, obj.Len()) instead (gosimple)
pkg/pulumiyaml/ast/template.go:199:39: S1019: should use make([]ResourcesMapEntry, obj.Len()) instead (gosimple)
pkg/pulumiyaml/ast/template.go:251:38: S1019: should use make([]PropertyMapEntry, obj.Len()) instead (gosimple)
pkg/pulumiyaml/ast/template.go:618:25: SA6005: should use strings.EqualFold instead (staticcheck)
pkg/pulumiyaml/diags/utils.go:47:2: S1001: should use copy(to, from) instead of a loop (gosimple)
pkg/pulumiyaml/diags/diags.go:125:12: S1039: unnecessary use of fmt.Sprintf (gosimple)
pkg/pulumiyaml/diags/diags.go:143:14: S1039: unnecessary use of fmt.Sprintf (gosimple)
pkg/pulumiyaml/syntax/diags.go:91:19: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
pkg/pulumiyaml/packages.go:161:63: S1039: unnecessary use of fmt.Sprintf (gosimple)
pkg/pulumiyaml/analyser.go:1225:2: S1008: should use 'return e.VisitExpr(ctx, x)' instead of 'if !e.VisitExpr(ctx, x) { return false }; return true' (gosimple)
pkg/pulumiyaml/run.go:12:2: SA1019: "io/ioutil" has been deprecated since Go 1.19: As of Go 1.16, the same functionality is now provided by package io or package os, and those implementations should be preferred in new code. See the specific function documentation for details. (staticcheck)
pkg/pulumiyaml/analyser.go:800:8: SA6005: should use strings.EqualFold instead (staticcheck)
pkg/pulumiyaml/codegen/load.go:715:2: S1023: redundant `return` statement (gosimple)
pkg/pulumiyaml/codegen/gen_program.go:531:9: nilness: panic with nil value (govet)
pkg/pulumiyaml/codegen/gen_program.go:181:21: SA5009: couldn't parse format string (staticcheck)
pkg/pulumiyaml/codegen/gen_program.go:168:2: SA1019: contract.Assert is deprecated: Use Assertf. (staticcheck)
pkg/pulumiyaml/codegen/gen_program.go:203:3: SA1019: contract.Assert is deprecated: Use Assertf. (staticcheck)
pkg/pulumiyaml/codegen/gen_program.go:229:4: SA1019: contract.Assert is deprecated: Use Assertf. (staticcheck)
pkg/pulumiyaml/codegen/gen_program.go:732:2: SA1019: contract.Assert is deprecated: Use Assertf. (staticcheck)
pkg/pulumiyaml/codegen/gen_program.go:733:2: SA1019: contract.Assert is deprecated: Use Assertf. (staticcheck)
pkg/pulumiyaml/codegen/gen_program.go:739:3: SA1019: contract.Assert is deprecated: Use Assertf. (staticcheck)
pkg/pulumiyaml/codegen/load.go:519:2: SA1019: contract.Assert is deprecated: Use Assertf. (staticcheck)
pkg/pulumiyaml/codegen/load.go:630:2: SA1019: contract.Assert is deprecated: Use Assertf. (staticcheck)
pkg/pulumiyaml/codegen/load.go:723:2: SA1019: contract.Assert is deprecated: Use Assertf. (staticcheck)
pkg/pulumiyaml/codegen/load.go:896:2: SA1019: contract.Assert is deprecated: Use Assertf. (staticcheck)
pkg/pulumiyaml/codegen/load.go:1071:3: SA1019: contract.Assert is deprecated: Use Assertf. (staticcheck)
pkg/pulumiyaml/codegen/gen_program.go:10:2: SA1019: "io/ioutil" has been deprecated since Go 1.19: As of Go 1.16, the same functionality is now provided by package io or package os, and those implementations should be preferred in new code. See the specific function documentation for details. (staticcheck)
pkg/tests/example_transpile_test.go:8:2: SA1019: "io/ioutil" has been deprecated since Go 1.19: As of Go 1.16, the same functionality is now provided by package io or package os, and those implementations should be preferred in new code. See the specific function documentation for details. (staticcheck)
pkg/tests/example_test.go:86:65: SA4009: argument err is overwritten before first use (staticcheck)
pkg/tests/example_test.go:96:5: SA4009(related information): assignment to err (staticcheck)
pkg/tests/example_test.go:103:5: directive `// nolint:gosec // temporary file, no secrets, non-executable` should be written without leading space as `//nolint:gosec // temporary file, no secrets, non-executable` (nolintlint)

The following issues were fixed in a separate commit because they appear to have some bearing on logic and may represent bugs in pulumi-yaml.

pkg/pulumiyaml/codegen/gen_program.go:230:24: SA4010: this result of append is never used, except maybe in other appends (staticcheck)
pkg/pulumiyaml/codegen/load.go:569:19: SA4010: this result of append is never used, except maybe in other appends (staticcheck)
abhinav commented 1 year ago

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.