Skip to content

Conversation

@pranavgaikwad
Copy link
Contributor

@pranavgaikwad pranavgaikwad commented Nov 26, 2025

Summary by CodeRabbit

  • Refactoring

    • Improved condition parsing to carry provider-specific condition metadata through rule evaluation.
  • Bug Fixes

    • Symlinked directories are now excluded from directory scans to avoid treating them as files.
  • Chores

    • Updated an external analyzer dependency to a newer release.
  • Configuration

    • Tightened example rule conditions to require React references together with TSX file checks.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 26, 2025

Walkthrough

getConditions in the rule parser now returns an additional provider-specific conditions map and the parser accumulates/merges that map across "and"/"or"/default branches. The file-walking helper skips symlinked directories when enumerating non-directory entries.

Changes

Cohort / File(s) Summary
Parser return signature & propagation
parser/rule_parser.go
getConditions signature changed to add map[string][]provider.ConditionsByCap to its returns. All control paths (including "and", "or", and default provider branches) updated to receive, merge, and propagate the new providerConditions map; error and nil-return paths adjusted accordingly.
Symlink directory skip in walk
provider/lib.go
newCachedWalkDir now checks non-directory entries for symlinks that point to directories and skips adding those paths as files, preventing symlinked directories from being treated as regular files.
Module dependency bump
external-providers/generic-external-provider/go.mod
Bumped github.com/konveyor/analyzer-lsp require version to a newer alpha revision.
Rule examples updated
rule-example.yaml
Tightened rule conditions: replaced standalone nodejs.referenced: "React" with an and combining the nodejs reference and a builtin.filecontent TSX import check (with ignore: true on the TSX check).

Sequence Diagram(s)

sequenceDiagram
  participant RP as RuleParser
  participant GC as getConditions
  participant PC as ProviderConditionsMap

  RP->>GC: call getConditions(conditionsInterface)
  GC-->>RP: returns (conditionsList, providerClients, providerConditions, err)
  alt err != nil
    RP->>RP: handle error (propagate providerConditions where applicable)
  else
    RP->>PC: merge providerConditions into top-level provider map
    RP->>RP: continue condition composition ("and"/"or"/default)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–25 minutes

  • Pay attention to all return sites in parser/rule_parser.go to ensure the new map is always correctly initialized/returned on both success and error paths.
  • Verify merging logic for providerConditions across "and"/"or" branches preserves keys and avoids unintended overwrites.
  • Confirm symlink detection in provider/lib.go reliably distinguishes directory symlinks across platforms.

Possibly related PRs

Suggested reviewers

  • shawn-hurley
  • dymurray

Poem

🐰 I hop through rules, collecting each sign,
A fourth map of conditions now lives in the line.
Symlinked paths quietly fall from my map,
I nibble the code and leave no gap. ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main purpose of the changes—fixing how conditions are parsed from nested rules, which aligns with the signature update to getConditions and related propagation logic.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 96331f3 and d84e92c.

⛔ Files ignored due to path filters (1)
  • external-providers/generic-external-provider/go.sum is excluded by !**/*.sum
📒 Files selected for processing (4)
  • external-providers/generic-external-provider/go.mod (1 hunks)
  • parser/rule_parser.go (16 hunks)
  • provider/lib.go (1 hunks)
  • rule-example.yaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • parser/rule_parser.go
  • provider/lib.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: test
  • GitHub Check: test (windows-latest, windows, amd64)
  • GitHub Check: test (macos-latest, darwin, arm64)
  • GitHub Check: test (macos-latest, darwin, amd64)
  • GitHub Check: test (ubuntu-latest, linux, arm64)
  • GitHub Check: test (ubuntu-latest, linux, amd64)
  • GitHub Check: benchmark (windows-latest, windows)
  • GitHub Check: benchmark (ubuntu-latest, linux)
  • GitHub Check: benchmark (macos-latest, mac)
🔇 Additional comments (2)
external-providers/generic-external-provider/go.mod (1)

8-8: Version bump aligns with core parser/provider changes.

The pseudo-version update to analyzer-lsp reflects the fix for parsing nested rule conditions in the upstream module. The 5-day timestamp delta (2025-11-21 → 2025-11-26) aligns with the PR date and expected dependency updates.

rule-example.yaml (1)

477-483: Validates nested condition parsing with multi-provider "and" block.

The updated rule correctly demonstrates the fix by combining two provider conditions (nodejs.referenced and builtin.filecontent) in an "and" block. The ignore: true on the filecontent condition is a semantic choice that suppresses that provider's independent match output while still requiring its condition to be satisfied. This is a solid regression test for verifying the parser correctly merges conditions across nested logical operators.


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.

Copy link

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (1)
parser/rule_parser.go (1)

362-362: Consider restoring the more descriptive error message.

The error message was simplified to just "condition key must be a string", losing context about the ruleID and file path that would aid debugging.

If reverting is desired, the previous error likely included more context:

-return nil, nil, nil, fmt.Errorf("condition key must be a string")
+return nil, nil, nil, fmt.Errorf("condition key must be a string, ruleID: %s, file: %s", ruleID, filepath)

Note: The ruleID and filepath variables may need to be passed to getConditions if they're not currently in scope.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1397460 and 96331f3.

📒 Files selected for processing (2)
  • parser/rule_parser.go (16 hunks)
  • provider/lib.go (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
parser/rule_parser.go (2)
provider/provider.go (2)
  • ConditionsByCap (472-475)
  • InternalProviderClient (450-453)
engine/conditions.go (1)
  • ConditionEntry (43-49)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: test
  • GitHub Check: test (macos-latest, darwin, amd64)
  • GitHub Check: test (ubuntu-latest, linux, amd64)
  • GitHub Check: test (windows-latest, windows, amd64)
  • GitHub Check: test (macos-latest, darwin, arm64)
  • GitHub Check: test (ubuntu-latest, linux, arm64)
  • GitHub Check: benchmark (windows-latest, windows)
  • GitHub Check: benchmark (ubuntu-latest, linux)
  • GitHub Check: benchmark (macos-latest, mac)
🔇 Additional comments (4)
parser/rule_parser.go (3)

91-217: LGTM! Function signatures and accumulation logic are correct.

The LoadRules and LoadRule functions have been properly updated to handle the new providerConditions return value. The accumulation logic at lines 143-148 and 172-177 correctly merges conditions from nested rule sets.


372-395: LGTM! Condition accumulation in or/and branches is correct.

The provConditions map is properly accumulated from nested getConditions calls in both the "or" (lines 390-395) and "and" (lines 428-433) branches. The pattern ensures that provider conditions from nested rules are correctly propagated to the top level.

Also applies to: 408-433


627-808: LGTM! getConditions implementation is correct and complete.

The signature change has been properly implemented:

  • All error paths return nil for the new providerConditions map
  • Recursive calls to getConditions (lines 687, 717) correctly handle the new return value
  • Provider conditions are accumulated from nested "and" (lines 706-711) and "or" (lines 736-741) branches
  • The final return statement (line 807) includes all three return values

The implementation correctly propagates provider conditions through nested rule structures.

provider/lib.go (1)

301-306: I'm unable to clone the repository to access the codebase directly. However, based on the review comment provided, I can identify that the original concerns about symlink handling are reasonable and require manual verification.

Let me rewrite the review comment with the verification status:


Clarify intended behavior for symlinked directories in the symlink check (lines 301-306).

The code now skips symlinks that resolve to directories, preventing them from being counted as files. Before approving this change, the following points need clarification:

  1. Intentional behavior change? Is skipping symlinked directories a deliberate design decision and documented in the PR objectives?
  2. Broken symlink handling: When os.Stat() fails (e.g., broken symlink), the code continues and appends the symlink as a file. Confirm whether this is the intended behavior or if broken symlinks should also be skipped.

Verification needed:

  • Check test coverage for symlink handling in *_test.go files
  • Review PR description or related comments for intent and impact analysis
  • Ensure the change does not break existing functionality that may depend on symlinked directories being enumerable

@pranavgaikwad pranavgaikwad force-pushed the fix/parseRulesCorrectly branch from 1be31ba to d84e92c Compare November 26, 2025 22:03
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.

1 participant