feat(format/yaml): flow scalar content - #11050
Conversation
|
✅ Organic activityNo automation signals detected in the analyzed events. This is an automated analysis by AgentScan |
ematipico
left a comment
There was a problem hiding this comment.
This PR needs the same logic from its previous PR of the stack
fd40954 to
a360920
Compare
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01472YxeN6U2t4LWfaqkieAv
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01472YxeN6U2t4LWfaqkieAv
a360920 to
81a7843
Compare
WalkthroughAdds shared YAML line iteration and a Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/biome_yaml_formatter/tests/line_endings.rs`:
- Around line 37-40: Extend the flow-scalar line-ending coverage in
flow_scalar_with_carriage_return_line_breaks with a CRLF input case containing
\r\n, ensuring the expected formatted output uses normalized \n line breaks and
preserves indentation. Keep the existing lone-CR regression case and target the
ContentLines CRLF handling branch.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d979ff0e-c862-4532-af29-86aa34e92803
⛔ Files ignored due to path filters (21)
crates/biome_yaml_formatter/tests/specs/prettier/yaml/plain/multiline.yml.snapis excluded by!**/*.snapand included by**crates/biome_yaml_formatter/tests/specs/prettier/yaml/quote/multiline.yml.snapis excluded by!**/*.snapand included by**crates/biome_yaml_formatter/tests/specs/prettier/yaml/spec/construct-binary.yml.snapis excluded by!**/*.snapand included by**crates/biome_yaml_formatter/tests/specs/prettier/yaml/spec/multiline-plain-scalar-with-empty-line.yml.snapis excluded by!**/*.snapand included by**crates/biome_yaml_formatter/tests/specs/prettier/yaml/spec/multiline-scalar-at-top-level.yml.snapis excluded by!**/*.snapand included by**crates/biome_yaml_formatter/tests/specs/prettier/yaml/spec/multiline-scalar-in-mapping.yml.snapis excluded by!**/*.snapand included by**crates/biome_yaml_formatter/tests/specs/prettier/yaml/spec/plain-scalar-looking-like-key-comment-anchor-and-tag.yml.snapis excluded by!**/*.snapand included by**crates/biome_yaml_formatter/tests/specs/prettier/yaml/spec/sequence-entry-that-looks-like-two-with-wrong-indentation.yml.snapis excluded by!**/*.snapand included by**crates/biome_yaml_formatter/tests/specs/prettier/yaml/spec/spec-example-2-27-invoice.yml.snapis excluded by!**/*.snapand included by**crates/biome_yaml_formatter/tests/specs/prettier/yaml/spec/spec-example-6-4-line-prefixes.yml.snapis excluded by!**/*.snapand included by**crates/biome_yaml_formatter/tests/specs/prettier/yaml/spec/spec-example-6-5-empty-lines.yml.snapis excluded by!**/*.snapand included by**crates/biome_yaml_formatter/tests/specs/prettier/yaml/spec/spec-example-6-8-flow-folding.yml.snapis excluded by!**/*.snapand included by**crates/biome_yaml_formatter/tests/specs/prettier/yaml/spec/spec-example-7-12-plain-lines.yml.snapis excluded by!**/*.snapand included by**crates/biome_yaml_formatter/tests/specs/prettier/yaml/spec/spec-example-7-14-flow-sequence-entries.yml.snapis excluded by!**/*.snapand included by**crates/biome_yaml_formatter/tests/specs/prettier/yaml/spec/spec-example-7-20-single-pair-explicit-entry.yml.snapis excluded by!**/*.snapand included by**crates/biome_yaml_formatter/tests/specs/prettier/yaml/spec/spec-example-7-5-double-quoted-line-breaks.yml.snapis excluded by!**/*.snapand included by**crates/biome_yaml_formatter/tests/specs/prettier/yaml/spec/spec-example-7-6-double-quoted-lines.yml.snapis excluded by!**/*.snapand included by**crates/biome_yaml_formatter/tests/specs/prettier/yaml/spec/spec-example-7-9-single-quoted-lines.yml.snapis excluded by!**/*.snapand included by**crates/biome_yaml_formatter/tests/specs/prettier/yaml/spec/spec-example-9-4-explicit-documents.yml.snapis excluded by!**/*.snapand included by**crates/biome_yaml_formatter/tests/specs/prettier/yaml/spec/various-trailing-comments.yml.snapis excluded by!**/*.snapand included by**crates/biome_yaml_formatter/tests/specs/yaml/scalar/multiline.yaml.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (10)
crates/biome_yaml_formatter/src/content_lines.rscrates/biome_yaml_formatter/src/flow_scalar.rscrates/biome_yaml_formatter/src/lib.rscrates/biome_yaml_formatter/src/yaml/auxiliary/block_content.rscrates/biome_yaml_formatter/src/yaml/auxiliary/block_map_implicit_entry.rscrates/biome_yaml_formatter/src/yaml/auxiliary/double_quoted_scalar.rscrates/biome_yaml_formatter/src/yaml/auxiliary/plain_scalar.rscrates/biome_yaml_formatter/src/yaml/auxiliary/single_quoted_scalar.rscrates/biome_yaml_formatter/tests/line_endings.rscrates/biome_yaml_formatter/tests/specs/yaml/scalar/multiline.yaml
| #[test] | ||
| fn flow_scalar_with_carriage_return_line_breaks() { | ||
| assert_format("a: \"foo\r\r bar\"\r", "a: \"foo\n\n bar\"\n"); | ||
| } |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Add a CRLF regression case.
\r\r only exercises lone-CR handling; it misses the dedicated \r\n branch in ContentLines.
Proposed test
fn flow_scalar_with_carriage_return_line_breaks() {
assert_format("a: \"foo\r\r bar\"\r", "a: \"foo\n\n bar\"\n");
+ assert_format("a: \"foo\r\n bar\"\r\n", "a: \"foo\n bar\"\n");
}As per coding guidelines, “All code changes must include appropriate tests”.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| #[test] | |
| fn flow_scalar_with_carriage_return_line_breaks() { | |
| assert_format("a: \"foo\r\r bar\"\r", "a: \"foo\n\n bar\"\n"); | |
| } | |
| #[test] | |
| fn flow_scalar_with_carriage_return_line_breaks() { | |
| assert_format("a: \"foo\r\r bar\"\r", "a: \"foo\n\n bar\"\n"); | |
| assert_format("a: \"foo\r\n bar\"\r\n", "a: \"foo\n bar\"\n"); | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@crates/biome_yaml_formatter/tests/line_endings.rs` around lines 37 - 40,
Extend the flow-scalar line-ending coverage in
flow_scalar_with_carriage_return_line_breaks with a CRLF input case containing
\r\n, ensuring the expected formatted output uses normalized \n line breaks and
preserves indentation. Keep the existing lone-CR regression case and target the
ContentLines CRLF handling branch.
Source: Coding guidelines
Summary
This PR formats flow scalar content in the yaml formatter.
implemented with fable 5
Test Plan
Docs