Conversation
…actMarkdown Remove two unreachable functions identified by the deadcode static analyzer: - ExtractWorkflowNameFromMarkdown (pkg/parser/frontmatter_content.go) - ExtractMarkdown (pkg/parser/frontmatter_content.go) Both functions are superseded by in-memory equivalents (ExtractWorkflowNameFromMarkdownBody, ExtractMarkdownContent) and are not reachable from any production binary entry point. Also remove their exclusive test functions (TestExtractWorkflowNameFromMarkdown, TestExtractMarkdown) and a stale comment referencing the deleted function. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…2026-03-23-707d58d81ebfd7e3
There was a problem hiding this comment.
Pull request overview
Removes unreachable parser helpers and associated tests identified by deadcode, consolidating usage on the existing in-memory parsing functions.
Changes:
- Deleted file-based helpers
ExtractWorkflowNameFromMarkdownandExtractMarkdownfrompkg/parser/frontmatter_content.go. - Removed unit tests that exercised the deleted functions from
pkg/parser/frontmatter_utils_test.go. - Removed a stale test comment referencing the deleted API in
pkg/parser/frontmatter_includes_test.go.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/parser/frontmatter_content.go | Removes file-I/O-based helpers (and their os dependency), leaving in-memory equivalents. |
| pkg/parser/frontmatter_utils_test.go | Deletes tests that targeted the removed APIs. |
| pkg/parser/frontmatter_includes_test.go | Removes a stale comment referencing the removed function. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| // ExtractWorkflowNameFromMarkdownBody extracts the workflow name from an already-extracted | ||
| // markdown body (i.e. the content after the frontmatter has been stripped). This is more | ||
| // efficient than ExtractWorkflowNameFromMarkdown or ExtractWorkflowNameFromContent because it |
There was a problem hiding this comment.
The doc comment mentions ExtractWorkflowNameFromMarkdown, but that function is removed in this PR. Please update the comment to avoid referencing the deleted symbol (e.g., only compare to ExtractWorkflowNameFromContent).
| // efficient than ExtractWorkflowNameFromMarkdown or ExtractWorkflowNameFromContent because it | |
| // efficient than ExtractWorkflowNameFromContent and any file-based variants because it |
| // Test mergeToolsFromJSON function | ||
|
|
||
| // Benchmark StripANSI function for performance |
There was a problem hiding this comment.
Removing these tests also removes coverage of the workflow-name extraction behavior (H1 detection + filename fallback), which is still exercised by ExtractWorkflowNameFromContent / ExtractWorkflowNameFromMarkdownBody in production. Consider reintroducing equivalent tests targeting the in-memory APIs so this behavior remains covered.
See below for a potential fix:
func TestExtractWorkflowNameFromContent_H1Title(t *testing.T) {
content := []byte("# My Workflow Title\n\nSome other content.")
filename := "fallback-name.md"
got := ExtractWorkflowNameFromContent(content, filename)
want := "My Workflow Title"
if got != want {
t.Errorf("ExtractWorkflowNameFromContent() with H1 title = %q, want %q", got, want)
}
}
func TestExtractWorkflowNameFromContent_FilenameFallback(t *testing.T) {
content := []byte("No heading here, just body content.")
filename := "owner/repo/.github/workflows/sample-workflow.md"
got := ExtractWorkflowNameFromContent(content, filename)
want := "sample-workflow"
if got != want {
t.Errorf("ExtractWorkflowNameFromContent() filename fallback = %q, want %q", got, want)
}
}
func TestExtractWorkflowNameFromMarkdownBody_H1Title(t *testing.T) {
body := "# Another Workflow\n\nDetails about this workflow."
filename := "another-fallback.md"
got := ExtractWorkflowNameFromMarkdownBody(body, filename)
want := "Another Workflow"
if got != want {
t.Errorf("ExtractWorkflowNameFromMarkdownBody() with H1 title = %q, want %q", got, want)
}
}
func TestExtractWorkflowNameFromMarkdownBody_FilenameFallback(t *testing.T) {
body := "Content without any level-1 heading."
filename := "owner/repo/.github/workflows/body-fallback.md"
got := ExtractWorkflowNameFromMarkdownBody(body, filename)
want := "body-fallback"
if got != want {
t.Errorf("ExtractWorkflowNameFromMarkdownBody() filename fallback = %q, want %q", got, want)
}
}
Dead Code Removal
This PR removes unreachable Go functions identified by the
deadcodestatic analyzer.Functions Removed
ExtractWorkflowNameFromMarkdownpkg/parser/frontmatter_content.goExtractMarkdownpkg/parser/frontmatter_content.goBoth functions are superseded by in-memory equivalents (
ExtractWorkflowNameFromMarkdownBody,ExtractMarkdownContent) that avoid redundant file I/O and are used throughout the production codebase.Tests Removed
TestExtractWorkflowNameFromMarkdownpkg/parser/frontmatter_utils_test.goTestExtractMarkdownpkg/parser/frontmatter_utils_test.goAlso removed a stale comment in
pkg/parser/frontmatter_includes_test.gothat referenced the deleted function.Verification
go build ./...— passesgo vet ./...— passesgo vet -tags=integration ./...— passesmake fmt— no changes neededgo test ./pkg/parser/...— passesDead Function Count
deadcodeAutomated by Dead Code Removal workflow — https://github.com/github/gh-aw/actions/runs/23461486296