Skip to content

Fix compliance score calculation in Get-ComplianceReportData#928

Closed
04cb wants to merge 1 commit intomicrosoft:mainfrom
04cb:fix/compliance-score-calculation
Closed

Fix compliance score calculation in Get-ComplianceReportData#928
04cb wants to merge 1 commit intomicrosoft:mainfrom
04cb:fix/compliance-score-calculation

Conversation

@04cb
Copy link
Copy Markdown

@04cb 04cb commented Mar 7, 2026

The `Get-ComplianceReportData` function was calculating compliance scores using a confusing formula that derived `PinnedDependencies` from the difference between total violations and non-Info severity violations. Since no violations are currently assigned 'Info' severity, this resulted in `PinnedDependencies` always being 0 when violations were found.

The fix simplifies the logic to explicitly set `PinnedDependencies` to 0 and `ComplianceScore` to 0% when violations are found (since all items in the Violations array are unpinned dependencies), and 100% when no violations are found. This preserves the existing behavior while making the code more maintainable and easier to understand.

Changes:

  • Removed the confusing `$unpinnedDeps` calculation with severity filtering
  • Removed the derived `$pinnedDeps` calculation
  • Explicitly set `PinnedDependencies = 0` when violations exist
  • Clarified that `TotalDependencies` represents the count of violations found
  • Added clear comments explaining the calculation logic

The Get-ComplianceReportData function was calculating compliance scores
using a confusing formula that derived PinnedDependencies from the
difference between total violations and non-Info severity violations.
Since no violations are currently assigned 'Info' severity, this resulted
in PinnedDependencies always being 0 when violations were found.

The fix simplifies the logic to explicitly set PinnedDependencies to 0
and ComplianceScore to 0% when violations are found (since all items in
the Violations array are unpinned dependencies), and 100% when no
violations are found. This preserves the existing behavior while making
the code more maintainable and easier to understand.
@04cb 04cb requested a review from a team as a code owner March 7, 2026 05:34
@WilliamBerryiii
Copy link
Copy Markdown
Member

While there are some potential improvements that can be made in this section of the code, there's no issue filed that demonstrates incorrect behavior of the system or the calculations. Please file an issue first if you believe the calculations are incorrect and we will triage from there.

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