$original_line) { $line_number = $line_num + 1; // Skip empty lines if (trim($original_line) === '') { continue; } // Check if line contains .is(':visible') pattern if (preg_match($pattern, $original_line, $matches, PREG_OFFSET_CAPTURE)) { $match_position = $matches[0][1]; // Check if there's a // comment before the match $comment_pos = strpos($original_line, '//'); if ($comment_pos !== false && $comment_pos < $match_position) { // The match is in a comment, skip it continue; } // Check if the match is inside a /* */ comment block (simplified check) // This is a basic check - for full accuracy would need to track multi-line comments $before_match = substr($original_line, 0, $match_position); if (str_contains($before_match, '/*') && !str_contains($before_match, '*/')) { // Likely inside a block comment continue; } $this->add_violation( $file_path, $line_number, "Use .is_visible() instead of .is(':visible') for jQuery visibility checks.", trim($original_line), "Replace .is(':visible') with .is_visible() for checking jQuery element visibility. " . "IMPORTANT: .is_visible() is a custom jQuery extension implemented in the RSpade framework " . "and is available throughout the codebase. It provides better performance and clearer intent " . "than the :visible selector. Example: use '$(selector).is_visible()' instead of '$(selector).is(':visible')'.", 'medium' ); } } } }