elastic / elastic/terraform-provider-elasticstack

[semantic-refactor] Dead deprecated slice-conversion wrappers in synthetics/schema.go duplicate typeutils

Closed Beginner friendly
#4,922 0 comments 0 reactions 0 assignees View on GitHub
automated-analysis code-quality phase-coding refactoring semantic-refactor triaged
Dominant language
Go
Stars
209
Forks
151
Avg merge
23h 11m
Merged PRs (30d)
169

Description

## Summary

`internal/kibana/synthetics/schema.go` still defines `ValueStringSlice` and `StringSliceValue` as deprecated pass-through wrappers around `internal/utils/typeutils`'s functions of the same name. Every caller in the repository has already migrated to calling `typeutils.ValueStringSlice` / `typeutils.StringSliceValue` directly — the wrappers have zero remaining callers and exist purely as dead, deprecated indirection.

## Concrete Evidence

### Opportunity: Dead deprecated wrapper functions duplicating `typeutils` slice converters
- **Severity**: Low
- **Type**: duplicate-function
- **Locations**:
- `internal/kibana/synthetics/schema.go` — `func ValueStringSlice(v []types.String) []string` (lines 61-66), `func StringSliceValue(v []string) []types.String` (lines 68-73)
- `internal/utils/typeutils/tfsdk_lists.go` — canonical implementations `func ValueStringSlice(v []types.String) []string` (lines 32-39), `func StringSliceValue(v []string) []types.String` (lines 41-48)

- **Code Sample**:
```go
// internal/kibana/synthetics/schema.go
// ValueStringSlice converts []types.String to []string.
//
// Deprecated: use typeutils.ValueStringSlice directly.
func ValueStringSlice(v []types.String) []string {
return typeutils.ValueStringSlice(v)
}

// StringSliceValue converts []string to []types.String.
//
// Deprecated: use typeutils.StringSliceValue directly.
func StringSliceValue(v []string) []types.String {
return typeutils.StringSliceValue(v)
}
```

A repo-wide search for `synthetics.ValueStringSlice(` and `synthetics.StringSliceValue(` across `internal/**/*.go` returns **no matches** — every call site in `internal/kibana/synthetics/...` (privatelocation/models.go, parameter/models.go, monitor/schema.go) already calls `typeutils.ValueStringSlice` / `typeutils.StringSliceValue` directly.

## Impact Analysis

- **Maintainability**: The wrappers are unreachable dead code that adds a false impression of an in-progress migration; a future contributor unfamiliar with the history may add a new call site against the deprecated shim instead of the canonical helper, undoing the migration that's already complete.
- **Organization**: `schema.go` in the `synthetics` package should only contain synthetics-specific schema/ID helpers (see `TryReadCompositeID` in the same file); the two wrapper functions are unrelated leftovers from an earlier `typeutils` extraction.
- **Duplication Risk**: None going forward once removed — no behavior depends on the wrapper.

## Refactoring Recommendations

1. **Delete the dead wrappers**
- Target: `internal/kibana/synthetics/schema.go`
- Action: consolidate — delete `ValueStringSlice` and `StringSliceValue` from this file (and drop the now-unused `types` import if nothing else in the file needs it; `TryReadCompositeID` doesn't use `types`).
- Estimated effort: minutes
- Benefits: removes dead code, removes a stale deprecation notice, leaves `typeutils` as the single source of truth.

## Implementation Checklist

- [ ] Review refactoring findings
- [ ] Prioritize refactoring tasks
- [ ] Create refactoring plan
- [ ] Implement changes
- [ ] Update tests as needed
- [ ] Verify no functionality broken

## Analysis Metadata

- **Analyzed Files**: 1467 non-test `.go` files under `internal/` and `provider/`
- **Total Functions Cataloged**: ~5197 top-level func/method declarations
- **Function Clusters Identified**: 162 function names with 2+ declarations
- **Outliers Found**: 1 (this dead-wrapper pair)
- **Duplicates Detected**: 2 functions (exact duplicates, deprecated shim)
- **Detection Method**: Serena semantic code analysis + naming pattern analysis
- **Analysis Date**: 2026-09-13

> [!WARNING]
>
> Firewall blocked 1 domain
>
> The following domain was blocked by the firewall during workflow execution:
>
> - `api.anthropic.com`
>
> To allow these domains, add them to the `network.allowed` list in your workflow frontmatter:
>
> ```yaml
> network:
> allowed:
> - defaults
> - "api.anthropic.com"
> ```
>
> See [Network Configuration](https://github.github.com/gh-aw/reference/network/) for more information.
>
>

> Generated by [Semantic Function Refactor](https://github.com/elastic/terraform-provider-elasticstack/actions/runs/34780414858) · claude · sonnet50 · 266.5 AIC · ⌖ 42.5 AIC · ⊞ 11.2K · [◷](https://github.com/search?q=repo%3Aelastic%2Fterraform-provider-elasticstack+is%3Aissue+%22gh-aw-workflow-call-id%3A+elastic%2Fterraform-provider-elasticstack%2Fsemantic-function-refactor%22&type=issues)

Contributor guide

No contributing guide indexed for this repository

Research direction

Read internal/kibana/synthetics/schema.go and compare its two slice-conversion wrappers with the canonical implementations in internal/utils/typeutils/tfsdk_lists.go. Remove the unused wrappers and the types import if no longer needed, then verify that repository callers still use typeutils.ValueStringSlice and typeutils.StringSliceValue and that the package builds successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Refactor
Difficulty
1/5
Estimated time
Under an hour
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
90/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.