-
-
Notifications
You must be signed in to change notification settings - Fork 278
feat(regex): add <> symbol as 'all' and implement exclusions #1698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe changes introduce a new wildcard representation in the codebase, replacing the previous wildcard character Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (4)
internal/engines/lookup.go (2)
208-218: LGTM! Consider adding a comment for clarity.The implementation of the new wildcard symbol
<>and the handling of exclusions look good. Using theALLconstant instead of a hardcoded string is a good practice.Consider adding a brief comment explaining the format of exclusions, e.g.:
// Handle '<>-1,2,3' case: parse exclusions after '-' // Format: "<>-id1,id2,id3" where id1, id2, id3 are excluded subject IDs excludedIds = strings.Split(strings.TrimPrefix(id, ALL+"-"), ",")
221-222: LGTM! Consider a minor optimization.The updated condition correctly handles both exclusions and the presence of the wildcard symbol. Good job on using
slices.Containsfor checking the presence of<>.Consider combining the two checks into a single condition for better readability:
if excludedIds != nil || slices.Contains(ids, ALL) { // ... (rest of the code) }This change uses the
ALLconstant for consistency and slightly simplifies the condition.internal/engines/subjectFilter.go (2)
Line range hint
1-1031: Overall: Well-implemented new wildcard and exclusion functionalityThe changes in this file successfully introduce a new wildcard representation (
<>) and implement exclusion functionality. The use of theALLconstant and consistent handling of wildcards across different functions is commendable.Key points:
- The new wildcard representation is consistently applied throughout the file.
- Exclusion logic is implemented correctly in union, intersection, and the new exclusion function.
- The code structure and logic are well-maintained despite the significant changes.
Recommendations:
- Add comprehensive unit tests for the modified and new functions, especially for edge cases and complex scenarios involving wildcards and exclusions.
- Include additional inline comments explaining the more complex logic, particularly in the intersection and exclusion functions.
- Consider adding a brief documentation comment at the file level explaining the new wildcard representation and exclusion functionality for future developers.
These changes introduce a new way of handling wildcards and exclusions, which may have implications for other parts of the system. Consider reviewing and updating any documentation, API contracts, or dependent modules to ensure consistency with this new approach.
Action Required: Add Unit Tests for
subjectFilterUnionFunctionNo existing unit tests cover the
subjectFilterUnionfunction. To ensure the new wildcard and exclusion handling works as intended, please add comprehensive unit tests covering various scenarios, including:
- Responses with only
"<>"- Responses with
"<>"and additional IDs- Responses with mixed regular IDs and `"<>"```
- Edge cases like empty responses or responses with only exclusions
🔗 Analysis chain
Line range hint
693-729: LGTM: New wildcard and exclusion handling implementedThe changes in this function correctly implement the new wildcard
"<>"representation and exclusion functionality. The logic for handling wildcards and collecting exclusions is well-structured and aligns with the expected behavior.The new result format
"<>-1,2,3"for representing wildcard with exclusions is clear and concise.To ensure the correctness of this significant change, please add comprehensive unit tests covering various scenarios, including:
- Responses with only
"<>"- Responses with
"<>"and additional IDs- Responses with mixed regular IDs and
"<>"- Edge cases like empty responses or responses with only exclusions
Consider running the following command to check for existing tests and identify areas that need additional coverage:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
rg -t go "func Test.*subjectFilterUnion" test/Length of output: 101
Script:
#!/bin/bash # Step 1: Find all Go test files in the repository fd -t f -e _test.go # Step 2: Search for test functions related to 'subjectFilterUnion' within the found test files fd -t f -e _test.go | xargs rg "func Test.*subjectFilterUnion"Length of output: 86
Script:
#!/bin/bash # Step 1: Find all Go test files in the repository fd -t f -e _test.go # Step 2: Search for any references to 'subjectFilterUnion' within the found test files fd -t f -e _test.go | xargs rg "subjectFilterUnion"Length of output: 1034
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- internal/engines/lookup.go (1 hunks)
- internal/engines/subjectFilter.go (10 hunks)
🧰 Additional context used
🔇 Additional comments (8)
internal/engines/lookup.go (2)
210-210: LGTM! Consistent use of theALLconstant.The use of the
ALLconstant here is consistent with its usage elsewhere in the method. This improves maintainability by centralizing the definition of the wildcard symbol.
Line range hint
1-324: Overall, the changes look good and align with the PR objectives.The implementation of the new
<>wildcard symbol and the exclusion mechanism has been done correctly. The code is well-structured and maintainable. A few minor suggestions have been made for further improvement:
- Adding a comment to explain the exclusion format.
- Simplifying a condition using the
ALLconstant.These changes successfully introduce the new wildcard representation and implement exclusions as intended.
internal/engines/subjectFilter.go (6)
23-24: LGTM: New wildcard constant introducedThe introduction of the
ALLconstant with the value"<>"is a good practice. It provides a clear, centralized definition for the new wildcard representation, which will improve code readability and maintainability.
282-282: LGTM: Updated wildcard usageThe change from
[]string{"*"}to[]string{ALL}correctly implements the new wildcard representation. This update ensures consistency with the newly introducedALLconstant.
404-404: LGTM: Consistent wildcard usageThe change from
[]string{"*"}to[]string{ALL}in this function maintains consistency with the new wildcard representation. This update aligns well with the changes made in other parts of the code.
Line range hint
1024-1031: LGTM: New helper function for wildcard detectionThe
containsWildcardfunction is a simple and effective helper for checking the presence of the new wildcard representation in a list of IDs. It correctly uses theALLconstant, ensuring consistency with the rest of the code.
Line range hint
892-920: LGTM: New exclusion function implemented correctlyThe new
subjectFilterExclusionfunction correctly implements the exclusion logic, handling wildcards in both left and right operands consistently with other functions. The error handling for the case of having only one function is a good safeguard.Consider adding inline comments to explain the logic for handling wildcards in left and right operands. This will improve code readability and maintainability.
Please add comprehensive unit tests for this new function, covering scenarios such as:
- Exclusion with no wildcards
- Exclusion with wildcard on the left side
- Exclusion with wildcard on the right side
- Exclusion with wildcards on both sides
- Edge cases like empty sets or sets with only wildcards
You can use the following command to check for existing tests and identify areas that need additional coverage:
rg -t go "func Test.*subjectFilterExclusion" test/
Line range hint
772-804: LGTM: Wildcard and exclusion handling for intersection implementedThe changes in this function correctly implement the wildcard
"<>"representation and exclusion functionality for intersection operations. The logic is consistent with the changes made insubjectFilterUnionand handles the more complex case of intersecting wildcards appropriately.Consider adding a code comment explaining the logic for wildcard intersection, particularly how exclusions are handled when a wildcard is encountered. This will improve code maintainability and help future developers understand the reasoning behind this implementation.
Please add comprehensive unit tests for this function, covering scenarios such as:
- Intersection of responses with only
"<>"- Intersection of
"<>"with regular IDs- Intersection of
"<>"with exclusions and regular IDs- Edge cases like empty responses or responses with only exclusions
You can use the following command to check for existing tests and identify areas that need additional coverage:
rg -t go "func Test.*subjectFilterIntersection" test/
Summary by CodeRabbit
New Features
<>for enhanced filtering capabilities.Bug Fixes
Documentation