Skip to content

[dead-code] chore: remove dead functions — 2 functions removed#22534

Merged
pelikhan merged 2 commits intomainfrom
dead-code/remove-extract-markdown-functions-2026-03-23-707d58d81ebfd7e3
Mar 23, 2026
Merged

[dead-code] chore: remove dead functions — 2 functions removed#22534
pelikhan merged 2 commits intomainfrom
dead-code/remove-extract-markdown-functions-2026-03-23-707d58d81ebfd7e3

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Dead Code Removal

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

Functions Removed

Function File
ExtractWorkflowNameFromMarkdown pkg/parser/frontmatter_content.go
ExtractMarkdown pkg/parser/frontmatter_content.go

Both functions are superseded by in-memory equivalents (ExtractWorkflowNameFromMarkdownBody, ExtractMarkdownContent) that avoid redundant file I/O and are used throughout the production codebase.

Tests Removed

Test Function File
TestExtractWorkflowNameFromMarkdown pkg/parser/frontmatter_utils_test.go
TestExtractMarkdown pkg/parser/frontmatter_utils_test.go

Also removed a stale comment in pkg/parser/frontmatter_includes_test.go that referenced the deleted function.

Verification

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

Dead Function Count

  • Before this batch: ~19 functions reported by deadcode
  • Removed in this PR: 2 functions
  • Remaining: ~17 functions (several skipped: WASM-live functions, test infrastructure, cached from prior runs)

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

Generated by Dead Code Removal Agent ·

  • expires on Mar 26, 2026, 9:49 PM UTC

…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>
@pelikhan pelikhan marked this pull request as ready for review March 23, 2026 22:17
Copilot AI review requested due to automatic review settings March 23, 2026 22:17
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 unreachable parser helpers and associated tests identified by deadcode, consolidating usage on the existing in-memory parsing functions.

Changes:

  • Deleted file-based helpers ExtractWorkflowNameFromMarkdown and ExtractMarkdown from pkg/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
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

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

Suggested change
// efficient than ExtractWorkflowNameFromMarkdown or ExtractWorkflowNameFromContent because it
// efficient than ExtractWorkflowNameFromContent and any file-based variants because it

Copilot uses AI. Check for mistakes.
Comment on lines 178 to 180
// Test mergeToolsFromJSON function

// Benchmark StripANSI function for performance
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

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)
	}
}

Copilot uses AI. Check for mistakes.
@pelikhan pelikhan merged commit 6b46ba6 into main Mar 23, 2026
70 of 114 checks passed
@pelikhan pelikhan deleted the dead-code/remove-extract-markdown-functions-2026-03-23-707d58d81ebfd7e3 branch March 23, 2026 22:21
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