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
This commit is contained in:
@@ -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}"
|
||||
);
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ class PRV_Ai_Visibility_Panel implements PRV_Dashboard_Panel {
|
||||
/**
|
||||
* Render the Chart.js visibility score trendline.
|
||||
*
|
||||
* @param array<int, array{run_id: string, captured_at: string, score: float}> $trendline
|
||||
* @param array<int, array{run_id: string, captured_at: string, score: float}> $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<string, array{label: string, cited: bool, our_position: int|null, top_domains: string[], model_count: int}> $standings
|
||||
* @param array<string, array{label: string, cited: bool, our_position: int|null, top_domains: string[], model_count: int}> $standings Per-peptide standing data.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
@@ -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 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user