redhat-developer / redhat-developer/rhdh-plugins

Scorecard: Assert correctness of threshold constants in unit tests

Open
#4,594 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature Tests triaged workspace/scorecard
Dominant language
TypeScript
Stars
48
Forks
120
Avg merge
2d 6h
Merged PRs (30d)
337

Description

Invalid threshold definitions let the scorecard plugin fail to start. For the ThresholdConfigs in the code base, unit tests should assert their correctness.

Add a unit tests that calls validateThresholdNumberIntervals for each of this ThresholdConfigs:

  1. PERCENTAGE_THRESHOLDS in @plugins/scorecard-backend-module-code-coverage/src/metricProviders/CodeCoverageMetricProvider.ts
  2. DEPENDABOT_THRESHOLDS in @plugins/scorecard-backend-module-dependabot/src/metricProviders/DependabotConfig.ts
  3. OPENSSF_THRESHOLDS in @plugins/scorecard-backend-module-openssf/src/metricProviders/OpenSSFConfig.ts
  4. SONARQUBE_NUMBER_THRESHOLDS in @plugins/scorecard-backend-module-sonarqube/src/metricProviders/SonarQubeConfig.ts
  5. DEFAULT_NUMBER_THRESHOLDS in @plugins/scorecard-common/src/types/threshold.ts

The test just need to pass without an exception.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with validateThresholdNumberIntervals in @plugins/scorecard-common/src/types/threshold.ts, then inspect the five named ThresholdConfigs in the scorecard metric provider files. Add unit tests that call the validator for each configuration, and run the relevant scorecard unit tests. Done means every test passes without an exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.