Skip to content

Commit 1a58b06

Browse files
ZviBaratzclaude
andauthored
fix(ego-lint): expand R-SLOP-24 guard for system schema identifiers (#139)
## Summary - Expand R-SLOP-24 guard-pattern to recognize bare system schema substrings (`desktop.`, `shell.app-switcher`) and `_SCHEMA` constant names - Add test fixture `system-schema-bare@test` with three suppression cases (bare `desktop.interface`, `_SCHEMA` constant, bare `shell.app-switcher`) - Update rules-reference.md Guard documentation - Reclassify dash-to-panel annotation from `fp` to `resolved` Closes #138 ## Test plan - [x] `bash tests/run-tests.sh` — 742 passed, 0 failed - [x] `ego-lint system-schema-bare@test` — no R-SLOP-24 warnings - [x] `ego-lint system-gsettings@test` — no regression - [x] `ego-lint system-gsettings-multiline@test` — no regression 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4aaf615 commit 1a58b06

File tree

7 files changed

+56
-4
lines changed

7 files changed

+56
-4
lines changed

field-tests/annotations/dash-to-panel.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ findings:
7272
notes: "File I/O not disclosed"
7373
# WARNs — False Positives
7474
- id: "R-SLOP-24::new Gio.Settings for system schemas"
75-
classification: fp
76-
notes: "5 hits — desktop.interface, desktop.notifications, shell.app-switcher, KEYBINDINGS_SCHEMA. Correct API for system schemas."
75+
classification: resolved
76+
notes: "5 hits — desktop.interface, desktop.notifications, shell.app-switcher, KEYBINDINGS_SCHEMA. Already suppressed by existing guard-window-forward: 5 mechanism. PR #139 adds additional coverage for edge cases (enumerated _SCHEMA constants, string-anchored desktop. guard)."
7777
- id: "R-SLOP-01::JSDoc despite provenance score 4"
7878
classification: expected
7979
notes: "5 hits — suppressed by provenance post-filter (score 4 >= 3 threshold). Fixed in deferred approach."

rules/patterns.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@
694694
message: "new Gio.Settings() is incorrect in GNOME 45+; use this.getSettings() from Extension base class"
695695
category: ai-slop
696696
fix: "Use this.getSettings() in Extension subclass or this.getSettings() in ExtensionPreferences"
697-
guard-pattern: "schema.*org\\.gnome\\.(?!shell\\.extensions\\.)|KEYBINDINGS_SCHEMA"
697+
guard-pattern: "schema.*org\\.gnome\\.(?!shell\\.extensions\\.)|['\"]desktop\\.|shell\\.app-switcher|(?:KEYBINDINGS|NOTIFICATIONS|DESKTOP|INTERFACE|WM|MUTTER|APP_SWITCHER)_SCHEMA"
698698
guard-window-forward: 5
699699
exclude-dirs: ["service"]
700700

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2233,7 +2233,7 @@ Rules for APIs removed or changed in specific GNOME Shell versions. These rules
22332233
- **Rule**: `new Gio.Settings()` should not be used in GNOME 45+ extensions.
22342234
- **Rationale**: The `Extension` base class provides `this.getSettings()` which uses the correct schema path automatically. Manually constructing `Gio.Settings` requires specifying the schema ID and may use the wrong compiled schema path.
22352235
- **Fix**: Use `this.getSettings()` in the Extension subclass, or pass a schema ID: `this.getSettings('org.gnome.shell.extensions.my-ext')`.
2236-
- **Guard**: Suppressed when `schema.*org.gnome.` (excluding `shell.extensions.`) or `KEYBINDINGS_SCHEMA` appears on the match line or within a 5-line forward window. Also skipped in `service/` directories.
2236+
- **Guard**: Suppressed when `schema.*org.gnome.` (excluding `shell.extensions.`), string-literal-anchored system schema substrings (`'desktop.` or `"desktop.`), bare `shell.app-switcher`, or enumerated system-schema constants (`KEYBINDINGS_SCHEMA`, `NOTIFICATIONS_SCHEMA`, `DESKTOP_SCHEMA`, `INTERFACE_SCHEMA`, `WM_SCHEMA`, `MUTTER_SCHEMA`, `APP_SWITCHER_SCHEMA`) appear on the match line or within a 5-line forward window. The `desktop.` anchor requires a quote prefix to avoid matching property-access contexts like `this.desktop.theme`. Also skipped in `service/` directories.
22372237

22382238
### R-SLOP-25: Main.extensionManager.enable/disable
22392239
- **Severity**: advisory

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,12 @@ echo "=== system-gsettings-deep ==="
5050
run_lint "system-gsettings-deep@test"
5151
assert_output_not_contains "R-SLOP-24 suppressed for deep multiline system schema" "\[WARN\].*R-SLOP-24"
5252
echo ""
53+
54+
# --- system-schema-bare (R-SLOP-24 guard for bare system schema identifiers) ---
55+
echo "=== system-schema-bare ==="
56+
run_lint "system-schema-bare@test"
57+
assert_output_not_contains "R-SLOP-24 suppressed for bare desktop schema" "\[WARN\].*R-SLOP-24.*desktop\.interface"
58+
assert_output_not_contains "R-SLOP-24 suppressed for NOTIFICATIONS_SCHEMA constant" "\[WARN\].*R-SLOP-24.*NOTIFICATIONS_SCHEMA"
59+
assert_output_not_contains "R-SLOP-24 suppressed for shell.app-switcher" "\[WARN\].*R-SLOP-24.*app-switcher"
60+
assert_output_contains "R-SLOP-24 still fires for extension-owned schema" "\[WARN\].*R-SLOP-24"
61+
echo ""
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: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import Gio from 'gi://Gio';
2+
import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js';
3+
4+
const NOTIFICATIONS_SCHEMA = 'org.gnome.desktop.notifications';
5+
6+
export default class BareSchemaExtension extends Extension {
7+
enable() {
8+
// Bare system schema substring — should NOT trigger R-SLOP-24
9+
this._iface = new Gio.Settings({
10+
schema_id: 'desktop.interface',
11+
});
12+
13+
// _SCHEMA constant — should NOT trigger R-SLOP-24
14+
this._notif = new Gio.Settings({
15+
schema_id: NOTIFICATIONS_SCHEMA,
16+
});
17+
18+
// Bare shell system schema — should NOT trigger R-SLOP-24
19+
this._switcher = new Gio.Settings({
20+
schema_id: 'shell.app-switcher',
21+
});
22+
23+
// Extension-owned schema — SHOULD trigger R-SLOP-24
24+
this._own = new Gio.Settings({
25+
schema_id: 'org.gnome.shell.extensions.myext',
26+
});
27+
}
28+
29+
disable() {
30+
this._iface = null;
31+
this._notif = null;
32+
this._switcher = null;
33+
this._own = null;
34+
}
35+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"uuid": "system-schema-bare@test",
3+
"name": "Bare System Schema Test",
4+
"description": "Tests R-SLOP-24 guard for system schema identifiers without org.gnome prefix",
5+
"shell-version": ["48"],
6+
"url": "https://example.com"
7+
}

0 commit comments

Comments
 (0)