Skip to content

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

Merged
pelikhan merged 1 commit into
mainfrom
chore/remove-dead-functions-2026-06-26-ec876ab64c256a14
Jun 26, 2026
Merged

[dead-code] chore: remove dead functions — 5 functions removed#41731
pelikhan merged 1 commit into
mainfrom
chore/remove-dead-functions-2026-06-26-ec876ab64c256a14

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Functions Removed

Function File
permissionLevelRank pkg/workflow/call_workflow_permissions.go
findUncoveredWorkerPermissions pkg/workflow/call_workflow_permissions.go
extractCallWorkflowPermissions pkg/workflow/call_workflow_permissions.go
hasNonAllowedExpressionInRunContent pkg/workflow/template_injection_validation.go
hasExpressionInRunContent pkg/workflow/template_injection_validation.go

Tests Removed

  • TestFindUncoveredWorkerPermissions
  • TestExtractCallWorkflowPermissions_FromLockYML
  • TestExtractCallWorkflowPermissions_FromYML
  • TestExtractCallWorkflowPermissions_FromMD
  • TestExtractCallWorkflowPermissions_FileNotFound
  • TestExtractCallWorkflowPermissions_LockYMLPriorityOverYML
  • TestHasNonAllowedExpressionInRunContent
  • TestHasExpressionInRunContent

Verification

  • go build ./...
  • go vet ./...
  • go vet -tags=integration ./...
  • make fmt
  • go test ./pkg/... (pre-existing pkg/cli failure unrelated)

https://github.com/github/gh-aw/actions/runs/28246514898

Generated by 🧹 Dead Code Removal Agent · ⌖ 12.7 AIC ·

  • expires on Jun 29, 2026, 7:21 AM UTC-08:00

Remove unreachable functions identified by deadcode analyzer:
- permissionLevelRank (call_workflow_permissions.go)
- findUncoveredWorkerPermissions (call_workflow_permissions.go)
- extractCallWorkflowPermissions (call_workflow_permissions.go)
- hasNonAllowedExpressionInRunContent (template_injection_validation.go)
- hasExpressionInRunContent (template_injection_validation.go)

Also remove their exclusive test functions and unused imports.

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

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

PR Code Quality Reviewer completed the code quality review.

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

Test Quality Sentinel completed test quality analysis.

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

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

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

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

No ADR enforcement needed: PR #41731 does not have the 'implementation' label and has 0 new lines of code in business logic directories (threshold: 100).

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 unused internal helper functions and their now-obsolete unit tests in pkg/workflow, reducing maintenance overhead while keeping the currently-used implementations intact (e.g., scanRunContentExpressions and extractCallWorkflowPermissionImport).

Changes:

  • Removed dead helper functions from template injection validation and call-workflow permissions logic.
  • Removed tests that only exercised the deleted helpers and cleaned up related imports.
Show a summary per file
File Description
pkg/workflow/template_injection_validation.go Removes unused hasNonAllowedExpressionInRunContent / hasExpressionInRunContent wrappers.
pkg/workflow/template_injection_validation_test.go Drops tests that only covered the removed wrappers and removes the unused regexp import.
pkg/workflow/call_workflow_permissions.go Removes unused permission comparison / compatibility helper functions and drops the sort import.
pkg/workflow/call_workflow_permissions_test.go Removes tests that depended on the deleted helpers (leaving remaining import/behavior coverage in place).

Review details

Tip

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

  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Low

Comment on lines 471 to 472
// TestExtractCallWorkflowPermissions_LockYMLPriorityOverYML tests that .lock.yml takes
// priority over .yml when both exist
@github-actions

Copy link
Copy Markdown
Contributor Author

🧪 Test Quality Sentinel Report

No new or modified tests to analyze — this PR only removes dead-code tests.

Test files changed (deletions only):

  • pkg/workflow/call_workflow_permissions_test.go (−217 lines)
  • pkg/workflow/template_injection_validation_test.go (−214 lines)
📊 Metrics & Test Classification (0 tests analyzed)
Metric Value
New/modified tests analyzed 0
✅ Design tests (behavioral contracts)
⚠️ Implementation tests (low value)
Tests with error/edge cases
Duplicate test clusters
Test inflation detected N/A
🚨 Coding-guideline violations 0

Go: 0 new/modified (*_test.go); JavaScript: 0 (*.test.cjs, *.test.js).

The two test files were modified but only to remove tests for the 5 dead functions deleted from production (call_workflow_permissions.go −80 lines, template_injection_validation.go −23 lines). No test function was added or changed.

Verdict

Check passed. No new or modified tests to score. Removing dead-code tests alongside their dead production code is correct practice — no quality concerns.

🧪 Test quality analysis by Test Quality Sentinel · 35.1 AIC · ⌖ 27.2 AIC · ⊞ 8.4K ·

@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: N/A (no new tests). This PR removes only dead-code tests alongside their dead production functions — 0% implementation tests (threshold: 30%). No quality concerns.

@github-actions github-actions Bot mentioned this pull request Jun 26, 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.

Skills-Based Review 🧠

Applied /zoom-out — two minor stale comments in adjacent files, no blocking issues.

📋 Key Themes & Highlights

Key Themes

  • Stale cross-file doc comments (2 instances): deleting the wrapper functions left dangling references in compiler.go and call_workflow_secrets.go that were not part of the diff
  • Functional correctness is unaffected — the build, vet, and tests all pass with the deletions

Positive Highlights

  • ✅ Pure deletion PR with zero additions — minimal blast radius
  • ✅ All wrapper functions were genuinely thin (e.g. hasNonAllowedExpressionInRunContent was a one-liner delegating to scanRunContentExpressions)
  • ✅ Deleted tests cleanly mirror deleted functions; no orphaned test helpers
  • ✅ Full verification included (go build, go vet × 2, make fmt, go test) with passing CI run

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 65 AIC · ⌖ 9.77 AIC · ⊞ 6.5K

return walkRunBlockLines(yamlContent, expressionRegex.MatchString)
}

// scanRunContentExpressions performs a single pass over run: blocks to detect both

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] The two deleted functions are still referenced by name in the validateTemplateInjection doc comment in compiler.go (~line 308), which now describes a stale two-step scan strategy. This comment was not updated as part of this PR.

💡 Suggested doc update in compiler.go

The Path B doc in compiler.go currently reads:

//  1. hasExpressionInRunContent(UnsafeContextPattern) — detects user-controlled
//     contexts (github.event.*, steps.*.outputs.*, inputs.*) ...
//  2. hasNonAllowedExpressionInRunContent — detects compiler-regression cases ...

Update to reference the consolidating replacement:

// Uses scanRunContentExpressions to detect both user-controlled contexts
// (scan.hasUnsafe) and non-allowlisted expressions (scan.hasDisallowed) in a
// single pass, avoiding a duplicate run-block walk.

return imported.permissions, nil
}

func extractCallWorkflowPermissionImport(workflowName, markdownPath string) (*callWorkflowPermissionImport, error) {

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] The now-deleted extractCallWorkflowPermissions is still referenced in a cross-reference comment in call_workflow_secrets.go (line 16): "Priority: .lock.yml > .yml (same as extractCallWorkflowPermissions)." A reader following that comment will find no such function.

💡 Suggested fix in call_workflow_secrets.go

Change:

// Priority: .lock.yml > .yml (same as extractCallWorkflowPermissions).

To:

// Priority: .lock.yml > .yml (same as extractCallWorkflowPermissionImport).

@pelikhan pelikhan merged commit 349c5b2 into main Jun 26, 2026
71 of 82 checks passed
@pelikhan pelikhan deleted the chore/remove-dead-functions-2026-06-26-ec876ab64c256a14 branch June 26, 2026 16:44

@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.

Dead code removal is valid: all 5 deleted functions are confirmed unreferenced in production code, go build/vet/test pass, and the deleted wrapper tests are adequately superseded by existing TestExtractCallWorkflowPermissionImport_* and TestCallWorkflowPermissions_EndToEnd coverage.

One inline comment for a documentation artifact introduced by this diff. Two additional stale references in unchanged files are noted below as non-blocking follow-ups.

Non-blocking: stale function names in compiler.go doc comment

pkg/workflow/compiler.go lines 308–312 (unchanged file) still name hasExpressionInRunContent and hasNonAllowedExpressionInRunContent as the two text scans used by Path B of validateTemplateInjection. Both functions are removed by this PR; the actual call at line 343 is scanRunContentExpressions(yamlContent). The comment should be updated to describe scanRunContentExpressions and its .hasUnsafe / .hasDisallowed fields instead.

Non-blocking: stale cross-reference in call_workflow_secrets.go

pkg/workflow/call_workflow_secrets.go line 16 reads // Priority: .lock.yml > .yml (same as extractCallWorkflowPermissions). — the referenced helper is deleted. Update to reference extractCallWorkflowPermissionImport or just describe the priority rule directly.

Warning

Firewall blocked 1 domain

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

  • patchdiff.githubusercontent.com

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

network:
  allowed:
    - defaults
    - "patchdiff.githubusercontent.com"

See Network Configuration for more information.

🔎 Code quality review by PR Code Quality Reviewer · 88.4 AIC · ⌖ 6.86 AIC · ⊞ 5.2K

@@ -645,48 +470,6 @@ jobs:

// TestExtractCallWorkflowPermissions_LockYMLPriorityOverYML tests that .lock.yml takes
// priority over .yml when both exist

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.

Orphan comment left behind after function deletion: the doc comment for TestExtractCallWorkflowPermissions_LockYMLPriorityOverYML has no function body below it and will mislead anyone reading the file.

💡 Suggested fix

Delete the two dangling lines (lines 471–472):

-// TestExtractCallWorkflowPermissions_LockYMLPriorityOverYML tests that .lock.yml takes
-// priority over .yml when both exist
-
 // TestCallWorkflowPermissions_EndToEnd tests...

The .lock.yml > .yml priority is still exercised end-to-end inside TestBuildCallWorkflowJobs_SetsPermissionsFromLockYML and TestCallWorkflowPermissions_EndToEnd—no coverage gap, just remove the stale comment.

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