feat(cli): add format errors to GitLab reporter#8028
Conversation
🦋 Changeset detectedLatest commit: d51feda The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThe GitLab reporter has been enhanced to handle missing diagnostic spans more robustly. When a span is unavailable, the code now defaults to a minimal fallback range (1..1) instead of returning early, ensuring format errors are properly output. A changeset has been added to document this patch bump. Suggested labels
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
crates/biome_cli/src/reporter/gitlab.rs (1)
208-210: Solid fix for missing spans.The fallback ensures format errors without explicit spans still get emitted. Minor consideration:
TextSize::from(0)(file start) might be fractionally more idiomatic than offset 1, but your tested solution works perfectly well.Consider this if you want to be pedantic:
- let span = location - .span - .unwrap_or(TextRange::new(TextSize::from(1), TextSize::from(1))); + let span = location + .span + .unwrap_or(TextRange::new(TextSize::from(0), TextSize::from(0)));
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
crates/biome_cli/tests/snapshots/main_cases_reporter_gitlab/reports_diagnostics_gitlab_check_command.snapis excluded by!**/*.snapand included by**crates/biome_cli/tests/snapshots/main_cases_reporter_gitlab/reports_diagnostics_gitlab_ci_command.snapis excluded by!**/*.snapand included by**crates/biome_cli/tests/snapshots/main_cases_reporter_gitlab/reports_diagnostics_gitlab_format_command.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (2)
.changeset/ten-bags-ring.md(1 hunks)crates/biome_cli/src/reporter/gitlab.rs(2 hunks)
🧰 Additional context used
🧠 Learnings (11)
📚 Learning: 2025-09-25T12:32:59.003Z
Learnt from: arendjr
Repo: biomejs/biome PR: 7593
File: crates/biome_service/src/workspace/server.rs:1306-1306
Timestamp: 2025-09-25T12:32:59.003Z
Learning: In the biomejs/biome project, do not flag compilation errors during code review as they are handled by the existing test infrastructure and CI. Focus on other code quality aspects instead.
Applied to files:
.changeset/ten-bags-ring.md
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:46.002Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Use `dbg_write!` to debug and inspect the emitted IR during formatting
Applied to files:
crates/biome_cli/src/reporter/gitlab.rs
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/src/**/*.rs : After generation, remove usages of `format_verbatim_node` and implement real formatting with biome_formatter utilities
Applied to files:
crates/biome_cli/src/reporter/gitlab.rs
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/src/lib.rs : Add the provided AsFormat, IntoFormat, and iterator plumbing code to lib.rs
Applied to files:
crates/biome_cli/src/reporter/gitlab.rs
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:46.002Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Import and use the `FormatNode` trait for AST nodes
Applied to files:
crates/biome_cli/src/reporter/gitlab.rs
📚 Learning: 2025-10-15T09:21:24.116Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_diagnostics/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:21:24.116Z
Learning: Use helper advice types from `biome_diagnostics::v2` (CodeFrameAdvice, CommandAdvice, DiffAdvice, LogAdvice) when suitable
Applied to files:
crates/biome_cli/src/reporter/gitlab.rs
📚 Learning: 2025-10-15T09:22:15.851Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:15.851Z
Learning: Applies to crates/biome_formatter/src/context.rs : Create HtmlFormatContext in context.rs with comments and source_map fields and implement FormatContext and CstFormatContext
Applied to files:
crates/biome_cli/src/reporter/gitlab.rs
📚 Learning: 2025-10-15T09:21:24.116Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_diagnostics/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:21:24.116Z
Learning: Specify static properties (category, severity, description, message, location, tags) with `#[diagnostic(...)]`
Applied to files:
crates/biome_cli/src/reporter/gitlab.rs
📚 Learning: 2025-10-15T09:21:24.116Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_diagnostics/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:21:24.116Z
Learning: Prefer implementing the Diagnostic trait via `#[derive(Diagnostic)]`
Applied to files:
crates/biome_cli/src/reporter/gitlab.rs
📚 Learning: 2025-10-15T09:22:46.002Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:22:46.002Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Do not attempt to fix code; if a mandatory token/node is missing, return `None` instead
Applied to files:
crates/biome_cli/src/reporter/gitlab.rs
📚 Learning: 2025-10-15T09:24:31.042Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-10-15T09:24:31.042Z
Learning: Lexer must implement the biome_parser::Lexer trait
Applied to files:
crates/biome_cli/src/reporter/gitlab.rs
🧬 Code graph analysis (1)
crates/biome_cli/src/reporter/gitlab.rs (2)
crates/biome_configuration/src/diagnostics.rs (1)
location(377-379)crates/biome_diagnostics/src/display.rs (1)
location(783-789)
🔇 Additional comments (2)
.changeset/ten-bags-ring.md (1)
1-5: LGTM!The changeset correctly documents this patch-level fix.
crates/biome_cli/src/reporter/gitlab.rs (1)
6-6: Necessary imports for the fallback span logic.
dyc3
left a comment
There was a problem hiding this comment.
Looks good! Thanks for keeping the changeset simple :)
Summary
This PR adds formatting errors to the GitLab reporter output. I noticed that
biome ci --reporter=gitlabwould output an empty list of issues when only formatting errors were present in a project, but still exit with a non-zero exit code and fail the pipeline.I checked the GitHub reporter and noticed that it does output formatting errors, dug around a bit and found this part of its code:
biome/crates/biome_diagnostics/src/display_github.rs
Lines 19 to 22 in 96f3e77
So I just applied the same thing to the GitLab reporter.
Test Plan
Introduced a formatting error in a sample project and verified the output of
biome check --reporter=gitlab.Without the reporter:
❯ bunx biome check src/main.tsx format ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ✖ Formatter would have printed the following content: 29 29 │ createRoot(document.getElementById('root')!).render( 30 30 │ <StrictMode> 31 │ - ······<QueryClientProvider·client={queryClient}> 31 │ + ····<QueryClientProvider·client={queryClient}> 32 32 │ <RouterProvider router={router} /> 33 33 │ </QueryClientProvider> Checked 96 files in 1360ms. No fixes applied. Found 1 error. check ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ✖ Some errors were emitted while running checks.With reporter, before this PR:
❯ bunx biome check --reporter=gitlab [] check ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ✖ Some errors were emitted while running checks.With reporter, after this PR:
This matches the GitHub reporter output:
❯ bunx biome check --reporter=github ::error title=format,file=src/main.tsx,line=1,endLine=1,col=2,endColumn=2::Formatter would have printed the following content: check ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ × Some errors were emitted while running checks.Docs
n/a