Conversation
…tCompilerError - Remove redundant pastFrontmatter variable from fastParseTitle; the inFrontmatter flag already encodes the distinction between 'inside frontmatter' and 'past frontmatter'. Reduces 3-variable state to 2. - Make formatCompilerError a thin wrapper over formatCompilerErrorWithPosition (line=1, col=1) to eliminate ~15 lines of duplicated struct construction. No functional change; all existing tests pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors two recently added helpers to reduce state/duplication while preserving behavior: fastParseTitle is simplified by removing redundant state, and formatCompilerError is simplified by delegating to formatCompilerErrorWithPosition.
Changes:
- Simplified
fastParseTitleby removingpastFrontmatterand directly togglinginFrontmatteron close delimiter. - Deduplicated compiler error formatting by making
formatCompilerErrora thin wrapper overformatCompilerErrorWithPosition(filePath, 1, 1, ...).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/cli/workflows.go | Simplifies frontmatter/title scanning state machine while keeping frontmatter semantics and error behavior intact. |
| pkg/workflow/compiler_error_formatter.go | Removes duplicated error-formatting struct construction by delegating to the positioned formatter. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR simplifies two pieces of code from PRs merged in the last 24 hours, improving clarity while preserving identical functionality.
Files Simplified
pkg/cli/workflows.go— simplifiedfastParseTitlestate machinepkg/workflow/compiler_error_formatter.go— eliminated duplicated struct constructionImprovements Made
1.
fastParseTitle— removed redundantpastFrontmattervariableThe function tracked three booleans (
firstLine,inFrontmatter,pastFrontmatter), butpastFrontmatteris redundant: onceinFrontmatterbecomes false after the opening---, the code is already past any frontmatter. Removing it:pastFrontmatter &&guard on the H1 check (implicit from!inFrontmatter)else if inFrontmatter && !pastFrontmatterbranch toelse if inFrontmatterinFrontmatter && !pastFrontmatter→inFrontmatter2.
formatCompilerError— deduplicated via wrapperformatCompilerErrorandformatCompilerErrorWithPositionshared identical logic (sameconsole.FormatErrorstruct, samewrappedCompilerErrorreturn).formatCompilerErroris now a thin wrapper that callsformatCompilerErrorWithPosition(filePath, 1, 1, ...), removing ~15 lines of duplicated code.Changes Based On
Recent changes from:
extractWorkflowNameFromFileby eliminating unnecessary YAML parse #21012 —perf: optimize extractWorkflowNameFromFile by eliminating unnecessary YAML parse(introducedfastParseTitle)Fix engine validation error location and improve error detection(introducedformatCompilerErrorWithPosition, refactoredformatCompilerError)Testing
TestFastParseTitlesubtests passTestIsFormattedCompilerError,TestFindFrontmatterFieldLine,TestEngineValidationErrorHasFileLocationtests passmake build)gofmtcleanReview Focus
Please verify:
fastParseTitlestate transitions are equivalent to the originalformatCompilerErrordelegation preserves the same log output (now showsline=1, column=1in the log, same information)Automated by Code Simplifier Agent — analyzing code from the last 24 hours
References: §23110390758