Commit 614883e
fix(ego-lint): suppress R-VER46-01/02 for ShellVersion-guarded else branches (#151)
## Problem
`R-VER46-01` (`add_actor`) and `R-VER46-02` (`remove_actor`) fire as
false positives when the deprecated API is called inside an `else {}`
branch guarded by a `ShellVersion` version check:
\`\`\`js
const ShellVersion = parseFloat(Config.PACKAGE_VERSION);
if (ShellVersion >= 46) {
parent.remove_child(actor); // modern path
} else {
parent.remove_actor(actor); // ← R-VER46-02 was firing here (FP)
}
\`\`\`
This pattern is used by caffeine (`extension.js:721, 829`) and
hara-hachi-bu, and is entirely correct — `remove_actor()` only runs on
GNOME < 46 where it still exists.
## Root Cause
The existing `guard-pattern` for both rules only matched feature-check
guards like `if (obj.remove_actor)`, not `ShellVersion`-based version
conditionals.
## Fix
Extend the `guard-pattern` regex for R-VER46-01 and R-VER46-02 with
`|\\bShellVersion\\b` and set `guard-window: 5`. This causes the
backward-scan to skip the match when `ShellVersion` appears within the
preceding 5 lines — covering all typical 3–4 line if/else version
guards.
The existing guard for feature-check patterns is preserved (regex
alternation).
## Tests
- New fixture `version-guard-remove-actor@test`: verifies both
R-VER46-01 and R-VER46-02 produce no FAIL or WARN on
ShellVersion-guarded else branches
- Existing `gnome46-compat@test`: unchanged — unguarded
`add_actor`/`remove_actor` still produces FAIL (true positives
preserved)
- Net change: +4 passing assertions, 0 regressions (567→571 pass, 125
fail unchanged)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Solomon <sol@nanoclaw.dev>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent fc10806 commit 614883e
File tree
4 files changed
+54
-2
lines changed- rules
- tests
- fixtures/version-guard-remove-actor@test
4 files changed
+54
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
854 | 854 | | |
855 | 855 | | |
856 | 856 | | |
857 | | - | |
| 857 | + | |
| 858 | + | |
858 | 859 | | |
859 | 860 | | |
860 | 861 | | |
| |||
865 | 866 | | |
866 | 867 | | |
867 | 868 | | |
868 | | - | |
| 869 | + | |
| 870 | + | |
869 | 871 | | |
870 | 872 | | |
871 | 873 | | |
| |||
Lines changed: 34 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
474 | 474 | | |
475 | 475 | | |
476 | 476 | | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
477 | 486 | | |
478 | 487 | | |
479 | 488 | | |
| |||
0 commit comments