$line) { $line_number = $line_num + 1; // Skip comments using sanitized version if (isset($sanitized_lines[$line_num])) { $sanitized_trimmed = trim($sanitized_lines[$line_num]); if (empty($sanitized_trimmed)) { continue; // Skip empty/comment lines } } // Check for Rsx.on('ready') pattern if (preg_match('/\bRsx\s*\.\s*on\s*\(\s*[\'"]ready[\'"]/i', $line)) { $this->add_violation( $file_path, $line_number, "Rsx.on('ready') is deprecated. Use ES6 class lifecycle methods instead.", trim($line), InitializationSuggestions::get_user_suggestion(), 'high' ); } // Check for framework methods (forbidden in user code) $framework_methods = [ '_on_framework_core_define', '_on_framework_core_init', '_on_framework_module_define', '_on_framework_module_init' ]; foreach ($framework_methods as $method) { if (preg_match('/\bstatic\s+(async\s+)?' . preg_quote($method) . '\s*\(\s*\)/', $line)) { $this->add_violation( $file_path, $line_number, "Framework initialization method '{$method}' cannot be used in user code.", trim($line), InitializationSuggestions::get_user_suggestion(), 'critical' ); } } // Check for jQuery ready patterns (handled by DocumentReadyRule but add context here) if (preg_match('/\$\s*\(\s*document\s*\)\s*\.\s*ready\s*\(/', $line) || preg_match('/\$\s*\(\s*function\s*\(/', $line)) { $this->add_violation( $file_path, $line_number, "jQuery ready patterns are not allowed. Use ES6 class lifecycle methods.", trim($line), InitializationSuggestions::get_user_suggestion(), 'high' ); } } } }