-
Notifications
You must be signed in to change notification settings - Fork 98
Discuss and Implement Go Static Analysis Tooling #96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I could've sworn we were running |
…e linting Reference: #96 Reference: #97 Fixes the previous linting issues: ```console ❯ golangci-lint run ./... internal/reflect/helpers.go:47:20: `getStructTags` - `ctx` is unused (unparam) func getStructTags(ctx context.Context, in reflect.Value, path *tftypes.AttributePath) (map[string]int, error) { ^ internal/reflect/pointer.go:54:27: `pointerSafeZeroValue` - `ctx` is unused (unparam) func pointerSafeZeroValue(ctx context.Context, target reflect.Value) reflect.Value { ^ types/float64.go:13:22: `float64Validate` - `ctx` is unused (unparam) func float64Validate(ctx context.Context, in tftypes.Value, path *tftypes.AttributePath) diag.Diagnostics { ^ types/int64.go:13:20: `int64Validate` - `ctx` is unused (unparam) func int64Validate(ctx context.Context, in tftypes.Value, path *tftypes.AttributePath) diag.Diagnostics { ^ tfsdk/plan.go:210:26: `(Plan).pathExists` - `ctx` is unused (unparam) func (p Plan) pathExists(ctx context.Context, path *tftypes.AttributePath) (bool, diag.Diagnostics) { ^ tfsdk/serve.go:70:43: `(*server).cancelRegisteredContexts` - `ctx` is unused (unparam) func (s *server) cancelRegisteredContexts(ctx context.Context) { ^ tfsdk/state.go:219:27: `(State).pathExists` - `ctx` is unused (unparam) func (s State) pathExists(ctx context.Context, path *tftypes.AttributePath) (bool, diag.Diagnostics) { ^ tfsdk/tftypes_value.go:16:24: `createParentValue` - `ctx` is unused (unparam) func createParentValue(ctx context.Context, parentPath *tftypes.AttributePath, parentType tftypes.Type, childValue interface{}) (tftypes.Value, diag.Diagnostics) { ^ tfsdk/tftypes_value.go:61:23: `upsertChildValue` - `ctx` is unused (unparam) func upsertChildValue(ctx context.Context, parentPath *tftypes.AttributePath, parentValue tftypes.Value, childStep tftypes.AttributePathStep, childValue tftypes.Value) (tftypes.Value, diag.Diagnostics) { ^ tfsdk/value_as_test.go:109:16: S1040: type assertion to the same type: target already has type attr.Value (gosimple) if !val.Equal(target.(attr.Value)) { ^ tfsdk/attribute_plan_modification.go:310:9: SA9003: empty branch (staticcheck) } else if resp.RequiresReplace { ``` All testing and linting workflows verified as successful via: ```shell act -s GITHUB_TOKEN=$GITHUB_TOKEN pull_request ```
…e linting (#255) Reference: #96 Reference: #97 Fixes the previous linting issues: ```console ❯ golangci-lint run ./... internal/reflect/helpers.go:47:20: `getStructTags` - `ctx` is unused (unparam) func getStructTags(ctx context.Context, in reflect.Value, path *tftypes.AttributePath) (map[string]int, error) { ^ internal/reflect/pointer.go:54:27: `pointerSafeZeroValue` - `ctx` is unused (unparam) func pointerSafeZeroValue(ctx context.Context, target reflect.Value) reflect.Value { ^ types/float64.go:13:22: `float64Validate` - `ctx` is unused (unparam) func float64Validate(ctx context.Context, in tftypes.Value, path *tftypes.AttributePath) diag.Diagnostics { ^ types/int64.go:13:20: `int64Validate` - `ctx` is unused (unparam) func int64Validate(ctx context.Context, in tftypes.Value, path *tftypes.AttributePath) diag.Diagnostics { ^ tfsdk/plan.go:210:26: `(Plan).pathExists` - `ctx` is unused (unparam) func (p Plan) pathExists(ctx context.Context, path *tftypes.AttributePath) (bool, diag.Diagnostics) { ^ tfsdk/serve.go:70:43: `(*server).cancelRegisteredContexts` - `ctx` is unused (unparam) func (s *server) cancelRegisteredContexts(ctx context.Context) { ^ tfsdk/state.go:219:27: `(State).pathExists` - `ctx` is unused (unparam) func (s State) pathExists(ctx context.Context, path *tftypes.AttributePath) (bool, diag.Diagnostics) { ^ tfsdk/tftypes_value.go:16:24: `createParentValue` - `ctx` is unused (unparam) func createParentValue(ctx context.Context, parentPath *tftypes.AttributePath, parentType tftypes.Type, childValue interface{}) (tftypes.Value, diag.Diagnostics) { ^ tfsdk/tftypes_value.go:61:23: `upsertChildValue` - `ctx` is unused (unparam) func upsertChildValue(ctx context.Context, parentPath *tftypes.AttributePath, parentValue tftypes.Value, childStep tftypes.AttributePathStep, childValue tftypes.Value) (tftypes.Value, diag.Diagnostics) { ^ tfsdk/value_as_test.go:109:16: S1040: type assertion to the same type: target already has type attr.Value (gosimple) if !val.Equal(target.(attr.Value)) { ^ tfsdk/attribute_plan_modification.go:310:9: SA9003: empty branch (staticcheck) } else if resp.RequiresReplace { ``` All testing and linting workflows verified as successful via: ```shell act -s GITHUB_TOKEN=$GITHUB_TOKEN pull_request ```
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Module version
Use-cases
The Go ecosystem has a plethora of static analysis tooling, which can help catch code bugs, enhance quality, and automate style decisions. For example,
revive
(the spiritual successor togolint
) can require Go documentation comments on exported types and functions, which seems desirable given the purpose of this codebase.Proposal
I have worked successfully with
golangci-lint
via GitHub Actions (and before thatgometalinter
), which brings many static analysis tools under one tool and configuration. This is open for discussion though!The text was updated successfully, but these errors were encountered: