Skip to content

add not/exists operator for properties filter#119

Merged
EtienneLt merged 4 commits into
mainfrom
add-exist-for-property-expert-rule
Jun 12, 2026
Merged

add not/exists operator for properties filter#119
EtienneLt merged 4 commits into
mainfrom
add-exist-for-property-expert-rule

Conversation

@EtienneLt

Copy link
Copy Markdown
Contributor

PR Summary

@EtienneLt EtienneLt self-assigned this Jun 11, 2026
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 64957163-2b00-4246-a3fa-9b34cba2ec74

📥 Commits

Reviewing files that changed from the base of the PR and between 8902bd8 and 2a2507a.

📒 Files selected for processing (1)
  • src/main/java/org/gridsuite/filter/wip/rule/PropertiesExpertRule.java

📝 Walkthrough

Walkthrough

This PR implements property existence checking in PropertiesExpertRule by adding null-handling logic for EXISTS and NOT_EXISTS operators, then adds comprehensive test coverage across all equipment types to validate the new behavior for both present and absent properties.

Changes

Property Existence Operators

Layer / File(s) Summary
Property existence operator null-handling
src/main/java/org/gridsuite/filter/expertfilter/expertrule/PropertiesExpertRule.java, src/main/java/org/gridsuite/filter/wip/rule/PropertiesExpertRule.java
OperatorType and Collections imports added. Constructor defaults null propertyValues to an empty immutable list; evaluateRule now checks the operator when propertyValue is null: returns true for NOT_EXISTS, false for EXISTS, and continues with existing logic for other operators.
Test coverage for existence operators across equipment types
src/test/java/org/gridsuite/filter/expertfilter/PropertiesExpertRuleTest.java
All equipment argument providers—substation, generator, line, load, shunt compensator, two-winding transformer, static var compensator, three-winding transformer, HVDC line, and boundary line—are expanded with EXISTS and NOT_EXISTS test cases validating true/false outcomes for matching vs. non-matching property names using null property values.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is empty and provides no information about the changeset, making it impossible to verify alignment with the actual code changes. Add a meaningful description explaining what the EXISTS and NOT_EXISTS operators do, why they were added, and how they affect the properties filter behavior.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding EXISTS and NOT_EXISTS operators to the properties filter, which aligns with modifications across all three modified files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@flomillot flomillot self-requested a review June 11, 2026 15:13

@flomillot flomillot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even completed the parameterized tests 💯

Signed-off-by: Etienne LESOT <[email protected]>
@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/java/org/gridsuite/filter/wip/rule/PropertiesExpertRule.java`:
- Around line 39-44: The constructor PropertiesExpertRule currently maps null
propertyValues to an empty list unconditionally which makes NOT_IN rules with
null/empty values match everything; change the constructor
(PropertiesExpertRule) to branch on operator (OperatorType): for EXISTS and
NOT_EXISTS allow null/empty by converting null to Collections.emptyList(), but
for IN and NOT_IN require a non-null, non-empty propertyValues and throw an
IllegalArgumentException (or similar) if missing/empty; keep the use of
List.copyOf for defensive copying when a non-empty list is provided.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 64957163-2b00-4246-a3fa-9b34cba2ec74

📥 Commits

Reviewing files that changed from the base of the PR and between 8902bd8 and 2a2507a.

📒 Files selected for processing (1)
  • src/main/java/org/gridsuite/filter/wip/rule/PropertiesExpertRule.java

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/java/org/gridsuite/filter/wip/rule/PropertiesExpertRule.java`:
- Around line 39-44: The constructor PropertiesExpertRule currently maps null
propertyValues to an empty list unconditionally which makes NOT_IN rules with
null/empty values match everything; change the constructor
(PropertiesExpertRule) to branch on operator (OperatorType): for EXISTS and
NOT_EXISTS allow null/empty by converting null to Collections.emptyList(), but
for IN and NOT_IN require a non-null, non-empty propertyValues and throw an
IllegalArgumentException (or similar) if missing/empty; keep the use of
List.copyOf for defensive copying when a non-empty list is provided.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 64957163-2b00-4246-a3fa-9b34cba2ec74

📥 Commits

Reviewing files that changed from the base of the PR and between 8902bd8 and 2a2507a.

📒 Files selected for processing (1)
  • src/main/java/org/gridsuite/filter/wip/rule/PropertiesExpertRule.java
🛑 Comments failed to post (1)
src/main/java/org/gridsuite/filter/wip/rule/PropertiesExpertRule.java (1)

39-44: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Guard propertyValues by operator to avoid silent match-all NOT_IN rules.

Line 43 currently converts null to empty for every operator. That makes malformed NOT_IN rules evaluate to true for any non-null property (because noneMatch on empty is true), which can silently over-select results. Keep null/empty tolerance only for EXISTS/NOT_EXISTS, and require non-empty values for IN/NOT_IN.

💡 Proposed fix
 `@Builder`
 public PropertiesExpertRule(FieldType field, OperatorType operator, String propertyName, List<String> propertyValues) {
     this.field = Objects.requireNonNull(field);
     this.operator = Objects.requireNonNull(operator);
     this.propertyName = Objects.requireNonNull(propertyName);
-    this.propertyValues = propertyValues == null ? Collections.emptyList() : List.copyOf(propertyValues);
+    if (operator == OperatorType.EXISTS || operator == OperatorType.NOT_EXISTS) {
+        this.propertyValues = Collections.emptyList();
+    } else {
+        List<String> values = List.copyOf(Objects.requireNonNull(propertyValues, "propertyValues is required for " + operator));
+        if (values.isEmpty()) {
+            throw new IllegalArgumentException("propertyValues must not be empty for " + operator);
+        }
+        this.propertyValues = values;
+    }
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/org/gridsuite/filter/wip/rule/PropertiesExpertRule.java` around
lines 39 - 44, The constructor PropertiesExpertRule currently maps null
propertyValues to an empty list unconditionally which makes NOT_IN rules with
null/empty values match everything; change the constructor
(PropertiesExpertRule) to branch on operator (OperatorType): for EXISTS and
NOT_EXISTS allow null/empty by converting null to Collections.emptyList(), but
for IN and NOT_IN require a non-null, non-empty propertyValues and throw an
IllegalArgumentException (or similar) if missing/empty; keep the use of
List.copyOf for defensive copying when a non-empty list is provided.

@EtienneLt EtienneLt merged commit ab31335 into main Jun 12, 2026
5 checks passed
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