feat: add warning for mixed operators without parentheses#2786
feat: add warning for mixed operators without parentheses#2786ivanauth wants to merge 6 commits intoauthzed:mainfrom
Conversation
aa2be07 to
6a03a3d
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2786 +/- ##
==========================================
+ Coverage 73.49% 73.58% +0.10%
==========================================
Files 497 499 +2
Lines 59685 60325 +640
==========================================
+ Hits 43860 44387 +527
- Misses 12651 12734 +83
- Partials 3174 3204 +30 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@ivanauth this won't actually work in all cases, because expressions can cross multiple lines. Instead, this should likely be done by marking the expression during compilation with a piece of metadata, and having the warnings generator read that metadata |
|
Switched from source-scanning to compile-time metadata detection per review feedback. Added |
88ff553 to
6952dbd
Compare
e292e69 to
5c2b616
Compare
ebb6aa6 to
23d2a00
Compare
f5d430a to
87f6a1e
Compare
Add a lint warning when permission expressions mix operators (union, intersection, exclusion) at the same scope level without explicit parentheses (e.g., `viewer - blocked & editor`). The warning is suppressible via `// spicedb-ignore-warning: mixed-operators-without-parentheses`. Introduces NodeTypeParenthesizedExpression in the parser to track explicit parentheses in the AST, enabling accurate detection of mixed operators at the same scope level. Fixes authzed/zed#598
87f6a1e to
1742057
Compare
…perators-warning # Conflicts: # CHANGELOG.md
When writing permission expressions like
viewer - blocked & editor, it's easy to assume arithmetic-style precedence. But SpiceDB's actual precedence (exclusion binds loosest, then intersection, then union) can lead to unexpected behavior.This adds a lint warning that flags mixed operators at the same scope, nudging users to add parentheses and make their intent explicit.
Example:
The warning can be suppressed with:
Fixes authzed/zed#598