Skip to content

Derive Hash for ThreatLevel (#186)#187

Merged
msk merged 2 commits intomainfrom
octoaide/issue-186-2026-03-30T18-18-47
Mar 30, 2026
Merged

Derive Hash for ThreatLevel (#186)#187
msk merged 2 commits intomainfrom
octoaide/issue-186-2026-03-30T18-18-47

Conversation

@octoaide
Copy link
Copy Markdown
Contributor

@octoaide octoaide Bot commented Mar 30, 2026

Summary

This change adds a Hash derive for the ThreatLevel enum so it can be used directly as a HashMap key. This makes it easier for downstream crates (for example review-database) to count or group items by threat level without introducing local workarounds.

What I changed

  • src/types.rs: Added Hash to the derive list for ThreatLevel.
  • src/types.rs: Added test threat_level_as_hash_key that uses ThreatLevel as a HashMap key and verifies counting behavior.
  • CHANGELOG.md: Added an [Unreleased] entry noting the Hash derive for ThreatLevel.

Why

Consumers of review-protocol want to use ThreatLevel in hash-based collections (e.g., HashMap) to count or aggregate events by threat level. Deriving Hash is a small, backward-compatible change that enables that usage pattern.

Notes

  • Tests were added to validate ThreatLevel works as a hash key.
  • Formatting/linting adjustments (if any) are incidental and not the focus of this PR.

Closes #186

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.86%. Comparing base (0412c82) to head (e2dec94).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #187      +/-   ##
==========================================
+ Coverage   85.82%   85.86%   +0.04%     
==========================================
  Files          15       15              
  Lines        6313     6331      +18     
==========================================
+ Hits         5418     5436      +18     
  Misses        895      895              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@octoaide
Copy link
Copy Markdown
Contributor Author

octoaide Bot commented Mar 30, 2026

I ran the failing checks and found the cause: the test threat_level_as_hash_key referenced ThreatLevel without importing it. The test module's existing use super::*; is behind #[cfg(any(feature = "client", feature = "server"))], so when running the default cargo test / cargo clippy --tests (no features enabled) ThreatLevel ended up undeclared.

I fixed this by adding use super::ThreatLevel; directly in the test function, committed the change, and pushed it. Tests now pass and the CI checks that were blocking this PR are resolved.

Summary: added an explicit import for ThreatLevel in the failing test, pushed the fix, and CI is green.

@msk msk merged commit 844f9a6 into main Mar 30, 2026
22 checks passed
@msk msk deleted the octoaide/issue-186-2026-03-30T18-18-47 branch March 30, 2026 18:32
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.

Would it be possible to derive Hash for ThreatLevel?

1 participant