2020-09-09 20:37:03 +00:00
|
|
|
run:
|
|
|
|
timeout: 10m
|
2022-03-04 08:17:41 +00:00
|
|
|
# Enable checking the by default skipped "examples" dirs
|
2023-12-02 17:16:09 +00:00
|
|
|
build-tags:
|
|
|
|
- all
|
2018-11-05 21:36:35 +00:00
|
|
|
linters:
|
|
|
|
enable-all: false
|
|
|
|
enable:
|
|
|
|
- errcheck
|
turn on the golangci-lint exhaustive linter (#15028)
Turn on the golangci-lint exhaustive linter. This is the first step
towards catching more missing cases during development rather than
in tests, or in production.
This might be best reviewed commit-by-commit, as the first commit turns
on the linter with the `default-signifies-exhaustive: true` option set,
which requires a lot less changes in the current codebase.
I think it's probably worth doing the second commit as well, as that
will get us the real benefits, even though we end up with a little bit
more churn. However it means all the `switch` statements are covered,
which isn't the case after the first commit, since we do have a lot of
`default` statements that just call `assert.Fail`.
Fixes #14601
## Checklist
- [x] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
- [x] I have formatted my code using `gofumpt`
<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!---
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-01-17 16:50:41 +00:00
|
|
|
- exhaustive
|
2023-01-11 20:52:51 +00:00
|
|
|
- prealloc
|
2023-03-03 16:36:39 +00:00
|
|
|
- gofumpt
|
2021-09-21 17:00:44 +00:00
|
|
|
- revive
|
2018-11-05 21:36:35 +00:00
|
|
|
- gosec
|
|
|
|
- govet
|
|
|
|
- ineffassign
|
|
|
|
- lll
|
|
|
|
- misspell
|
2023-01-06 01:10:56 +00:00
|
|
|
- nolintlint
|
2018-11-05 21:36:35 +00:00
|
|
|
- nakedret
|
|
|
|
- unconvert
|
2023-01-11 03:01:25 +00:00
|
|
|
- unused
|
2022-03-04 08:17:41 +00:00
|
|
|
- paralleltest
|
2023-12-12 12:19:42 +00:00
|
|
|
- perfsprint
|
2024-01-17 09:35:20 +00:00
|
|
|
- depguard
|
2024-01-17 14:56:37 +00:00
|
|
|
- importas
|
2023-01-06 01:10:56 +00:00
|
|
|
|
|
|
|
linters-settings:
|
2023-06-28 11:55:00 +00:00
|
|
|
nakedret:
|
|
|
|
# Make an issue if func has more lines of code than this setting, and it has naked returns.
|
|
|
|
# Default: 30
|
|
|
|
max-func-lines: 60
|
2023-01-06 01:10:56 +00:00
|
|
|
nolintlint:
|
|
|
|
# Some linter exclusions are added to generated or templated files
|
|
|
|
# pre-emptively.
|
|
|
|
# Don't complain about these.
|
|
|
|
allow-unused: true
|
2023-04-04 17:53:05 +00:00
|
|
|
govet:
|
2023-05-19 22:47:41 +00:00
|
|
|
enable:
|
|
|
|
- nilness
|
|
|
|
# Reject comparisons of reflect.Value with DeepEqual or '=='.
|
|
|
|
- reflectvaluecompare
|
|
|
|
# Reject sort.Slice calls with a non-slice argument.
|
|
|
|
- sortslice
|
|
|
|
# Detect write to struct/arrays by-value that aren't read again.
|
|
|
|
- unusedwrite
|
2024-01-17 09:35:20 +00:00
|
|
|
depguard:
|
|
|
|
rules:
|
|
|
|
protobuf:
|
|
|
|
deny:
|
|
|
|
- pkg: "github.com/golang/protobuf"
|
|
|
|
desc: Use google.golang.org/protobuf instead
|
2024-01-17 14:56:37 +00:00
|
|
|
importas:
|
|
|
|
alias:
|
|
|
|
- pkg: github.com/pulumi/pulumi/sdk/v3/proto/go
|
|
|
|
alias: pulumirpc
|
|
|
|
- pkg: github.com/pulumi/pulumi/sdk/v3/proto/go/testing
|
|
|
|
alias: testingrpc
|
|
|
|
- pkg: github.com/deckarep/golang-set/v2
|
|
|
|
alias: mapset
|
2024-02-29 21:06:24 +00:00
|
|
|
- pkg: github.com/pulumi/pulumi/sdk/v3/go/common/testing
|
|
|
|
alias: ptesting
|
golangci-lint: Enable staticcheck
Remove staticcheck from the list of disabled linters.
It's enabled by default in golangci-lint.
This also fixes minor remaining staticcheck issues
that don't merit their own pull requests,
or opts out of those that cannot be fixed yet.
Notably, we're opting out of:
- Resource.Name is deprecated (#9469)
- github.com/golang/protobuf is deprecated (#11869)
- strings.Title has been deprecated (#11870)
Besides that, other issues addressed in this change are:
```
// all issues are in pkg
codegen/schema/docs_parser.go:103:4: SA4006: this value of `text` is never used (staticcheck)
codegen/schema/loader.go:253:3: SA9003: empty branch (staticcheck)
resource/deploy/step_executor.go:328:12: SA9003: empty branch (staticcheck)
resource/deploy/step_generator.go:141:10: SA9003: empty branch (staticcheck)
codegen/pcl/invoke.go:97:10: SA9003: empty branch (staticcheck)
codegen/hcl2/model/type_const.go:57:2: SA9003: empty branch (staticcheck)
codegen/hcl2/model/type_enum.go:99:9: SA4001: &*x will be simplified to x. It will not copy x. (staticcheck)
codegen/go/gen_test.go:399:19: SA4017: HasPrefix is a pure function but its return value is ignored (staticcheck)
```
Depends on #11857, #11858, #11859, #11860, #11862, #11865, #11866, #11867, #11868
Resolves #11808
2023-01-11 19:53:41 +00:00
|
|
|
|
|
|
|
issues:
|
2023-03-20 23:49:45 +00:00
|
|
|
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 _'
|
|
|
|
|
2023-03-20 23:03:05 +00:00
|
|
|
# staticcheck already has smarter checks for empty blocks.
|
|
|
|
# revive's empty-block linter has false positives.
|
|
|
|
# For example, as of writing this, the following is not allowed.
|
|
|
|
# for foo() { }
|
|
|
|
- linters: [revive]
|
|
|
|
text: 'empty-block: this block is empty, you can remove it'
|
|
|
|
|
2023-03-20 23:39:42 +00:00
|
|
|
# We *frequently* use the term 'new' in the context of properties
|
|
|
|
# (new and old properties),
|
|
|
|
# and we rarely use the 'new' built-in function.
|
|
|
|
# It's fine to ignore these cases.
|
|
|
|
- linters: [revive]
|
|
|
|
text: 'redefines-builtin-id: redefinition of the built-in function new'
|
|
|
|
|
golangci-lint: Enable staticcheck
Remove staticcheck from the list of disabled linters.
It's enabled by default in golangci-lint.
This also fixes minor remaining staticcheck issues
that don't merit their own pull requests,
or opts out of those that cannot be fixed yet.
Notably, we're opting out of:
- Resource.Name is deprecated (#9469)
- github.com/golang/protobuf is deprecated (#11869)
- strings.Title has been deprecated (#11870)
Besides that, other issues addressed in this change are:
```
// all issues are in pkg
codegen/schema/docs_parser.go:103:4: SA4006: this value of `text` is never used (staticcheck)
codegen/schema/loader.go:253:3: SA9003: empty branch (staticcheck)
resource/deploy/step_executor.go:328:12: SA9003: empty branch (staticcheck)
resource/deploy/step_generator.go:141:10: SA9003: empty branch (staticcheck)
codegen/pcl/invoke.go:97:10: SA9003: empty branch (staticcheck)
codegen/hcl2/model/type_const.go:57:2: SA9003: empty branch (staticcheck)
codegen/hcl2/model/type_enum.go:99:9: SA4001: &*x will be simplified to x. It will not copy x. (staticcheck)
codegen/go/gen_test.go:399:19: SA4017: HasPrefix is a pure function but its return value is ignored (staticcheck)
```
Depends on #11857, #11858, #11859, #11860, #11862, #11865, #11866, #11867, #11868
Resolves #11808
2023-01-11 19:53:41 +00:00
|
|
|
exclude:
|
|
|
|
# https://github.com/pulumi/pulumi/issues/9469
|
|
|
|
- 'Name is deprecated: Name returns the variable or declaration name of the resource'
|
|
|
|
|
|
|
|
# https://github.com/pulumi/pulumi/issues/11869
|
|
|
|
- '"github.com/golang/protobuf/[\w/]+" is deprecated'
|
|
|
|
|
|
|
|
# https://github.com/pulumi/pulumi/issues/11870
|
|
|
|
- 'strings.Title has been deprecated'
|
2023-03-01 22:33:59 +00:00
|
|
|
|
|
|
|
# https://github.com/pulumi/pulumi/issues/12328
|
2024-04-26 13:01:58 +00:00
|
|
|
- 'deprecated: Please use types in:? cloud.google.com/go/logging/apiv2/loggingpb'
|
|
|
|
|
|
|
|
exclude-dirs:
|
|
|
|
- Godeps$
|
|
|
|
- builtin$
|
|
|
|
- node_modules
|
|
|
|
- testdata$
|
|
|
|
- third_party$
|
|
|
|
- vendor$
|
|
|
|
exclude-dirs-use-default: false
|