Skip to content

fix(cli): lint with multiple api files results in invalid output#2744

Open
harshit078 wants to merge 21 commits into
Redocly:mainfrom
harshit078:fix-lint-multiple-files
Open

fix(cli): lint with multiple api files results in invalid output#2744
harshit078 wants to merge 21 commits into
Redocly:mainfrom
harshit078:fix-lint-multiple-files

Conversation

@harshit078
Copy link
Copy Markdown
Contributor

@harshit078 harshit078 commented Apr 15, 2026

What/Why/How?

  • Added logic to gather all lint results into allResults during per-file loop, then call formatProblems() once after with the combined totals.

Reference

#2692

Testing

Screenshots (optional)

Check yourself

  • This PR follows the contributing guide
  • All new/updated code is covered by tests
  • Core code changed? - Tested with other Redocly products (internal contributions only)
  • New package installed? - Tested in different environments (browser/node)
  • Documentation update has been considered

Security

  • The security impact of the change has been considered
  • Code follows company security practices and guidelines

Note

Medium Risk
Changes lint output behavior for --format=checkstyle by aggregating results across APIs, which may affect downstream CI parsers but is scoped to one output format.

Overview
Fixes redocly lint --format=checkstyle when multiple APIs are provided by aggregating all lint problems across files and calling formatProblems once at the end, producing a single valid Checkstyle XML document instead of concatenated per-file XML.

Updates tests to assert single-call aggregation behavior and refreshes docs/changeset to reflect the new combined Checkstyle output semantics.

Reviewed by Cursor Bugbot for commit 889daad. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 15, 2026

🦋 Changeset detected

Latest commit: 889daad

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

This PR includes changesets to release 3 packages
Name Type
@redocly/cli Patch
@redocly/openapi-core Patch
@redocly/respect-core 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

@harshit078 harshit078 changed the title fix(cli): lint with multiple api files results in invalid checkstyle/json output fix(cli): lint with multiple api files results in invalid output Apr 15, 2026
@harshit078 harshit078 marked this pull request as ready for review April 15, 2026 12:24
@harshit078 harshit078 requested review from a team as code owners April 15, 2026 12:24
Comment thread packages/cli/src/commands/lint.ts
Comment thread packages/cli/src/commands/lint.ts Outdated
Copy link
Copy Markdown
Contributor

@Daryna-del Daryna-del left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! The overall approach looks good, but there are
a couple of things worth addressing before merging. Could you also take a
look at why the build and test job is failing? Left a few comments.

Comment thread packages/cli/src/commands/lint.ts Outdated
Comment thread packages/cli/src/commands/lint.ts Outdated
Comment thread packages/core/src/format/format.ts Outdated
@harshit078 harshit078 requested a review from Daryna-del May 7, 2026 08:37
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0c7cf32. Configure here.

Comment thread packages/cli/src/commands/lint.ts
Copy link
Copy Markdown
Contributor

@Daryna-del Daryna-del left a comment

Choose a reason for hiding this comment

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

Hey @harshit078
Left some comments, could you, please, take a look?

Comment thread docs/@v1/commands/lint.md Outdated
Comment thread .changeset/empty-cities-sink.md Outdated
"@redocly/cli": patch
---

When multiple APIs are linted in a single command, all structured formats (such as `checkstyle` and `json`) produce a single combined document that groups problems per file.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We would like to have combined output only for checkstyle format. Could you please adjust it?

Comment thread docs/@v2/commands/lint.md Outdated
Some formats, such as `checkstyle` or `json`, don't work well when multiple APIs are linted in a single command.
Try linting each API separately when you pass the command output to another tool.
{% /admonition %}
When multiple APIs are linted in a single command, all structured formats (such as `checkstyle` and `json`) produce a single combined document that groups problems per file.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here, only for checkstyle format. Could you please adjust docs?

Comment thread packages/cli/src/commands/lint.ts Outdated
version,
command: 'lint',
});
allLintRes.push(...results);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We would like to have combined output only for checkstyle format. Could you please adjust a solution?

Comment thread packages/cli/src/commands/lint.ts Outdated
}
}

if (!argv['generate-ignore-file']) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here, only for checkstyle format

Comment thread tests/e2e/lint/default-message-override/snapshot.txt Outdated
Comment thread tests/e2e/lint/draft4-vs-2020-schema-differences/snapshot.txt Outdated
@harshit078
Copy link
Copy Markdown
Contributor Author

Hey @Daryna-del , I have addressed the comments you left and updated the docs along with it. Can you please review it again ? Thanks !

@harshit078 harshit078 requested a review from Daryna-del May 19, 2026 07:57
@Daryna-del
Copy link
Copy Markdown
Contributor

Hi @harshit078 !
Thanks for the contribution! We’re almost there 🙂
Could you please fix formatting issue by running npm run format?

@harshit078
Copy link
Copy Markdown
Contributor Author

Hey @Daryna-del , pushed a fix for the linting issue. Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants