Skip to content

[dead-code] chore: remove dead functions — 4 functions removed#24288

Merged
pelikhan merged 1 commit intomainfrom
dead-code/remove-effective-token-funcs-20260403-eff714a77d51ab7f
Apr 3, 2026
Merged

[dead-code] chore: remove dead functions — 4 functions removed#24288
pelikhan merged 1 commit intomainfrom
dead-code/remove-effective-token-funcs-20260403-eff714a77d51ab7f

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 3, 2026

Dead Code Removal

This PR removes unreachable Go functions identified by the deadcode static analyzer.

Functions Removed

Function File
effectiveTokenMultiplier pkg/cli/effective_tokens.go
computeBaseWeightedTokens pkg/cli/effective_tokens.go
computeModelEffectiveTokens pkg/cli/effective_tokens.go
populateEffectiveTokens pkg/cli/effective_tokens.go

These four functions were superseded by computeModelEffectiveTokensWithWeights and populateEffectiveTokensWithCustomWeights, which are the live implementations called from production code (token_usage.go). The simpler wrappers were never called outside of tests.

Tests Removed

Test Function File
TestEffectiveTokenMultiplierExactMatch pkg/cli/effective_tokens_test.go
TestEffectiveTokenMultiplierCaseInsensitive pkg/cli/effective_tokens_test.go
TestEffectiveTokenMultiplierPrefixMatch pkg/cli/effective_tokens_test.go
TestEffectiveTokenMultiplierUnknownModel pkg/cli/effective_tokens_test.go
TestComputeBaseWeightedTokens pkg/cli/effective_tokens_test.go
TestComputeModelEffectiveTokens pkg/cli/effective_tokens_test.go
TestPopulateEffectiveTokens pkg/cli/effective_tokens_test.go
TestPopulateEffectiveTokensNilSummary pkg/cli/effective_tokens_test.go

Verification

  • go build ./... — passes
  • go vet ./... — passes
  • go vet -tags=integration ./... — passes
  • make fmt — no changes needed

Dead Function Count

  • Before this batch: 15 functions
  • Removed in this PR: 4 functions
  • Remaining: ~11 functions (several skipped: WASM-live functions, and functions used in too many test files to batch-refactor)

Automated by Dead Code Removal workflow — https://github.com/github/gh-aw/actions/runs/23945333342

Generated by Dead Code Removal Agent · ● 1.9M ·

  • expires on Apr 6, 2026, 12:07 PM UTC


✨ PR Review Safe Output Test - Run 23946149750

💥 [THE END] — Illustrated by Smoke Claude · ● 236K ·

Remove 4 unreachable functions identified by deadcode analyzer:
- effectiveTokenMultiplier
- computeBaseWeightedTokens
- computeModelEffectiveTokens
- populateEffectiveTokens

These functions were superseded by computeModelEffectiveTokensWithWeights
and populateEffectiveTokensWithCustomWeights, which are the live
implementations called from production code (token_usage.go).

Also remove 8 exclusive test functions that only tested the deleted code.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💥 Automated smoke test review - all systems nominal!

💥 [THE END] — Illustrated by Smoke Claude · ● 236K

// - Embedding model_multipliers.json at compile time
// - Applying token class weights before the model multiplier
// - Providing model multiplier lookup with prefix matching for model variants
// - Computing effective tokens from raw per-model token usage data
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good cleanup — removing the Providing model multiplier lookup with prefix matching comment accurately reflects that the dead functions are gone. The comment now matches the live code.

})
}

func TestModelMultipliersJSONEmbedded(t *testing.T) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test coverage removal looks correct — these tests were covering effectiveTokenMultiplier, computeBaseWeightedTokens, computeModelEffectiveTokens, and populateEffectiveTokens which are all dead functions. The live implementations (computeModelEffectiveTokensWithWeights) are still tested.

@pelikhan pelikhan marked this pull request as ready for review April 3, 2026 13:25
Copilot AI review requested due to automatic review settings April 3, 2026 13:25
@pelikhan pelikhan merged commit d1c36a2 into main Apr 3, 2026
51 checks passed
@pelikhan pelikhan deleted the dead-code/remove-effective-token-funcs-20260403-eff714a77d51ab7f branch April 3, 2026 13:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes dead/unreachable Effective Tokens helper functions and their now-obsolete unit tests after the codebase migrated to the weighted implementations used by token_usage.go.

Changes:

  • Deleted 4 unused ET helper functions from pkg/cli/effective_tokens.go.
  • Removed the unit tests that exercised the deleted helpers from pkg/cli/effective_tokens_test.go.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pkg/cli/effective_tokens.go Removes unused ET helper functions; leaves weighted ET computation as the only path.
pkg/cli/effective_tokens_test.go Deletes tests tied to removed helpers; retains tests for embedded JSON parsing and custom-weight merging.
Comments suppressed due to low confidence (2)

pkg/cli/effective_tokens.go:129

  • populateEffectiveTokensWithCustomWeights is documented as "like populateEffectiveTokens", but populateEffectiveTokens was removed in this PR. Please reword this doc comment to be self-contained (e.g., describe that it populates EffectiveTokens/TotalEffectiveTokens and optionally merges custom weights) so readers don't have to hunt for a non-existent symbol.
// populateEffectiveTokensWithCustomWeights is like populateEffectiveTokens but
// merges custom into the built-in weights before computing effective tokens.
// Custom weights take precedence over the defaults loaded from model_multipliers.json.
// It is a no-op when summary is nil.

pkg/cli/effective_tokens_test.go:19

  • This PR removes the direct tests for model multiplier lookup semantics (case-insensitive exact match, longest-prefix match for model variants, and unknown-model default). That behavior still exists in computeModelEffectiveTokensWithWeights, but is no longer covered explicitly. Please add focused tests for these lookup rules to avoid regressions in effective token computation.
func TestModelMultipliersJSONEmbedded(t *testing.T) {
	// Verify the embedded JSON parses without error
	loadedMultipliers = nil
	initMultipliers()
	require.NotNil(t, loadedMultipliers, "multipliers should be loaded from embedded JSON")
	assert.NotEmpty(t, loadedMultipliers, "should have at least one multiplier entry")
}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -23,7 +23,6 @@ package cli
// Key responsibilities:
// - Embedding model_multipliers.json at compile time
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file-level "Key responsibilities" comment no longer mentions the model multiplier lookup behavior, but computeModelEffectiveTokensWithWeights still performs case-insensitive exact matching and longest-prefix matching for model variants. Please update this header comment (or add a brief note near the lookup implementation) so the documented responsibilities stay aligned with the current behavior.

This issue also appears on line 126 of the same file.

Suggested change
// - Embedding model_multipliers.json at compile time
// - Embedding model_multipliers.json at compile time
// - Resolving model multipliers using case-insensitive exact matching and
// longest-prefix matching for model variants

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants