Skip to content

Commit 62c5509

Browse files
ZviBaratzclaude
andauthored
fix(ego-lint): reduce Tiling Shell false positives (#22)
## Summary - **R-VER49-08/11 ternary guard**: Same-line `get_maximized ?` suppresses maximize/unmaximize flags warnings — these are intentional version-compat shims - **Minified JS threshold**: Require 3+ lines >500 chars instead of 1 — single long lines in compiled TypeScript are not minification Closes #16 ## Test plan - [x] Updated fixture: `gnome49-compat@test` with ternary maximize/unmaximize methods - [x] Updated fixture: `minified-js@test` with 3 long lines (still triggers) - [x] Assertions verify: R-VER49-08/11 suppressed with ternary guard, minified-js still detected - [x] `bash tests/run-tests.sh` passes (512 assertions) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e46e2df commit 62c5509

File tree

9 files changed

+58
-6
lines changed

9 files changed

+58
-6
lines changed

rules/patterns.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,8 @@
10571057
category: version-compat
10581058
fix: "Call window.set_maximize_flags(flags) then window.maximize()"
10591059
min-version: 49
1060+
guard-pattern: "get_maximized\\s*\\?"
1061+
guard-window: 1
10601062

10611063
- id: R-VER49-09
10621064
pattern: "\\bAppMenuButton\\b"
@@ -1084,6 +1086,8 @@
10841086
category: version-compat
10851087
min-version: 49
10861088
fix: "Call unmaximize() without the MaximizeFlags parameter"
1089+
guard-pattern: "get_maximized\\s*\\?"
1090+
guard-window: 1
10871091

10881092
# --- GNOME 50 migration (version-gated) ---
10891093
# GNOME 50 removed X11 support and associated APIs.

skills/ego-lint/references/rules-reference.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2230,7 +2230,8 @@ Rules for APIs removed or changed in specific GNOME Shell versions. These rules
22302230
- **Rule**: `maximize()` lost the `MaximizeFlags` parameter in GNOME 49.
22312231
- **Rationale**: Passing `MaximizeFlags` to `maximize()` will throw in GNOME 49.
22322232
- **Fix**: Call `window.set_maximize_flags(flags)` first, then `window.maximize()`.
2233-
- **Tested by**: `tests/fixtures/gnome49-maximize@test/`
2233+
- **Guard**: Suppressed when `get_maximized ?` appears on the same line (ternary version-compat pattern).
2234+
- **Tested by**: `tests/fixtures/gnome49-compat@test/`
22342235

22352236
### R-VER49-09: AppMenuButton removal
22362237
- **Severity**: blocking
@@ -2556,6 +2557,7 @@ Rules for APIs removed or changed in specific GNOME Shell versions. These rules
25562557
- **Rule**: `MaximizeFlags` parameter was removed from `unmaximize()` in GNOME 49.
25572558
- **Rationale**: The `unmaximize()` method no longer accepts a flags parameter.
25582559
- **Fix**: Call `unmaximize()` without the `MaximizeFlags` parameter.
2560+
- **Guard**: Suppressed when `get_maximized ?` appears on the same line (ternary version-compat pattern).
25592561
25602562
---
25612563

skills/ego-lint/scripts/ego-lint.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,12 @@ for f in "$EXT_DIR"/*.js; do
421421
continue
422422
fi
423423

424-
# Check for any line > 500 chars (strong minification signal)
425-
if awk 'length > 500 { found=1; exit } END { exit !found }' "$f" 2>/dev/null; then
426-
minified_files+=" $rel_path (lines > 500 chars)"$'\n'
424+
# Check for lines > 500 chars — need 3+ such lines to flag as minified.
425+
# A single long line (e.g., keyboard constant chain) in an otherwise
426+
# readable file is not minification.
427+
long_line_count=$(awk 'length > 500 { n++ } END { print n+0 }' "$f" 2>/dev/null || true)
428+
if [[ "$long_line_count" -ge 3 ]]; then
429+
minified_files+=" $rel_path ($long_line_count lines > 500 chars)"$'\n'
427430
fi
428431
done
429432
if [[ -d "$EXT_DIR/lib" ]]; then
@@ -433,8 +436,9 @@ if [[ -d "$EXT_DIR/lib" ]]; then
433436
minified_files+=" $rel_path (webpack bundle)"$'\n'
434437
continue
435438
fi
436-
if awk 'length > 500 { found=1; exit } END { exit !found }' "$f" 2>/dev/null; then
437-
minified_files+=" $rel_path (lines > 500 chars)"$'\n'
439+
long_line_count=$(awk 'length > 500 { n++ } END { print n+0 }' "$f" 2>/dev/null || true)
440+
if [[ "$long_line_count" -ge 3 ]]; then
441+
minified_files+=" $rel_path ($long_line_count lines > 500 chars)"$'\n'
438442
fi
439443
done < <(find "$EXT_DIR/lib" -name '*.js' -print0 2>/dev/null)
440444
fi

tests/fixtures/gnome49-compat@test/extension.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ export default class Gnome49Test extends Extension {
99
this._tap = new Clutter.TapAction();
1010
}
1111

12+
// Ternary version-compat guard: should NOT trigger R-VER49-08/11
13+
_maximizeCompat(window) {
14+
window.get_maximized ? window.maximize(Meta.MaximizeFlags.BOTH) : window.maximize();
15+
}
16+
17+
_unmaximizeCompat(window) {
18+
window.get_maximized ? window.unmaximize(Meta.MaximizeFlags.BOTH) : window.unmaximize();
19+
}
20+
1221
disable() {
1322
this._click = null;
1423
this._tap = null;
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

tests/fixtures/minified-boundary@test/extension.js

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"uuid": "minified-boundary@test",
3+
"name": "Minified Boundary Test",
4+
"description": "Tests that 2 long lines do not trigger minified-js detection",
5+
"shell-version": ["48"],
6+
"url": "https://example.com"
7+
}

tests/fixtures/minified-js@test/extension.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/run-tests.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,12 @@ assert_exit_code "exits with 1 (has failures)" 1
191191
assert_output_contains "fails on minified JS" "\[FAIL\].*minified-js"
192192
echo ""
193193

194+
# --- minified-boundary (2 long lines — below threshold) ---
195+
echo "=== minified-boundary ==="
196+
run_lint "minified-boundary@test"
197+
assert_output_not_contains "no minified-js with only 2 long lines" "\[FAIL\].*minified-js"
198+
echo ""
199+
194200
# --- init-time-safety ---
195201
echo "=== init-time-safety ==="
196202
run_lint "init-time-safety@test"
@@ -428,6 +434,8 @@ assert_exit_code "exits with 1 (has failures)" 1
428434
assert_output_contains "fails on Meta.Rectangle" "\[FAIL\].*R-VER49-01"
429435
assert_output_contains "fails on Clutter.ClickAction" "\[FAIL\].*R-VER49-02"
430436
assert_output_contains "fails on Clutter.TapAction" "\[FAIL\].*R-VER49-03"
437+
assert_output_not_contains "no R-VER49-08 with ternary guard" "\[FAIL\].*R-VER49-08"
438+
assert_output_not_contains "no R-VER49-11 with ternary guard" "\[FAIL\].*R-VER49-11"
431439
echo ""
432440

433441
# --- gnome46-extras ---

0 commit comments

Comments
 (0)