Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the domainscrawl matcher to eliminate race conditions in tests by moving from global state to instance-based design. The matcher logic is encapsulated in a matchEngine type with instance methods, improving testability and thread safety.
Key changes:
- Introduced
matchEnginetype with instance methods (AddElements,Match,Reset,Enabled) replacing global functions - Added
NewMatcher()constructor for creating isolated matcher instances - Updated all tests to use local matcher instances instead of global state
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/pkg/postprocessor/domainscrawl/domainscrawl.go | Refactored matcher from global functions to instance methods on matchEngine type |
| internal/pkg/postprocessor/domainscrawl/domainscrawl_test.go | Updated tests to use local matcher instances created with NewMatcher() |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #459 +/- ##
==========================================
- Coverage 56.20% 56.20% -0.01%
==========================================
Files 130 130
Lines 8022 8037 +15
==========================================
+ Hits 4509 4517 +8
- Misses 3154 3161 +7
Partials 359 359
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This pull request refactors the domainscrawl matcher in
internal/pkg/postprocessor/domainscrawl/domainscrawl.goto improve testability and encapsulation. The matcher logic is moved from global functions and variables to instance methods on a newmatchEnginetype, and the tests are updated to use matcher instances instead of global state. This makes the codebase more modular and easier to test in isolation.Matcher encapsulation and API changes:
matchEnginetype and moved matcher logic from global functions to instance methods (e.g.,AddElements,Match,Reset,Enabled). Added aNewMatcherconstructor for creating isolated matcher instances. (internal/pkg/postprocessor/domainscrawl/domainscrawl.go)matchEngineinstance, rather than via global functions and state. (internal/pkg/postprocessor/domainscrawl/domainscrawl.go) [1] [2] [3] [4]Test improvements:
domainscrawl_test.goto use localmatchEngineinstances created withNewMatcher, removing reliance on global state and making tests more robust and parallelizable. (internal/pkg/postprocessor/domainscrawl/domainscrawl_test.go) [1] [2] [3] [4] [5] [6] [7] [8]