diff --git a/app/RSpade/CodeQuality/Rules/JavaScript/JQueryVariableNaming_CodeQualityRule.php b/app/RSpade/CodeQuality/Rules/JavaScript/JQueryVariableNaming_CodeQualityRule.php index 561e54769..4485996e2 100644 --- a/app/RSpade/CodeQuality/Rules/JavaScript/JQueryVariableNaming_CodeQualityRule.php +++ b/app/RSpade/CodeQuality/Rules/JavaScript/JQueryVariableNaming_CodeQualityRule.php @@ -65,10 +65,18 @@ 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 { @@ -216,12 +224,21 @@ class JQueryVariableNaming_CodeQualityRule extends CodeQualityRule_Abstract if (empty($chain)) { return 'jquery'; // No methods means original jQuery object } - + // Array access [0] or [index] returns DOM element (scalar) if (preg_match('/^\[[\d]+\]/', $chain)) { 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 diff --git a/app/RSpade/CodeQuality/Rules/Manifest/FilenameClassMatch_CodeQualityRule.php b/app/RSpade/CodeQuality/Rules/Manifest/FilenameClassMatch_CodeQualityRule.php index 7cc0fadc1..8e30e5a61 100644 --- a/app/RSpade/CodeQuality/Rules/Manifest/FilenameClassMatch_CodeQualityRule.php +++ b/app/RSpade/CodeQuality/Rules/Manifest/FilenameClassMatch_CodeQualityRule.php @@ -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);