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,22 +469,20 @@ 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(
|
||||||
):
|
rule_id="JS-001",
|
||||||
self._add_violation(
|
rule_name="Use apiClient directly",
|
||||||
rule_id="JS-001",
|
severity=Severity.WARNING,
|
||||||
rule_name="Use apiClient directly",
|
file_path=file_path,
|
||||||
severity=Severity.WARNING,
|
line_number=i,
|
||||||
file_path=file_path,
|
message="Use apiClient directly instead of window.apiClient",
|
||||||
line_number=i,
|
context=line.strip(),
|
||||||
message="Use apiClient directly instead of window.apiClient",
|
suggestion="Replace window.apiClient with apiClient",
|
||||||
context=line.strip(),
|
)
|
||||||
suggestion="Replace window.apiClient with apiClient",
|
|
||||||
)
|
|
||||||
|
|
||||||
# JS-002: Check for console usage
|
# JS-002: Check for console usage
|
||||||
for i, line in enumerate(lines, 1):
|
for i, line in enumerate(lines, 1):
|
||||||
|
|||||||
Reference in New Issue
Block a user