From f344b73c16f635f8b8e072e62d46d364e29e90dc Mon Sep 17 00:00:00 2001 From: peptiderepo <273788462+peptiderepo@users.noreply.github.com> Date: Sat, 13 Jun 2026 09:48:53 +0000 Subject: [PATCH] PHPCS: fix remaining violations (EscapeOutput, InterpolatedNotPrepared, missing @param) - Collapse multi-line RuntimeException throws to single line so phpcs:ignore EscapeOutput.ExceptionNotEscaped applies correctly (gateway-client, perplexity-provider, openrouter-provider) - Move phpcs:ignore InterpolatedNotPrepared from SQL string line to the get_results/get_var line where the violation fires (collector) - Add descriptions to @param trendline and @param standings in panel - Remove duplicate phpcs:ignore comment in collector Agent-Session: pr-vision rename v0.1.1 --- .../collector/class-prv-ai-visibility-collector.php | 9 +++------ includes/panel/class-prv-ai-visibility-panel.php | 4 ++-- includes/providers/class-prv-gateway-client.php | 12 ++++-------- includes/providers/class-prv-openrouter-provider.php | 5 ++--- includes/providers/class-prv-perplexity-provider.php | 6 ++---- 5 files changed, 13 insertions(+), 23 deletions(-) diff --git a/includes/collector/class-prv-ai-visibility-collector.php b/includes/collector/class-prv-ai-visibility-collector.php index 79fee94..0120b19 100644 --- a/includes/collector/class-prv-ai-visibility-collector.php +++ b/includes/collector/class-prv-ai-visibility-collector.php @@ -64,9 +64,8 @@ class PRV_Ai_Visibility_Collector implements PRV_Data_Collector { $table = PRV_Table_Manager::get_table_name(); // ── Trendline: one score per run_id ──────────────────────────── - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching + // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $run_rows = $wpdb->get_results( - // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared "SELECT run_id, MIN(captured_at) AS captured_at, SUM(cited) AS cited_count, COUNT(*) AS total_count, @@ -92,9 +91,8 @@ class PRV_Ai_Visibility_Collector implements PRV_Data_Collector { } // ── Standings: latest result per peptide ──────────────────────── - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching + // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $standing_rows = $wpdb->get_results( - // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared "SELECT peptide_slug, peptide_label, MAX(cited) AS cited, MIN(CASE WHEN cited=1 THEN our_position ELSE NULL END) AS our_position, @@ -119,9 +117,8 @@ class PRV_Ai_Visibility_Collector implements PRV_Data_Collector { } // ── Run metadata ──────────────────────────────────────────────── - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching + // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $last_run = $wpdb->get_var( - // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared "SELECT MAX(captured_at) FROM {$table}" ); diff --git a/includes/panel/class-prv-ai-visibility-panel.php b/includes/panel/class-prv-ai-visibility-panel.php index c0fc081..b8fe27a 100644 --- a/includes/panel/class-prv-ai-visibility-panel.php +++ b/includes/panel/class-prv-ai-visibility-panel.php @@ -87,7 +87,7 @@ class PRV_Ai_Visibility_Panel implements PRV_Dashboard_Panel { /** * Render the Chart.js visibility score trendline. * - * @param array $trendline + * @param array $trendline Trendline data points. * * @return void */ @@ -122,7 +122,7 @@ class PRV_Ai_Visibility_Panel implements PRV_Dashboard_Panel { /** * Render the per-peptide current standings table. * - * @param array $standings + * @param array $standings Per-peptide standing data. * * @return void */ diff --git a/includes/providers/class-prv-gateway-client.php b/includes/providers/class-prv-gateway-client.php index df6d21d..6b5855a 100644 --- a/includes/providers/class-prv-gateway-client.php +++ b/includes/providers/class-prv-gateway-client.php @@ -110,10 +110,8 @@ class PRV_Gateway_Client { } if ( $status >= 400 ) { - // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped - throw new \RuntimeException( - sprintf( 'PR Vision gateway HTTP %d: %s', $status, substr( $raw_body, 0, 300 ) ) - ); + // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- exception message, not HTML output + throw new \RuntimeException( sprintf( 'PR Vision gateway HTTP %d: %s', $status, substr( $raw_body, 0, 300 ) ) ); } $data = json_decode( $raw_body, true ); @@ -127,10 +125,8 @@ class PRV_Gateway_Client { remove_action( 'http_api_curl', $curl_filter, 99 ); } - // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped - throw new \RuntimeException( - sprintf( 'PR Vision: gateway failed after %d attempts. Last: %s', PRV_MAX_RETRIES, $last_error ) - ); + // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- exception message, not HTML output + throw new \RuntimeException( sprintf( 'PR Vision: gateway failed after %d attempts. Last: %s', PRV_MAX_RETRIES, $last_error ) ); } /** diff --git a/includes/providers/class-prv-openrouter-provider.php b/includes/providers/class-prv-openrouter-provider.php index ad9c02b..ce8f87f 100644 --- a/includes/providers/class-prv-openrouter-provider.php +++ b/includes/providers/class-prv-openrouter-provider.php @@ -169,9 +169,8 @@ class PRV_OpenRouter_Provider implements PRV_Probe_Provider { */ private function resolve_api_key(): string { if ( ! defined( 'PRV_OPENROUTER_API_KEY' ) || '' === PRV_OPENROUTER_API_KEY ) { - throw new \RuntimeException( - __( 'PRV_OPENROUTER_API_KEY constant is not defined. Add it to wp-config.php.', 'pr-vision' ) - ); + // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- exception message, not HTML output + throw new \RuntimeException( __( 'PRV_OPENROUTER_API_KEY constant is not defined. Add it to wp-config.php.', 'pr-vision' ) ); } return PRV_OPENROUTER_API_KEY; } diff --git a/includes/providers/class-prv-perplexity-provider.php b/includes/providers/class-prv-perplexity-provider.php index b6f5a53..ef22bc4 100644 --- a/includes/providers/class-prv-perplexity-provider.php +++ b/includes/providers/class-prv-perplexity-provider.php @@ -155,10 +155,8 @@ class PRV_Perplexity_Provider implements PRV_Probe_Provider { */ private function resolve_api_key(): string { if ( ! defined( 'PRV_OPENROUTER_API_KEY' ) || '' === PRV_OPENROUTER_API_KEY ) { - // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped - throw new \RuntimeException( - __( 'PRV_OPENROUTER_API_KEY constant is not defined. Add it to wp-config.php.', 'pr-vision' ) - ); + // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- exception message, not HTML output + throw new \RuntimeException( __( 'PRV_OPENROUTER_API_KEY constant is not defined. Add it to wp-config.php.', 'pr-vision' ) ); } return PRV_OPENROUTER_API_KEY; }