Skip to content

feat: add targets support for scorecardClassic#2651

Merged
AlbinaBlazhko17 merged 25 commits intomainfrom
feat/add-targets-support
Mar 18, 2026
Merged

feat: add targets support for scorecardClassic#2651
AlbinaBlazhko17 merged 25 commits intomainfrom
feat/add-targets-support

Conversation

@AlbinaBlazhko17
Copy link
Copy Markdown
Contributor

@AlbinaBlazhko17 AlbinaBlazhko17 commented Mar 12, 2026

What/Why/How?

  • Added support of targets property in scorecardClassic command. Using targets property we can override rules inside scorecardClassic for specific api, which matches the criteria's under where statement. We find the matching api using metadata. We can add metadata in three places: under api in config, inside openapi file in x-metadata or title and version inside openapi. If the target matches we apply rules for the levels.

Reference

Resolves #2580

Testing

Locally.

Screenshots (optional)

Check yourself

  • Code changed? - Tested with Redoc/Realm/Reunite (internal)
  • All new/updated code is covered by tests
  • New package installed? - Tested in different environments (browser/node)
  • Documentation update considered

Security

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

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 12, 2026

🦋 Changeset detected

Latest commit: a4b3851

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 Minor
@redocly/openapi-core Minor
@redocly/respect-core Minor

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

@AlbinaBlazhko17 AlbinaBlazhko17 changed the title Feat/add targets support feat: add targets support for scorecardClassic Mar 12, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 12, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 79.15% (🎯 79%) 6495 / 8205
🔵 Statements 78.62% (🎯 78%) 6714 / 8539
🔵 Functions 82.57% (🎯 82%) 1322 / 1601
🔵 Branches 71.02% (🎯 71%) 4436 / 6246
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/cli/src/commands/scorecard-classic/index.ts 0% 0% 0% 0% 34-184
packages/cli/src/commands/scorecard-classic/targets-handler/targets-handler.ts 100% 84.21% 100% 100%
packages/cli/src/commands/scorecard-classic/validation/validate-scorecard.ts 80% 74.54% 100% 79.16% 51-53, 67-87
packages/cli/src/utils/miscellaneous.ts 61.21% 55.46% 78.04% 60.49% 60, 125, 182-232, 258-259, 269-270, 285, 289, 292, 298, 302-305, 313-346, 357, 382, 391, 399-437, 527, 536
Generated in workflow #9047 for commit a4b3851 by the Vitest Coverage Report Action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 12, 2026

CLI Version Mean Time ± Std Dev (s) Relative Performance (Lower is Faster)
cli-latest 3.594s ± 0.053s ▓ 1.00x
cli-next 3.585s ± 0.023s ▓ 1.00x (Fastest)

@AlbinaBlazhko17 AlbinaBlazhko17 marked this pull request as ready for review March 13, 2026 07:06
@AlbinaBlazhko17 AlbinaBlazhko17 requested review from a team as code owners March 13, 2026 07:06
@AlbinaBlazhko17 AlbinaBlazhko17 marked this pull request as draft March 13, 2026 07:17
@AlbinaBlazhko17 AlbinaBlazhko17 marked this pull request as ready for review March 13, 2026 07:17
Comment thread .changeset/lovely-bikes-brake.md
@JLekawa
Copy link
Copy Markdown
Contributor

JLekawa commented Mar 13, 2026

It might be a good idea to add some documentation for this property.

@AlbinaBlazhko17
Copy link
Copy Markdown
Contributor Author

@JLekawa the whole config for scorecardClassic goes from Reunite, so you need to configure it on the other side and we have docs how to configure scorecardClassic. Do we need to add docs inside CLI? WDYT?

Comment thread packages/cli/src/commands/scorecard-classic/targets-handler/targets-handler.ts Outdated
Comment thread packages/cli/src/commands/scorecard-classic/__tests__/targets-handler.test.ts Outdated
Comment thread packages/core/src/index.ts Outdated
Comment thread packages/cli/src/commands/scorecard-classic/__tests__/targets-handler.test.ts Outdated
Comment thread packages/cli/src/commands/scorecard-classic/targets-handler/targets-handler.ts Outdated
Comment thread packages/cli/src/commands/scorecard-classic/__tests__/targets-handler.test.ts Outdated
Comment thread packages/cli/src/commands/scorecard-classic/targets-handler/targets-handler.ts Outdated
Comment thread packages/cli/src/commands/scorecard-classic/targets-handler/targets-handler.ts Outdated
Comment thread packages/cli/src/commands/scorecard-classic/targets-handler/targets-handler.ts Outdated
Comment thread packages/cli/src/commands/scorecard-classic/targets-handler/targets-handler.ts Outdated
Copy link
Copy Markdown
Collaborator

@tatomyr tatomyr left a comment

Choose a reason for hiding this comment

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

Almost there.

}

for (const target of targets) {
const matches = Object.entries(target.where?.metadata || {}).every(([key, value]) => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please extract the callback to a named function so the name conveys the intention.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Refactored

Comment thread packages/cli/src/commands/scorecard-classic/__tests__/targets-handler.test.ts Outdated
levels: [{ name: 'Baseline' }],
targets: [{ where: { metadata: { env: 'prod' } }, minimumLevel: 'Gold' }],
};
expect(getTarget(scorecardConfig.targets, { env: 'dev' })?.minimumLevel).toBeUndefined();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
expect(getTarget(scorecardConfig.targets, { env: 'dev' })?.minimumLevel).toBeUndefined();
expect(getTarget(scorecardConfig.targets, { env: 'dev' })!.minimumLevel).toBeUndefined();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This will throw an error, because the purpose of this test is to check if it is undefined

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Oh, indeed. Didn't notice.

Comment thread packages/cli/src/commands/scorecard-classic/targets-handler/targets-handler.ts Outdated
@AlbinaBlazhko17 AlbinaBlazhko17 merged commit 99b2a6a into main Mar 18, 2026
40 of 41 checks passed
@AlbinaBlazhko17 AlbinaBlazhko17 deleted the feat/add-targets-support branch March 18, 2026 07:13
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.

scorecard-classic: Custom target rules not respected

3 participants