Commit 0b71b4a
Remove unused factory pattern code from sampling strategy packages (#7705)
- [x] Verify that flagged functions are unused outside tests
- [x] Remove unused functions from adaptive/factory.go (entire file
deleted)
- [x] Remove unused functions from adaptive/options.go (AddFlags,
InitFromViper)
- [x] Remove unused functions from
adaptive/calculationstrategy/interface.go (CalculateFunc type)
- [x] Remove unused functions from file/factory.go (entire file deleted)
- [x] Remove unused functions from file/options.go (AddFlags,
InitFromViper)
- [x] Remove unused functions from file/provider.go (deepCopy)
- [x] Remove unused functions from metafactory/factory.go (entire
directory deleted)
- [x] Remove unused functions from metafactory/factory_config.go (entire
directory deleted)
- [x] Clean up unused imports after deletions
- [x] Remove metafactory references from cmd/internal/env/command.go
- [x] Remove test files that only tested deleted functions
- [x] Update remaining tests to not use deleted functions
- [x] Fix formatting issues
- [x] Remove unused defaultResourceName constant
- [x] Remove viper imports and constants no longer needed
- [x] Inline default constants into DefaultOptions()
- [x] Add unit test for DefaultOptions()
- [x] Build all binaries successfully (jaeger, remote-storage, and
others)
- [x] Run all tests successfully (sampling strategy, extension,
processor tests pass)
- [x] Lint passes with 0 issues
## Summary
Successfully removed all 25 unused functions flagged by the deadcode
detector plus additional cleanup:
- Deleted entire factory.go files from adaptive, file, and metafactory
packages
- Removed AddFlags and InitFromViper functions from options.go files
- Removed deepCopy function from file/provider.go
- Removed CalculateFunc type from interface.go
- Updated tests to use documented mock implementations
- Removed metafactory references from cmd/internal/env/command.go
- Removed viper imports and viper key constants that were only used by
deleted functions
- Inlined default constants directly into DefaultOptions() to reduce
mental overhead
- Added unit test for DefaultOptions() to provide test coverage
- All binaries build successfully
- All tests pass
- Linter passes with 0 issues
<!-- START COPILOT CODING AGENT SUFFIX -->
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
> Deadcode detector tool flags the following functions as unused. Verify
that they are indeed not used outside of their internal unit tests and
delete them. Make sure all binaries build via `make build-binaries` and
all tests pass via `make tests`.
>
> ```
> internal/sampling/samplingstrategy/adaptive/factory.go:37:6:
unreachable func: NewFactory
> internal/sampling/samplingstrategy/adaptive/factory.go:47:17:
unreachable func: Factory.AddFlags
> internal/sampling/samplingstrategy/adaptive/factory.go:52:19:
unreachable func: Factory.InitFromViper
> internal/sampling/samplingstrategy/adaptive/factory.go:57:19:
unreachable func: Factory.Initialize
> internal/sampling/samplingstrategy/adaptive/factory.go:83:19:
unreachable func: Factory.CreateStrategyProvider
> internal/sampling/samplingstrategy/adaptive/factory.go:97:19:
unreachable func: Factory.Close
> internal/sampling/samplingstrategy/adaptive/options.go:122:6:
unreachable func: AddFlags
>
internal/sampling/samplingstrategy/adaptive/calculationstrategy/interface.go:15:24:
unreachable func: CalculateFunc.Calculate
> internal/sampling/samplingstrategy/file/factory.go:26:6: unreachable
func: NewFactory
> internal/sampling/samplingstrategy/file/factory.go:34:17: unreachable
func: Factory.AddFlags
> internal/sampling/samplingstrategy/file/factory.go:39:19: unreachable
func: Factory.InitFromViper
> internal/sampling/samplingstrategy/file/factory.go:44:19: unreachable
func: Factory.Initialize
> internal/sampling/samplingstrategy/file/factory.go:50:19: unreachable
func: Factory.CreateStrategyProvider
> internal/sampling/samplingstrategy/file/factory.go:60:17: unreachable
func: Factory.Close
> internal/sampling/samplingstrategy/file/options.go:31:6: unreachable
func: AddFlags
> internal/sampling/samplingstrategy/file/provider.go:324:6: unreachable
func: deepCopy
> internal/sampling/samplingstrategy/metafactory/factory.go:45:6:
unreachable func: NewFactory
> internal/sampling/samplingstrategy/metafactory/factory.go:61:17:
unreachable func: Factory.getFactoryOfType
> internal/sampling/samplingstrategy/metafactory/factory.go:73:19:
unreachable func: Factory.AddFlags
> internal/sampling/samplingstrategy/metafactory/factory.go:82:19:
unreachable func: Factory.InitFromViper
> internal/sampling/samplingstrategy/metafactory/factory.go:91:19:
unreachable func: Factory.Initialize
> internal/sampling/samplingstrategy/metafactory/factory.go:101:19:
unreachable func: Factory.CreateStrategyProvider
> internal/sampling/samplingstrategy/metafactory/factory.go:110:19:
unreachable func: Factory.Close
> internal/sampling/samplingstrategy/metafactory/factory_config.go:24:6:
unreachable func: FactoryConfigFromEnv
> internal/sampling/samplingstrategy/metafactory/factory_config.go:36:6:
unreachable func: getStrategyStoreTypeFromEnv
> ```
</details>
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 We'd love your input! Share your thoughts on Copilot coding agent in
our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: yurishkuro <[email protected]>
Co-authored-by: Yuri Shkuro <[email protected]>1 parent cb37388 commit 0b71b4a
File tree
20 files changed
+36
-997
lines changed- cmd/internal/env
- internal/sampling/samplingstrategy
- adaptive
- calculationstrategy
- file
- metafactory
20 files changed
+36
-997
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
| |||
33 | 32 | | |
34 | 33 | | |
35 | 34 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | 35 | | |
46 | 36 | | |
47 | 37 | | |
| |||
65 | 55 | | |
66 | 56 | | |
67 | 57 | | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | 58 | | |
86 | 59 | | |
87 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | | - | |
161 | | - | |
162 | 160 | | |
163 | 161 | | |
164 | 162 | | |
| |||
171 | 169 | | |
172 | 170 | | |
173 | 171 | | |
174 | | - | |
175 | 172 | | |
176 | 173 | | |
177 | 174 | | |
| |||
182 | 179 | | |
183 | 180 | | |
184 | 181 | | |
185 | | - | |
186 | 182 | | |
187 | 183 | | |
188 | 184 | | |
| |||
204 | 200 | | |
205 | 201 | | |
206 | 202 | | |
207 | | - | |
208 | 203 | | |
209 | 204 | | |
210 | 205 | | |
211 | 206 | | |
212 | | - | |
213 | 207 | | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | 208 | | |
218 | 209 | | |
219 | 210 | | |
| |||
229 | 220 | | |
230 | 221 | | |
231 | 222 | | |
232 | | - | |
233 | 223 | | |
234 | 224 | | |
235 | | - | |
236 | 225 | | |
237 | 226 | | |
238 | 227 | | |
239 | 228 | | |
240 | | - | |
241 | 229 | | |
242 | 230 | | |
243 | 231 | | |
| |||
251 | 239 | | |
252 | 240 | | |
253 | 241 | | |
254 | | - | |
255 | 242 | | |
256 | 243 | | |
257 | 244 | | |
| |||
270 | 257 | | |
271 | 258 | | |
272 | 259 | | |
273 | | - | |
274 | 260 | | |
275 | 261 | | |
276 | 262 | | |
277 | | - | |
278 | 263 | | |
279 | | - | |
280 | | - | |
281 | 264 | | |
282 | 265 | | |
283 | 266 | | |
| |||
292 | 275 | | |
293 | 276 | | |
294 | 277 | | |
295 | | - | |
296 | 278 | | |
297 | 279 | | |
298 | 280 | | |
299 | | - | |
300 | 281 | | |
301 | 282 | | |
302 | 283 | | |
303 | 284 | | |
304 | 285 | | |
305 | 286 | | |
306 | 287 | | |
307 | | - | |
308 | 288 | | |
309 | 289 | | |
310 | | - | |
311 | 290 | | |
312 | 291 | | |
313 | 292 | | |
| |||
339 | 318 | | |
340 | 319 | | |
341 | 320 | | |
342 | | - | |
343 | 321 | | |
344 | 322 | | |
345 | 323 | | |
| |||
357 | 335 | | |
358 | 336 | | |
359 | 337 | | |
360 | | - | |
361 | 338 | | |
362 | 339 | | |
363 | 340 | | |
364 | | - | |
365 | 341 | | |
366 | | - | |
367 | 342 | | |
368 | | - | |
369 | 343 | | |
370 | 344 | | |
371 | 345 | | |
372 | 346 | | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | 347 | | |
Lines changed: 0 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
Lines changed: 0 additions & 18 deletions
This file was deleted.
This file was deleted.
0 commit comments