feat: add warning for mixed operators without parentheses#2786
feat: add warning for mixed operators without parentheses#2786ivanauth wants to merge 3 commits intoauthzed:mainfrom
Conversation
aa2be07 to
6a03a3d
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2786 +/- ##
==========================================
- Coverage 73.80% 73.75% -0.04%
==========================================
Files 493 493
Lines 59295 59447 +152
==========================================
+ Hits 43755 43841 +86
- Misses 12384 12438 +54
- Partials 3156 3168 +12 ☔ 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
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