Refactor IndexMatcher control flow to reduce CodeQL complexity hotspots#311
Conversation
Agent-Logs-Url: https://github.com/albe/node-event-storage/sessions/1dd9c392-e611-4621-8fd4-60914039e1c8 Co-authored-by: albe <4259532+albe@users.noreply.github.com>
Agent-Logs-Url: https://github.com/albe/node-event-storage/sessions/1dd9c392-e611-4621-8fd4-60914039e1c8 Co-authored-by: albe <4259532+albe@users.noreply.github.com>
|
@copilot where is the reduced code coverage coming from? If the logic didn't change coverage shouldn't be affected, no? |
Good catch — coverage dropped because the refactor changed how c8/istanbul instruments branches, even though behavior stayed the same. In |
|
@copilot yes add new tests that covers this code branch to keep coverage same or even improve it |
Agent-Logs-Url: https://github.com/albe/node-event-storage/sessions/0dbff84b-fce2-43cf-988a-46de8462f1e9 Co-authored-by: albe <4259532+albe@users.noreply.github.com>
Added focused tests in commit |
IndexMatcherwas flagged for elevated cyclomatic complexity, withforEachMatchcalled out as the primary hotspot and the deepest nesting around candidate match evaluation. This change reduces branching depth and conditional nesting in-place, without restructuring via helper extraction.forEachMatch: flatten candidate resolution and fallback evaluationcontinueflow when discriminant values are missing/invalid.matches(...)verification semantics unchanged.add/remove: simplify classification branchesfunctionMatcherstableunclassifiedMatchersBehavioral intent