Skip to content

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

Merged
Daryna-del merged 26 commits into
Redocly:mainfrom
harshit078:fix-lint-multiple-files
Jun 3, 2026
Merged

fix(cli): lint with multiple api files results in invalid output#2744
Daryna-del merged 26 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

Low Risk
Scoped to checkstyle output aggregation in the lint command; other formats and ignore-file generation are unchanged.

Overview
lint --format=checkstyle now emits one valid Checkstyle XML document when you pass multiple API paths in a single run. Previously each API triggered its own formatProblems call, which concatenated separate XML roots and broke downstream parsers.

The handler buffers problems per file during the loop and calls formatProblems once after all APIs finish, using combined totals. Other formats still format per API as before. Docs drop the old “lint one API at a time” warning and describe the combined <file> behavior. A unit test asserts a single aggregated formatProblems call for two APIs.

Reviewed by Cursor Bugbot for commit fc23c4e. 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: fc23c4e

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
Comment thread docs/@v2/commands/lint.md Outdated
Comment thread packages/cli/src/commands/lint.ts Outdated
Comment thread packages/cli/src/commands/lint.ts Outdated
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 !

@harshit078
Copy link
Copy Markdown
Contributor Author

Hey @Daryna-del , can you review the PR again post all test fixes ? Thanks !

@Daryna-del Daryna-del added the snapshot Create experimental release PR label Jun 1, 2026
@Daryna-del Daryna-del added snapshot Create experimental release PR and removed snapshot Create experimental release PR labels Jun 2, 2026
@Daryna-del Daryna-del added snapshot Create experimental release PR and removed snapshot Create experimental release PR labels Jun 2, 2026
@Daryna-del Daryna-del removed the snapshot Create experimental release PR label Jun 2, 2026
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!
Thanks again for the contribution! Everything looks good to me, let's wait for a review from technical writers 🙂
Regarding the changes I made to your PR, I was trying to adjust the release snapshot version job for testing purposes, but it didn’t work as expected, so I reverted those changes. Sorry for the confusion.

@Daryna-del Daryna-del merged commit 296e029 into Redocly:main Jun 3, 2026
76 of 79 checks passed
@Daryna-del
Copy link
Copy Markdown
Contributor

Hey @harshit078!
Fix should be available in 2.31.6 version.
Thank you.

@harshit078 harshit078 deleted the fix-lint-multiple-files branch June 4, 2026 11:12
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.

3 participants