Skip to content

Add HealthCalculator tests + fix PercentRank >1.0 bug#613

Merged
erikdarlingdata merged 1 commit intodevfrom
fix/health-calculator-tests
Mar 17, 2026
Merged

Add HealthCalculator tests + fix PercentRank >1.0 bug#613
erikdarlingdata merged 1 commit intodevfrom
fix/health-calculator-tests

Conversation

@erikdarlingdata
Copy link
Owner

@erikdarlingdata erikdarlingdata commented Mar 17, 2026

57 unit tests with adversarial inputs. Found and fixed PercentRank returning 1.5 for out-of-range values.

Summary by CodeRabbit

  • Tests

    • Added comprehensive unit test suite for health and impact scoring functionality.
  • Bug Fixes

    • Fixed ranking calculation to prevent values from exceeding the maximum threshold of 1.0.

57 tests covering CpuScore, MemoryScore, StorageScore, Overall,
ScoreColor, PercentRank, and HighImpactScorer with adversarial inputs.

Found and fixed: PercentRank returned 1.5 when value exceeded all list
entries (rank/count-1 exceeded 1.0). Clamped with Math.Min(1.0m, ...).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata merged commit 713f840 into dev Mar 17, 2026
@erikdarlingdata erikdarlingdata deleted the fix/health-calculator-tests branch March 17, 2026 22:34
@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e9bacd0a-192e-4f00-9a25-8159b162a05d

📥 Commits

Reviewing files that changed from the base of the PR and between 91ed3e3 and 2c1b840.

📒 Files selected for processing (2)
  • Lite.Tests/HealthCalculatorTests.cs
  • Lite/Services/LocalDataService.FinOps.cs

📝 Walkthrough

Walkthrough

This pull request adds a comprehensive test suite for FinOpsHealthCalculator and HighImpactScorer covering boundary conditions, monotonicity, and edge cases. A production code fix adjusts PercentRank calculation to clamp results at 1.0, preventing values from exceeding the upper bound.

Changes

Cohort / File(s) Summary
Test Coverage
Lite.Tests/HealthCalculatorTests.cs
Adds 497 lines of unit tests for FinOpsHealthCalculator and HighImpactScorer, including tests for CPU, memory, and storage scores; PercentRank behavior across various input lists and edge cases; and HighImpactScorer topN filtering with adversarial inputs.
PercentRank Clamping
Lite/Services/LocalDataService.FinOps.cs
Modifies PercentRank calculation to clamp the result at 1.0, preventing rank values from exceeding the upper bound while maintaining zero returns for empty or single-value inputs.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/health-calculator-tests
📝 Coding Plan
  • Generate coding plan for human review comments

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

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.

1 participant