Commit 74c4eeb
authored
Enable gosimple linter and fix issues (#880)
Reference: #865
Previously:
```text
helper/validation/float_test.go:66:17: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
expectedErr: regexp.MustCompile("expected [\\w]+ to be at least \\(2\\.5\\d*\\), got 1\\.5\\d*"),
^
helper/validation/float_test.go:71:17: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
expectedErr: regexp.MustCompile("expected type of [\\w]+ to be float"),
^
helper/validation/float_test.go:89:17: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
expectedErr: regexp.MustCompile("expected [\\w]+ to be at most \\(1\\.5\\d*\\), got 2\\.5\\d*"),
^
helper/validation/float_test.go:94:17: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
expectedErr: regexp.MustCompile("expected type of [\\w]+ to be float"),
^
helper/validation/int_test.go:21:17: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
expectedErr: regexp.MustCompile("expected [\\w]+ to be in the range \\(2 - 3\\), got 1"),
^
helper/validation/int_test.go:26:17: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
expectedErr: regexp.MustCompile("expected type of [\\w]+ to be integer"),
^
helper/validation/int_test.go:44:17: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
expectedErr: regexp.MustCompile("expected [\\w]+ to be at least \\(2\\), got 1"),
^
helper/validation/int_test.go:49:17: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
expectedErr: regexp.MustCompile("expected type of [\\w]+ to be integer"),
^
helper/validation/int_test.go:67:17: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
expectedErr: regexp.MustCompile("expected [\\w]+ to be at most \\(0\\), got 1"),
^
helper/validation/int_test.go:72:17: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
expectedErr: regexp.MustCompile("expected type of [\\w]+ to be integer"),
^
helper/validation/int_test.go:122:17: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
expectedErr: regexp.MustCompile("expected [\\w]+ to be one of \\[10 20\\], got 42"),
^
helper/validation/int_test.go:127:17: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
expectedErr: regexp.MustCompile("expected type of [\\w]+ to be integer"),
^
helper/validation/meta_test.go:55:17: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
expectedErr: regexp.MustCompile("expected length of [\\w]+ to be in the range \\(5 - 42\\), got foo"),
^
helper/validation/meta_test.go:90:17: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
expectedErr: regexp.MustCompile("expected [\\w]+ to be at least \\(42\\), got 7"),
^
helper/validation/meta_test.go:98:17: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
expectedErr: regexp.MustCompile("expected [\\w]+ to be at most \\(5\\), got 7"),
^
helper/validation/meta_test.go:125:17: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
expectedErr: regexp.MustCompile("expected [\\w]+ to be at least \\(42\\), got 7"),
^
helper/validation/meta_test.go:133:17: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
expectedErr: regexp.MustCompile("expected [\\w]+ to be at most \\(5\\), got 7"),
^
helper/validation/strings_test.go:293:17: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
expectedErr: regexp.MustCompile("expected [\\w]+ to be one of \\[ValidValue AnotherValidValue\\], got VALIDVALUE"),
^
helper/validation/strings_test.go:298:17: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
expectedErr: regexp.MustCompile("expected [\\w]+ to be one of \\[ValidValue AnotherValidValue\\], got InvalidValue"),
^
helper/validation/strings_test.go:303:17: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
expectedErr: regexp.MustCompile("expected type of [\\w]+ to be string"),
^
helper/validation/strings_test.go:322:17: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
expectedErr: regexp.MustCompile("expected [\\w]+ to not be any of \\[InvalidValue AnotherInvalidValue\\], got AnotherInvalidValue"),
^
helper/validation/strings_test.go:328:17: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
expectedErr: regexp.MustCompile("expected [\\w]+ to not be any of \\[InvalidValue AnotherInvalidValue\\], got INVALIDVALUE"),
^
helper/validation/strings_test.go:333:17: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
expectedErr: regexp.MustCompile("expected type of [\\w]+ to be string"),
^
helper/validation/strings_test.go:352:17: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
expectedErr: regexp.MustCompile("invalid value for [\\w]+ \\(value must contain foo\\)"),
^
helper/validation/strings_test.go:371:17: S1007: should use raw string (`...`) with regexp.MustCompile to avoid having to escape twice (gosimple)
expectedErr: regexp.MustCompile("invalid value for [\\w]+ \\(value must not contain foo\\)"),
^
internal/plugin/convert/diagnostics.go:96:10: S1034: assigning the result of this type assertion to a variable (switch step := step.(type)) could eliminate type assertions in switch cases (gosimple)
switch step.(type) {
^
internal/plugin/convert/diagnostics.go:98:25: S1034(related information): could eliminate this type assertion (gosimple)
p = p.GetAttr(string(step.(tftypes.AttributeName)))
^
internal/plugin/convert/diagnostics.go:100:37: S1034(related information): could eliminate this type assertion (gosimple)
p = p.Index(cty.StringVal(string(step.(tftypes.ElementKeyString))))
^
internal/plugin/convert/diagnostics.go:102:39: S1034(related information): could eliminate this type assertion (gosimple)
p = p.Index(cty.NumberIntVal(int64(step.(tftypes.ElementKeyInt))))
^
internal/addrs/module_instance.go:95:4: S1023: redundant break statement (gosimple)
break
^
internal/addrs/module_instance.go:125:4: S1023: redundant break statement (gosimple)
break
^
helper/resource/testing.go:129:14: S1012: should use `time.Since` instead of `time.Now().Sub` (gosimple)
elapsed := time.Now().Sub(start)
^
helper/resource/testing.go:242:13: S1012: should use `time.Since` instead of `time.Now().Sub` (gosimple)
elapsed := time.Now().Sub(start)
^
helper/schema/set.go:241:2: S1032: should use sort.Strings(...) instead of sort.Sort(sort.StringSlice(...)) (gosimple)
sort.Sort(sort.StringSlice(keys))
^
helper/schema/resource.go:847:5: S1002: should omit comparison to bool constant, can be simplified to `!s.Computed` (gosimple)
if s.Computed != true {
^
helper/schema/field_reader_map.go:162:3: S1008: should use 'return len(countActual) < countExpected' instead of 'if len(countActual) >= countExpected { return false }; return true' (gosimple)
if len(countActual) >= countExpected {
^
terraform/state.go:1026:20: S1039: unnecessary use of fmt.Sprintf (gosimple)
buf.WriteString(fmt.Sprintf("\n Dependencies:\n"))
^
terraform/state.go:1240:2: S1008: should use 'return s.Primary.Equal(other.Primary)' instead of 'if !s.Primary.Equal(other.Primary) { return false }; return true' (gosimple)
if !s.Primary.Equal(other.Primary) {
```1 parent 9e15c51 commit 74c4eeb
File tree
12 files changed
+40
-49
lines changed- helper
- resource
- schema
- validation
- internal
- addrs
- plugin/convert
- terraform
12 files changed
+40
-49
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
242 | | - | |
| 242 | + | |
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | 162 | | |
166 | | - | |
| 163 | + | |
167 | 164 | | |
168 | 165 | | |
169 | 166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
844 | 844 | | |
845 | 845 | | |
846 | 846 | | |
847 | | - | |
| 847 | + | |
848 | 848 | | |
849 | 849 | | |
850 | 850 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
241 | | - | |
| 241 | + | |
242 | 242 | | |
243 | 243 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
| 122 | + | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
| 133 | + | |
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
293 | | - | |
| 293 | + | |
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
298 | | - | |
| 298 | + | |
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
303 | | - | |
| 303 | + | |
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
| |||
319 | 319 | | |
320 | 320 | | |
321 | 321 | | |
322 | | - | |
| 322 | + | |
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
326 | 326 | | |
327 | 327 | | |
328 | | - | |
| 328 | + | |
329 | 329 | | |
330 | 330 | | |
331 | 331 | | |
332 | 332 | | |
333 | | - | |
| 333 | + | |
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
347 | | - | |
| 347 | + | |
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
351 | 351 | | |
352 | | - | |
| 352 | + | |
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
| |||
363 | 363 | | |
364 | 364 | | |
365 | 365 | | |
366 | | - | |
| 366 | + | |
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
370 | 370 | | |
371 | | - | |
| 371 | + | |
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
96 | 95 | | |
97 | 96 | | |
98 | 97 | | |
| |||
122 | 121 | | |
123 | 122 | | |
124 | 123 | | |
125 | | - | |
126 | 124 | | |
127 | 125 | | |
128 | 126 | | |
| |||
0 commit comments