Skip to content

[dead-code] chore: remove dead functions — 5 functions removed#38640

Merged
pelikhan merged 3 commits into
mainfrom
dead-code-removal-20260611-152801-719570c5be4b673a
Jun 11, 2026
Merged

[dead-code] chore: remove dead functions — 5 functions removed#38640
pelikhan merged 3 commits into
mainfrom
dead-code-removal-20260611-152801-719570c5be4b673a

Conversation

@github-actions

@github-actions github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

test

Generated by PR Description Updater for issue #38640 · 464.8 AIC · ⌖ 22.7 AIC · ⊞ 19.8K ·

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review June 11, 2026 15:52
Copilot AI review requested due to automatic review settings June 11, 2026 15:52
@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #38640 does not have the 'implementation' label and has only 1 new line of code in business logic directories (≤100 threshold).

@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

PR Code Quality Reviewer completed the code quality review.

@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

🧪 Test Quality Sentinel completed test quality analysis.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Removes several unused helper functions and their now-obsolete tests across the CLI, parser, and workflow compiler environment code, reducing surface area and maintenance overhead.

Changes:

  • Deleted dead env-resolution helper ResolveDefaultMaxDailyAICredits and its unit test.
  • Removed unused nested-import parsing helpers and a lenient-parsing test that was exclusive to them.
  • Removed the unused domain “insight” analysis API and the unused setNonInteractiveCIEnv wrapper + corresponding tests/imports.
Show a summary per file
File Description
pkg/workflow/compilerenv/manager.go Removes the daily-credits resolver function from compilerenv.
pkg/workflow/compilerenv/manager_test.go Deletes tests that only covered the removed daily-credits resolver.
pkg/parser/import_bfs.go Removes unused nested import entry parsing helpers.
pkg/parser/import_bfs_test.go Removes a unit test that only covered the deleted lenient parsing helpers.
pkg/cli/outcome_domain_breakdown.go Removes unused DomainInsight / AnalyzeDomainPerformance API and cleans imports.
pkg/cli/mcp_validation_test.go Renames/reduces tests after removing the cmd-env wrapper; keeps coverage for env-copy helper (but currently misses a key case).
pkg/cli/mcp_helpers.go Removes unused exec-based wrapper and its import; keeps env helper.

Copilot's findings

Tip

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

Comments suppressed due to low confidence (2)

pkg/cli/mcp_validation_test.go:67

  • The renamed TestWithNonInteractiveCIEnv now only covers the case where CI is already present (and overridden). The removed sub-test for “adds CI when missing” still applies to withNonInteractiveCIEnv and should be retained to keep coverage for that behavior.
func TestWithNonInteractiveCIEnv(t *testing.T) {
	t.Run("returns copied env with CI forced on", func(t *testing.T) {
		input := []string{"CI=false", "HOME=/tmp/test-home"}

		output := withNonInteractiveCIEnv(input)

pkg/workflow/compilerenv/manager.go:53

  • ResolveDefaultMaxDailyAICredits is removed here, but pkg/workflow/compilerenv/spec_test.go still states that ResolveDefaultMaxDailyAICredits is “retained” (around lines 64–69). That comment will be incorrect after this PR; please update the spec test commentary to match the current API surface.
// ResolveDefaultMaxAICredits returns the resolved max AI credits default, checking
// the enterprise env var GH_AW_DEFAULT_MAX_AI_CREDITS.
// Falls back to fallback (built-in default) when the env var is unset or invalid.
//
// A value of -1 is preserved and signals that budget enforcement and token
  • Files reviewed: 7/7 changed files
  • Comments generated: 1

Comment on lines 106 to 110
func countTotalAttempted(breakdowns []DomainBreakdown) int {
total := 0
for _, d := range breakdowns {
total += d.Attempted
}
@github-actions github-actions Bot mentioned this pull request Jun 11, 2026

@github-actions github-actions Bot left a comment

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.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • proxy.golang.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "proxy.golang.org"

See Network Configuration for more information.

🔎 Code quality review by PR Code Quality Reviewer · ⌖ 13.1 AIC

assert.NotContains(t, cmd.Env, "CI=false")
assert.Contains(t, cmd.Env, "HOME=/tmp/test-home")
})
}

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 regression: the withNonInteractiveCIEnv append-fallback path (return append(env, "CI=1")) is no longer exercised by any test case.

💡 Why this matters / suggested fix

Before this PR, setNonInteractiveCIEnv wrapped withNonInteractiveCIEnv, and its now-deleted "adds CI when missing" sub-test indirectly covered the branch in withNonInteractiveCIEnv that appends CI=1 when no CI= entry is present in the slice.

The remaining sub-test only covers the replacement branch (input already contains CI=false). After this removal, the append(env, "CI=1") line in withNonInteractiveCIEnv has no direct test.

Consider adding a sub-test to maintain coverage:

t.Run("adds CI when missing", func(t *testing.T) {
    input := []string{"HOME=/tmp/test-home"}

    output := withNonInteractiveCIEnv(input)

    assert.Equal(t, []string{"HOME=/tmp/test-home"}, input, "must not mutate input")
    assert.Contains(t, output, "CI=1")
    assert.Contains(t, output, "HOME=/tmp/test-home")
})

@github-actions github-actions Bot left a comment

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.

Skills-Based Review 🧠

Applied /zoom-out and /improve-codebase-architecture — approving with one minor follow-up note.

📋 Key Themes & Highlights

Key Themes

  • Clean deletions across the board: all 5 removed functions (setNonInteractiveCIEnv, AnalyzeDomainPerformance+DomainInsight, parseNestedImportEntries, parseNestedImportEntry, ResolveDefaultMaxDailyAICredits) have zero callers in the repo — confirmed by exhaustive grep.
  • Stale spec comment: spec_test.go lines 67–68 still reference ResolveDefaultMaxDailyAICredits as "retained"; see inline comment on manager.go.

Positive Highlights

  • ✅ Test rename (TestSetNonInteractiveCIEnvTestWithNonInteractiveCIEnv) correctly tracks the surviving function
  • ✅ Exported symbols (AnalyzeDomainPerformance, DomainInsight) verified dead before deletion — higher-risk removals handled well
  • ✅ Companion test files pruned in lockstep — no orphaned test coverage
  • ✅ Build and vet gates passed per PR description

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 291.3 AIC · ⌖ 13.5 AIC

return fallback
}

// ResolveDefaultMaxAICredits returns the resolved max AI credits default, checking

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.

[/zoom-out] Stale spec comment in a companion file needs a follow-up cleanup.

spec_test.go line 67–68 (unchanged in this PR) still reads:

"ResolveDefaultMaxDailyAICredits is retained for other compile-time uses but MUST NOT be called for the daily guardrail default path."

Now that ResolveDefaultMaxDailyAICredits has been deleted, that sentence provides incorrect guidance to the next reader. Consider patching the spec_test.go comment in a follow-up (or squashing it into this PR) to say the function has been removed and BuildDefaultMaxDailyAICreditsExpression is the only conforming API.

💡 Suggested comment update in spec_test.go
// TestSpec_DailyAICreditsGuardrail_RuntimeNotCompileTime validates AIC spec §9.3 (2):
// GH_AW_DEFAULT_MAX_DAILY_AI_CREDITS MUST be resolved at action runtime, not at
// compiler process environment lookup. BuildDefaultMaxDailyAICreditsExpression is
// the sole conforming API for this path; the compile-time resolver
// ResolveDefaultMaxDailyAICredits has been removed as dead code.
//
// T-AIC-DG-006: The compiler produces an expression, not a pre-resolved value.

@github-actions

Copy link
Copy Markdown
Contributor Author

🧪 Test Quality Sentinel Report

⚠️ Test Quality Score: 70/100 — Acceptable

Analyzed 1 modified test across 3 changed test files (all other changes are appropriate deletions of dead-code tests). The 1 modified test is a rename-only change (design test, no guideline violations).

📊 Metrics & Test Classification (1 test analyzed)
Metric Value
New/modified tests analyzed 1
✅ Design tests (behavioral contracts) 1 (100%)
⚠️ Implementation tests (low value) 0 (0%)
Tests with error/edge cases 0 (0%)
Duplicate test clusters 0
Test inflation detected No
🚨 Coding-guideline violations 0

Test Classification Details

Test File Classification Issues Detected
TestWithNonInteractiveCIEnv pkg/cli/mcp_validation_test.go:63 ✅ Design Single test case; no edge-case inputs (empty/nil slice); assertions lack descriptive message args (pre-existing)

Deleted Tests (Dead-Code Cleanup — Appropriate)

These tests were correctly removed because the production functions they covered were deleted as dead code:

Deleted Test File Reason
TestSetNonInteractiveCIEnv/adds_CI_when_missing mcp_validation_test.go Tested deleted setNonInteractiveCIEnv
TestSetNonInteractiveCIEnv/overrides_existing_CI_value mcp_validation_test.go Tested deleted setNonInteractiveCIEnv
TestParseNestedImportEntries_LenientArrayParsing import_bfs_test.go Tested deleted parseNestedImportEntries
TestResolveDefaultMaxDailyAICredits (6 subtests) manager_test.go Tested deleted ResolveDefaultMaxDailyAICredits

Language Support

Tests analyzed:

  • 🐹 Go (*_test.go): 1 modified test — unit (//go:build !integration)
  • 🟨 JavaScript (*.test.cjs, *.test.js): 0 tests changed
⚠️ Flagged Tests — Review Suggested (1 issue)

⚠️ TestWithNonInteractiveCIEnv (pkg/cli/mcp_validation_test.go:63)

Classification: Design test (behavioral contract) — rename-only change; body unchanged from before this PR

What design invariant does this test enforce? withNonInteractiveCIEnv must: force CI=1 in the output, remove an existing CI=false entry, preserve unrelated env vars, and not mutate the input slice. The test verifies all four contracts.

What would break if deleted? A behavioral regression in env manipulation (e.g., forgetting to strip the old CI value or mutating the input) would go undetected.

Note: The assertions lack descriptive message arguments (e.g., assert.Contains(t, output, "CI=1") should be assert.Contains(t, output, "CI=1", "output must override CI to 1")). This pre-existed the PR; the PR only renamed the function to align with withNonInteractiveCIEnv. Edge cases such as an empty input slice or an input with no existing CI entry are also missing.

Suggested improvement (low priority — pre-existing): Add descriptive message strings to each assertion and a second sub-case for an input that has no CI entry at all, to ensure CI=1 is still appended.

Verdict

Check passed. 0% of modified tests are implementation tests (threshold: 30%). This PR is a clean dead-code removal — 5 functions deleted along with their corresponding tests. The single modified test (TestWithNonInteractiveCIEnv) is a rename that aligns the test name with the production function it covers; its behavioral coverage is intact.

📖 Understanding Test Classifications

Design Tests (High Value) verify what the system does:

  • Assert on observable outputs, return values, or state changes
  • Cover error paths and boundary conditions
  • Would catch a behavioral regression if deleted
  • Remain valid even after internal refactoring

Implementation Tests (Low Value) verify how the system does it:

  • Assert on internal function calls (mocking internals)
  • Only test the happy path with typical inputs
  • Break during legitimate refactoring even when behavior is correct
  • Give false assurance: they pass even when the system is wrong

Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators.

References: §27359625411

🧪 Test quality analysis by Test Quality Sentinel · 323.9 AIC · ⌖ 28.5 AIC ·

@github-actions github-actions Bot left a comment

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 Quality Sentinel: 70/100. Test quality is acceptable — 0% of modified tests are implementation tests (threshold: 30%). This is a clean dead-code removal; the single modified test (TestWithNonInteractiveCIEnv) is a rename aligning the test name with its production function.

@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

…nd spec

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

@copilot run pr-finisher skill

Addressed all three unresolved review threads in commit fix: address review feedback — add missing test, fix stale comments and spec:

  1. Test coverage gap (mcp_validation_test.go): Added the "adds CI when missing" sub-test to TestWithNonInteractiveCIEnv to cover the append(env, "CI=1") branch.
  2. Stale spec comment (compilerenv/spec_test.go): Updated the comment on TestSpec_DailyAICreditsGuardrail_RuntimeNotCompileTime to reflect that ResolveDefaultMaxDailyAICredits has been removed, not retained.
  3. Stale spec doc (specs/objective-mapping-portfolio-reporting.md): Removed the AnalyzeDomainPerformance() Go API excerpt since the function was deleted in this PR.

Copilot AI requested a review from pelikhan June 11, 2026 16:23
@pelikhan pelikhan merged commit 74c2cbf into main Jun 11, 2026
17 checks passed
@pelikhan pelikhan deleted the dead-code-removal-20260611-152801-719570c5be4b673a branch June 11, 2026 17:52
@github-actions

Copy link
Copy Markdown
Contributor Author

@copilot review all comments and address unresolved review feedback, then summarize any remaining blockers and refresh the branch if needed.

Generated by 👨‍🍳 PR Sous Chef · 43.4 AIC · ⌖ 0.936 AIC · ⊞ 17.3K ·

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.

3 participants