Skip to content

Commit 5ae31e0

Browse files
ZviBaratzclaude
andauthored
fix(ego-lint): widen R-VER48-02 guard-window for distant version checks (#53)
## Summary - Increase R-VER48-02 `guard-window` from 3 to 10 to recognize PACKAGE_VERSION guards that appear far from the deprecated API call (e.g., cached in a variable then used in nested ternaries) - Add test fixture `version-guard-distant@test` reproducing the Dash to Panel false-positive pattern where the guard is 5-9 lines from the deprecated `Meta.disable_unredirect_for_display()` call ## Context In Dash to Panel's `src/utils.js`, the version-compat guard `Config.PACKAGE_VERSION >= '48'` is cached in a `v48` variable, then used in nested `if/else` ternaries. The deprecated `Meta.enable_unredirect_for_display()` and `Meta.disable_unredirect_for_display()` calls appear 5 and 9 lines after the guard respectively. With `guard-window: 3`, the sliding `deque` lookback had already evicted the guard line, causing false positives. Closes #39 Closes #42 ## Test plan - [x] New fixture `version-guard-distant@test` passes (R-VER48-02 suppressed) - [x] Existing fixture `version-guard-pkgver@test` still passes (close-range guard) - [x] Full test suite passes with zero regressions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f9c035b commit 5ae31e0

File tree

5 files changed

+46
-1
lines changed

5 files changed

+46
-1
lines changed

rules/patterns.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@
923923
fix: "Access via global.compositor instead of Meta directly"
924924
min-version: 48
925925
guard-pattern: "if\\s*\\(\\s*Meta\\.disable_unredirect|PACKAGE_VERSION.*['\"]4[89]|PACKAGE_VERSION.*['\"][5-9]"
926-
guard-window: 3
926+
guard-window: 10
927927

928928
- id: R-VER48-03
929929
pattern: "\\bCursorTracker\\.get_for_display\\b"

tests/assertions/dash-to-panel-fixes.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ assert_exit_code "exits with 0 (version guard suppresses R-VER48-02)" 0
1616
assert_output_not_contains "no FAIL for R-VER48-02 with PACKAGE_VERSION guard" "\[FAIL\].*R-VER48-02"
1717
echo ""
1818

19+
# --- version-guard-distant (R-VER48-02 guard-window with distant guard) ---
20+
echo "=== version-guard-distant ==="
21+
run_lint "version-guard-distant@test"
22+
assert_exit_code "exits with 0 (distant version guard suppresses R-VER48-02)" 0
23+
assert_output_not_contains "no FAIL for R-VER48-02 with distant PACKAGE_VERSION guard" "\[FAIL\].*R-VER48-02"
24+
echo ""
25+
1926
# --- deprecated-in-comments (skip-comments for R-DEPR-05/06) ---
2027
echo "=== deprecated-in-comments ==="
2128
run_lint "deprecated-in-comments@test"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SPDX-License-Identifier: GPL-2.0-or-later
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js';
2+
import Meta from 'gi://Meta';
3+
import * as Config from 'resource:///org/gnome/shell/misc/config.js';
4+
5+
let unredirectEnabled = true;
6+
7+
export default class DistantGuardExtension extends Extension {
8+
enable() {
9+
this._setDisplayUnredirect(true);
10+
}
11+
12+
_setDisplayUnredirect(enable) {
13+
let v48 = Config.PACKAGE_VERSION >= '48';
14+
15+
if (enable && !unredirectEnabled)
16+
v48
17+
? global.compositor.enable_unredirect()
18+
: Meta.enable_unredirect_for_display(global.display);
19+
else if (!enable && unredirectEnabled)
20+
v48
21+
? global.compositor.disable_unredirect()
22+
: Meta.disable_unredirect_for_display(global.display);
23+
24+
unredirectEnabled = enable;
25+
}
26+
27+
disable() {
28+
this._setDisplayUnredirect(false);
29+
}
30+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"uuid": "version-guard-distant@test",
3+
"name": "Distant Version Guard Test",
4+
"description": "Tests R-VER48-02 guard-window with guard far from deprecated call",
5+
"shell-version": ["48"],
6+
"url": "https://example.com"
7+
}

0 commit comments

Comments
 (0)