forked from hashicorp/terraform-provider-tfe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.golangci.yml
147 lines (145 loc) · 7.06 KB
/
.golangci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
run:
timeout: 5m
linters:
# This set of linters are enabled by default: deadcode, errcheck, gosimple, govet, ineffasign, staticcheck, struccheck, typecheck, unused, varcheck
enable:
# List of all linters: https://golangci-lint.run/usage/linters/
- whitespace #https://github.com/ultraware/whitespace
- noctx #https://github.com/sonatard/noctx
- nilerr #https://github.com/gostaticanalysis/nilerr
- nestif #https://github.com/nakabonne/nestif
- exportloopref #https://github.com/kyoh86/exportloopref
- bodyclose #https://github.com/timakin/bodyclose
# - goconst #https://github.com/jgautheron/goconst
- stylecheck #https://github.com/dominikh/go-tools/tree/master/stylecheck
- revive #golint is deprecated and golangci-lint recommends to use revive instead https://github.com/mgechev/revive
#other deprecated lint libraries: maligned, scopelint, interfacer
- gocritic #https://github.com/go-critic/go-critic
- unparam #https://github.com/mvdan/unparam
- misspell #https://github.com/client9/misspell
- errorlint #https://github.com/polyfloyd/go-errorlint
- gosec #https://github.com/securego/gosec
- predeclared #https://github.com/nishanths/predeclared
- unconvert #https://github.com/mdempsky/unconvert
- wrapcheck #https://github.com/tomarrell/wrapcheck
issues:
exclude-rules:
- path: _test\.go
linters:
- unused
- deadcode
# Exclude stylecheck underscore warnings in test files since most test files already follow this pattern
- linters:
- stylecheck
path: _test\.go
text: "should not use underscores in Go names"
# Exclude gocritic paramTypeCombine errors since it could make code less readable
- linters:
- gocritic
text: "paramTypeCombine"
# TO-DO: handle the following issues on separate tickets.
# Although errcheck is important for detecting bugs, it is disabled since fixing requires lots of logic testing.
- linters:
- errcheck
path: \.go
- linters:
- gocritic
path: resource_tfe_policy_set\.go
text: "badRegexp"
- linters:
- gocritic
path: data_source_ip_ranges_test\.go
text: "regexpSimplify: can re-write"
- linters:
- gosec
path: (_test|workspace_run_helpers)\.go
- linters:
- nestif
path: (resource_tfe_team_access|resource_tfe_workspace|credentials|resource_tfe_policy_set|
resource_tfe_policy_set|resource_tfe_team_members|resource_tfe_notification_configuration|resource_tfe_team)\.go
- linters:
- unparam
path: _test\.go
text: "always receives" # ignore unparam warning for all test files when a function param receives same mock data for it's test examples
- linters:
- errorlint
path: (data_source_organization|data_source_variable_set|data_source_workspace|resource_tfe_organization_token|
-|resource_tfe_team_token|plugin_provider_test|resource_tfe_agent_pool|resource_tfe_agent_token|resource_tfe_organization_module_sharing|
-|resource_tfe_policy_set|resource_tfe_policy_set_parameter|resource_tfe_team_members_test|resource_tfe_team_organization_member_test|
-|resource_tfe_notification_configuration|resource_tfe_oauth_client|resource_tfe_organization|resource_tfe_organization_membership|resource_tfe_team_members|
-|resource_tfe_registry_module|resource_tfe_run_trigger|resource_tfe_sentinel_policy|resource_tfe_ssh_key|resource_tfe_team|resource_tfe_team_access|
-|resource_tfe_team_member|resource_tfe_team_organization_member|resource_tfe_terraform_version|resource_tfe_variable_set|resource_tfe_variable|
-|resource_tfe_workspace|workspace_helpers)\.go
text: "comparing with == will fail on wrapped errors. Use errors.Is to check for a specific error"
- linters:
- errorlint
path: provider\.go
text: "type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors"
- linters:
- gosimple
path: resource_tfe_workspace\.go
text: "S1002: should omit comparison to bool constant"
- linters:
- gosimple
path: data_source_ip_ranges_test\.go
text: "S1039: unnecessary use of fmt.Sprintf"
- linters:
- gosimple
path: resource_tfe_team_members_test\.go
text: "S1019: should use make"
- linters:
- staticcheck
path: (resource_tfe_team_access_migrate_test|workspace_helpers_test)\.go
text: "SA1012: do not pass a nil Context, even if a function permits it; pass context.TODO if you are unsure about which Context to use"
- linters:
- staticcheck
path: (data_source_outputs|resource_tfe_agent_pool|resource_tfe_notification_configuration|resource_tfe_organization|resource_tfe_registry_module|
-|resource_tfe_run_trigger|resource_tfe_team_access|resource_tfe_organization_membership|resource_tfe_policy_set|resource_tfe_team_member|
-|resource_tfe_workspace|resource_tfe_team_organization_member|resource_tfe_variable_set|resource_tfe_team_project_access)\.go
text: "SA1019"
- linters:
- wrapcheck
path: (config_unix|data_source_slug|data_source_workspace|provider|resource_tfe_variable|resource_tfe_workspace|provider_test)\.go
text: "error returned from external package is unwrapped"
- linters:
- wrapcheck
path: (logging|plugin_provider|resource_tfe_oauth_client|resource_tfe_organization|resource_tfe_terraform_version|workspace_helpers|resource_tfe_agent_pool_test|
-|resource_tfe_agent_token_test|resource_tfe_notification_configuration_test|resource_tfe_oauth_client_test|resource_tfe_organization_membership_test|
-|resource_tfe_organization_test|resource_tfe_organization_token_test|resource_tfe_policy_set_parameter_test|resource_tfe_policy_set_test|resource_tfe_registry_module_test|
-|resource_tfe_run_trigger_test|resource_tfe_sentinel_policy_test|resource_tfe_ssh_key_test|resource_tfe_team_access_test|resource_tfe_team_member_test|
-|resource_tfe_team_member_test|resource_tfe_team_organization_member_test|resource_tfe_team_test|resource_tfe_team_token_test|resource_tfe_terraform_version_test|
-|resource_tfe_variable_set_test|resource_tfe_workspace_test|resource_tfe_team_members_test|resource_tfe_team_members_test|resource_tfe_variable_test)\.go
text: "error returned from interface method should be wrapped"
linters-settings:
# errcheck:
# # https://github.com/kisielk/errcheck#excluding-functions
# check-type-assertions: true
# check-blank: true
goconst:
min-len: 20
min-occurrences: 5
ignore-calls: false
ignore-tests: true
gocritic:
enabled-tags:
- diagnostic
- opinionated
- performance
disabled-checks:
- unnamedResult
- hugeParam
- singleCaseSwitch
- ifElseChain
- nestingReduce
- sloppyTestFuncName
revive:
# see https://github.com/mgechev/revive#available-rules for details.
ignore-generated-header: false #recommended in their configuration
severity: warning
rules:
- name: indent-error-flow #Prevents redundant else statements
severity: warning
- name: useless-break
severity: warning