Commit 3a070ff
refactor(utils): drop dead helpers and hand-rolled SliceContainsString (#2608)
* refactor(utils): drop dead helpers and hand-rolled SliceContainsString
Begin dismantling the pkg/utils dumping ground.
- Replace hand-rolled SliceContainsString / SliceContainsStringHasPrefix /
SliceContainsStringStartsWith with stdlib slices.Contains / slices.ContainsFunc
across ~39 call sites; remove the helpers (slices.Contains is the identical
O(n) scan, and the hot path in yaml_utils.go already uses a map).
- Delete nine dead exported functions (zero callers anywhere): ExtractAtmosConfig,
GetGitHubRepoReleases, GetGitHubReleaseByTag, GetGitHubLatestRelease, PrintAsHcl,
NewHighlightWriter (+ HighlightWriter type/method), GetAtmosConfigJSON,
PrintAsJSONToFileDescriptor, PrintAsYAMLWithConfig; remove the now-empty
config_utils.go and cascaded-unused imports/aliases.
- Convert two depends_on dynamic errors in stack_utils.go to wrapped static
errors (ErrDependencyResolution) — required to keep the lint gate green after
restructuring a flagged if/else chain into early returns.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* refactor: remove dead code across pkg/utils and the wider repo
Continue dismantling the pkg/utils dumping ground and extend the sweep
repo-wide, driven by `go run golang.org/x/tools/cmd/deadcode@latest -test ./...`
(authoritative for reachability; -test keeps test-only-used funcs out of the
dead set) and cross-checked with the compiler.
pkg/utils (~35 funcs + their tests):
- array_cleanup, cty_utils, jsonpath, file_utils, json_utils, log_utils,
map_utils, slice_utils, string_utils (intern wrappers), yaml_utils
(cache-clear/print + GetUserHomeDir/ObfuscateSensitivePaths); delete
type_utils.go and json_test.go. Slim the write-only YAML cache-stats to the
hits/misses counters a live test actually reads.
- Keep Intern, MatchWildcard, HasYAMLPosition, HasAppendTag, IsSocket and the
unexported clearParsedYAMLCache - they back tests of live code or have live
callers elsewhere.
Repo-wide (~53 funcs + tests): internal/exec command-registry orphans
(ExecuteHelmfileCmd, ExecuteTerraformGenerate*Cmd, vendor URI helpers, ...),
the errors sentry-shutdown cluster, pkg/auth test_helpers + superseded kube
map-equal helpers, pkg/provenance/tree_renderer, and assorted dead funcs in
cmd, pkg/aws, pkg/logger, pkg/perf, pkg/telemetry, pkg/ui/theme, pkg/stack,
pkg/runner/step, pkg/list/flags, pkg/toolchain/installer, tests/preconditions.
Deliberately kept (deadcode still lists them): interface-conformance methods,
Go Example_* docs, and recently-merged feature scaffolding (Atmos Git
DefaultWorkdir/WithStderr, CI constructors, etc.).
Verified: go build ./..., go vet ./..., changed-package tests, and the
custom-gcl PR lint gate (--new-from-rev=origin/main) all green; deadcode -test
reduced from 82 to 28 (the kept set above).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* test(exec): cover BuildDependentStackNameFromDependsOn{,Legacy}
Add table-driven unit tests for the two depends-on resolution functions in
internal/exec/stack_utils.go. They have a real production caller
(pkg/spacelift/spacelift_stack_processor.go) but no unit test, so the refactor
that rewrote them (early returns + wrapped ErrDependencyResolution) showed up as
the bulk of the PR's uncovered patch lines.
Each test covers all branches: resolves-to-stack, resolves-to-component (Legacy
only), and the not-found error path (asserted via errors.Is on
ErrDependencyResolution). No production code changes.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* test: cover refactor-touched lines to lift patch coverage past 80%
Add focused unit tests for three pure functions whose refactor-modified lines
(u.SliceContainsString → slices.Contains swaps and a gofumpt reformat) were the
remaining uncovered patch lines:
- internal/exec: handleDeploySubcommand — all deploy/apply/auto-approve branches.
- internal/exec: validateTagsAndComponents — component present/absent, tag
match/no-match, duplicate components (errors asserted via errors.Is).
- pkg/provenance: formatProvenanceCommentWithStackFile — nil, no-color, and the
previously-uncovered color path (computed entry, depth 3).
These exercise real, live code paths (no production changes) and cover the
mechanical refactor lines that integration tests hit but Go coverage didn't see.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* test(exec): cover apply+ApplyAutoApprove+UseTerraformPlan guard
Address CodeRabbit review (PR #2608): add the missing TestHandleDeploySubcommand
case for apply with ApplyAutoApprove=true AND UseTerraformPlan=true, which
exercises the `!info.UseTerraformPlan` guard so the second if-block's condition
is fully covered (no auto-approve is added when a plan is in use).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Andriy Knysh <aknysh@users.noreply.github.com>1 parent aec29bd commit 3a070ff
72 files changed
Lines changed: 247 additions & 3712 deletions
File tree
- cmd
- devcontainer
- internal
- errors
- internal/exec
- pkg
- auth
- cloud/kube
- aws
- identity
- ci/plugins/terraform
- list/flags
- logger
- perf
- provenance
- runner/step
- stack
- telemetry
- terraform/generate
- toolchain/installer
- ui/theme
- utils
- tests
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | 22 | | |
33 | 23 | | |
34 | 24 | | |
| |||
58 | 48 | | |
59 | 49 | | |
60 | 50 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | 51 | | |
70 | 52 | | |
71 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | 123 | | |
143 | 124 | | |
144 | 125 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | 26 | | |
36 | 27 | | |
37 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | 72 | | |
95 | 73 | | |
96 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
54 | 53 | | |
55 | 54 | | |
56 | 55 | | |
57 | 56 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | 57 | | |
68 | 58 | | |
69 | 59 | | |
| |||
154 | 144 | | |
155 | 145 | | |
156 | 146 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | 23 | | |
35 | 24 | | |
36 | 25 | | |
| |||
138 | 127 | | |
139 | 128 | | |
140 | 129 | | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | 130 | | |
156 | 131 | | |
157 | 132 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
292 | 293 | | |
293 | 294 | | |
294 | 295 | | |
295 | | - | |
296 | | - | |
| 296 | + | |
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
| |||
418 | 418 | | |
419 | 419 | | |
420 | 420 | | |
421 | | - | |
| 421 | + | |
422 | 422 | | |
423 | 423 | | |
424 | | - | |
| 424 | + | |
425 | 425 | | |
426 | 426 | | |
427 | 427 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
74 | | - | |
| 75 | + | |
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
359 | 360 | | |
360 | 361 | | |
361 | 362 | | |
362 | | - | |
| 363 | + | |
363 | 364 | | |
364 | 365 | | |
365 | 366 | | |
366 | | - | |
| 367 | + | |
367 | 368 | | |
368 | 369 | | |
369 | 370 | | |
370 | | - | |
| 371 | + | |
371 | 372 | | |
372 | 373 | | |
373 | 374 | | |
| |||
452 | 453 | | |
453 | 454 | | |
454 | 455 | | |
455 | | - | |
| 456 | + | |
456 | 457 | | |
457 | 458 | | |
458 | 459 | | |
459 | | - | |
| 460 | + | |
460 | 461 | | |
461 | 462 | | |
462 | 463 | | |
463 | | - | |
| 464 | + | |
464 | 465 | | |
465 | 466 | | |
466 | 467 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
232 | 233 | | |
233 | 234 | | |
234 | 235 | | |
235 | | - | |
| 236 | + | |
236 | 237 | | |
237 | 238 | | |
238 | 239 | | |
| |||
351 | 352 | | |
352 | 353 | | |
353 | 354 | | |
354 | | - | |
355 | | - | |
| 355 | + | |
| 356 | + | |
356 | 357 | | |
357 | 358 | | |
358 | 359 | | |
| |||
647 | 648 | | |
648 | 649 | | |
649 | 650 | | |
650 | | - | |
| 651 | + | |
651 | 652 | | |
652 | 653 | | |
653 | 654 | | |
| |||
0 commit comments