Fix JS-JQUERY-VAR-01 and MANIFEST-FILENAME-01 false positives

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
root
2025-12-26 03:49:09 +00:00
parent aac7585b8c
commit fd7d3340f4
2 changed files with 33 additions and 3 deletions

View File

@@ -65,11 +65,19 @@ class JQueryVariableNaming_CodeQualityRule extends CodeQualityRule_Abstract
* jQuery methods that ALWAYS return scalar values
*/
private const SCALAR_METHODS = [
'index', 'size', 'length', 'get', 'toArray',
'index', 'size', 'get', 'toArray',
'serialize', 'serializeArray',
'is', 'hasClass', 'is_visible' // Custom RSpade methods
];
/**
* jQuery properties (not methods) that return scalar values
* These are accessed without parentheses: $el.length, not $el.length()
*/
private const SCALAR_PROPERTIES = [
'length',
];
public function check(string $file_path, string $contents, array $metadata = []): void
{
// Only check files in ./rsx/ directory
@@ -222,6 +230,15 @@ class JQueryVariableNaming_CodeQualityRule extends CodeQualityRule_Abstract
return 'scalar';
}
// Check if chain ENDS with a scalar property access (e.g., .length)
// Pattern: .property at end of chain (no parentheses, possibly followed by operators)
if (preg_match('/\.([a-zA-Z_][a-zA-Z0-9_]*)\s*(?:[|&+\-*\/%]|$|;)/', $chain, $prop_match)) {
$last_property = $prop_match[1];
if (in_array($last_property, self::SCALAR_PROPERTIES, true)) {
return 'scalar';
}
}
// Find the last method call in the chain
// Match patterns like .method() or .method(args)
// Also capture what's inside the parentheses

View File

@@ -59,7 +59,15 @@ class FilenameClassMatch_CodeQualityRule extends CodeQualityRule_Abstract
return;
}
// Check if framework developer mode is enabled
$is_framework_developer = env('IS_FRAMEWORK_DEVELOPER', false);
foreach ($files as $file => $metadata) {
// Skip backup/upstream files
if (str_ends_with($file, '.upstream') || str_ends_with($file, '.backup')) {
continue;
}
// Only check files in ./rsx or ./app/RSpade
$is_rsx = str_starts_with($file, 'rsx/');
$is_rspade = str_starts_with($file, 'app/RSpade/');
@@ -68,6 +76,11 @@ class FilenameClassMatch_CodeQualityRule extends CodeQualityRule_Abstract
continue;
}
// app/RSpade/ files only checked in framework developer mode
if ($is_rspade && !$is_framework_developer) {
continue;
}
$extension = $metadata['extension'] ?? '';
$filename = basename($file);