fix: correct malformed JS-001 validation logic
Fixed broken conditional logic in JavaScript validation that was causing false positives on every single line of JS files. Problem: - Malformed ternary expression with 'if' inside condition - 'else True' caused every line WITHOUT 'window.apiClient' to trigger - Result: 3,144 violations (mostly false positives) Solution: - Simplified conditional to check if 'window.apiClient' exists first - Then check if it's not in a comment - Clearer, more maintainable logic Results: - Before: 3,144 total violations (3,000+ false JS-001 violations) - After: 184 total violations (all legitimate) - JS-001 violations: 0 (correct - no actual window.apiClient usage) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -469,12 +469,10 @@ class ArchitectureValidator:
|
|||||||
|
|
||||||
# JS-001: Check for window.apiClient
|
# JS-001: Check for window.apiClient
|
||||||
for i, line in enumerate(lines, 1):
|
for i, line in enumerate(lines, 1):
|
||||||
if (
|
if "window.apiClient" in line:
|
||||||
"window.apiClient" in line
|
# Check if it's not in a comment
|
||||||
and "//" not in line[: line.find("window.apiClient")]
|
before_occurrence = line[: line.find("window.apiClient")]
|
||||||
if "window.apiClient" in line
|
if "//" not in before_occurrence:
|
||||||
else True
|
|
||||||
):
|
|
||||||
self._add_violation(
|
self._add_violation(
|
||||||
rule_id="JS-001",
|
rule_id="JS-001",
|
||||||
rule_name="Use apiClient directly",
|
rule_name="Use apiClient directly",
|
||||||
|
|||||||
Reference in New Issue
Block a user