Skip to content

feat(cli): add format errors to GitLab reporter#8028

Merged
dyc3 merged 1 commit intobiomejs:mainfrom
fmajestic:gitlab-reporter-output-formatting-errors
Nov 7, 2025
Merged

feat(cli): add format errors to GitLab reporter#8028
dyc3 merged 1 commit intobiomejs:mainfrom
fmajestic:gitlab-reporter-output-formatting-errors

Conversation

@fmajestic
Copy link
Contributor

Summary

This PR adds formatting errors to the GitLab reporter output. I noticed that biome ci --reporter=gitlab would 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:

let span = location
.span
// We fall back to 1:1. This usually covers diagnostics that belong to the formatter or organize imports
.unwrap_or(TextRange::new(TextSize::from(1), TextSize::from(1)));

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:

❯ cargo run --manifest-path ~/projects/biome/Cargo.toml -p biome_cli check --reporter=gitlab
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.27s
     Running `/Users/me/projects/biome/target/debug/biome check --reporter=gitlab`
[
  {
    "description": "Formatter would have printed the following content:",
    "check_name": "format",
    "fingerprint": "1427705328477204594",
    "severity": "critical",
    "location": {
      "path": "src/main.tsx",
      "lines": {
        "begin": 1
      }
    }
  }
]
check ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ✖ Some errors were emitted while running checks.

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

@changeset-bot
Copy link

changeset-bot bot commented Nov 6, 2025

🦋 Changeset detected

Latest commit: d51feda

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

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

@github-actions github-actions bot added the A-CLI Area: CLI label Nov 6, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 6, 2025

Walkthrough

The 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

A-CLI, A-Diagnostic

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main change: adding format errors to the GitLab reporter output.
Description check ✅ Passed The description is well-detailed and directly related to the changeset, explaining the issue, the fix approach, and comprehensive test results.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6374b1f and d51feda.

⛔ Files ignored due to path filters (3)
  • crates/biome_cli/tests/snapshots/main_cases_reporter_gitlab/reports_diagnostics_gitlab_check_command.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_gitlab/reports_diagnostics_gitlab_ci_command.snap is excluded by !**/*.snap and included by **
  • crates/biome_cli/tests/snapshots/main_cases_reporter_gitlab/reports_diagnostics_gitlab_format_command.snap is excluded by !**/*.snap and 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.

Copy link
Contributor

@dyc3 dyc3 left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks for keeping the changeset simple :)

@dyc3 dyc3 merged commit c09e45c into biomejs:main Nov 7, 2025
19 of 20 checks passed
@github-actions github-actions bot mentioned this pull request Nov 7, 2025
@fmajestic fmajestic deleted the gitlab-reporter-output-formatting-errors branch November 10, 2025 22:13
ematipico pushed a commit to hamirmahal/biome that referenced this pull request Nov 19, 2025
l0ngvh pushed a commit to l0ngvh/biome that referenced this pull request Dec 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: CLI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants