Skip to content

Commit eb94d6d

Browse files
ZviBaratzclaude
andcommitted
docs(ego-lint): update rule docs and docstrings for isLocked exemption
Sync rules-reference.md and check-quality.py docstrings with the behavioral changes: R-QUAL-02 now only flags currentMode comparisons (isLocked exempt), session-modes-consistency narrowed to currentMode, and R-QUAL-11 threshold updated from 40% to 50%. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 84dada3 commit eb94d6d

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -921,9 +921,9 @@ Heuristic rules that detect code patterns commonly seen in AI-generated or over-
921921
### R-QUAL-02: Impossible state checks
922922
- **Severity**: advisory
923923
- **Checked by**: check-quality.py
924-
- **Rule**: Extension code should not check for states that are impossible given its configuration. For example, checking `Main.sessionMode.isLocked` without declaring `unlock-dialog` in `session-modes`.
925-
- **Rationale**: If the extension does not declare `unlock-dialog` in `session-modes`, it is never active on the lock screen, so checking lock state is dead code. This pattern is common in AI-generated extensions that copy-paste lock-screen handling without understanding when it applies.
926-
- **Fix**: Either add `"unlock-dialog"` to `session-modes` in `metadata.json` (if lock-screen support is intended) or remove the lock-state checking code.
924+
- **Rule**: Extension code should not check for states that are impossible given its configuration. For example, comparing `Main.sessionMode.currentMode` with `'unlock-dialog'` without declaring `unlock-dialog` in `session-modes`. Note: `sessionMode.isLocked` is exempt — reading lock state is always a defensive guard pattern, not evidence of lock screen functionality.
925+
- **Rationale**: If the extension does not declare `unlock-dialog` in `session-modes`, it is never active on the lock screen, so checking `currentMode` against lock-screen values is dead code. This pattern is common in AI-generated extensions that copy-paste lock-screen handling without understanding when it applies.
926+
- **Fix**: Either add `"unlock-dialog"` to `session-modes` in `metadata.json` (if lock-screen support is intended) or remove the `currentMode` comparison code.
927927

928928
### R-QUAL-03: Over-engineered async coordination
929929
- **Severity**: advisory
@@ -1561,7 +1561,7 @@ destroy() {
15611561
### R-QUAL-11: Comment Density
15621562
- **Severity**: advisory
15631563
- **Checked by**: check-quality.py
1564-
- **Rule**: Flags files where >40% of lines (after first 10) are comments.
1564+
- **Rule**: Flags files where >50% of lines (after first 10) are comments.
15651565
- **Rationale**: Excessive comments explaining obvious code is a strong AI slop signal.
15661566
- **Fix**: Remove redundant comments. Only keep comments that explain non-obvious logic or API quirks.
15671567
- **Tested by**: `tests/fixtures/quality-signals@test/`
@@ -1952,7 +1952,7 @@ Rules for APIs removed or changed in specific GNOME Shell versions. These rules
19521952
### metadata/session-modes-consistency: SessionMode usage without declaration
19531953
- **Severity**: advisory
19541954
- **Checked by**: check-metadata.py
1955-
- **Rule**: Warns if the extension code references `Main.sessionMode.currentMode` or `sessionMode.isLocked` but `metadata.json` does not declare `session-modes` with `unlock-dialog`.
1955+
- **Rule**: Warns if the extension code references `Main.sessionMode.currentMode` but `metadata.json` does not declare `session-modes` with `unlock-dialog`. Note: `sessionMode.isLocked` is exempt — reading lock state is a defensive guard, not evidence of lock screen usage.
19561956
- **Rationale**: Code that checks session mode without the proper declaration is either dead code (the extension won't run in lock screen mode) or a misunderstanding of the lifecycle.
19571957
- **Fix**: Either add `"session-modes": ["user", "unlock-dialog"]` to metadata.json, or remove the session mode checks from the code.
19581958

skills/ego-lint/scripts/check-quality.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
Performs structural analysis that goes beyond simple pattern matching:
77
- Excessive try-catch density
8-
- Impossible state checks (isLocked without lock session-mode)
8+
- Impossible state checks (currentMode unlock-dialog without lock session-mode)
99
- Over-engineered async coordination (_pendingDestroy + _initializing)
1010
- Module-level mutable state
1111
- Empty catch blocks
@@ -114,7 +114,7 @@ def check_try_catch_density(ext_dir, js_files):
114114

115115

116116
def check_impossible_state(ext_dir, js_files):
117-
"""R-QUAL-02: Flag isLocked/unlock-dialog checks without matching session-modes."""
117+
"""R-QUAL-02: Flag currentMode unlock-dialog checks without matching session-modes."""
118118
session_modes = get_session_modes(ext_dir)
119119
# If session-modes absent or ["user"], extension doesn't run on lock screen
120120
has_lock = (isinstance(session_modes, list) and

0 commit comments

Comments
 (0)