Skip to content

Commit 64b8595

Browse files
authored
fix: clean remaining lint blockers (#2164)
* fix: clean remaining lint blockers * fix: address lint warnings in touched files
1 parent cec034d commit 64b8595

6 files changed

Lines changed: 96 additions & 26 deletions

File tree

inc/Abilities/AgentCall/AgentCallAbility.php

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,18 +221,56 @@ private function sendWebhook( string $url, string $task, array $context, string
221221
);
222222

223223
if ( is_wp_error( $response ) ) {
224-
do_action( 'datamachine_log', 'error', 'Agent call webhook request failed', array( 'url' => $this->sanitizeUrlForLog( $url ), 'error' => $response->get_error_message() ) );
225-
return array( 'success' => false, 'url' => $this->sanitizeUrlForLog( $url ), 'error' => $response->get_error_message() );
224+
do_action(
225+
'datamachine_log',
226+
'error',
227+
'Agent call webhook request failed',
228+
array(
229+
'url' => $this->sanitizeUrlForLog( $url ),
230+
'error' => $response->get_error_message(),
231+
)
232+
);
233+
return array(
234+
'success' => false,
235+
'url' => $this->sanitizeUrlForLog( $url ),
236+
'error' => $response->get_error_message(),
237+
);
226238
}
227239

228240
$status_code = wp_remote_retrieve_response_code( $response );
229241
if ( $status_code >= 200 && $status_code < 300 ) {
230-
do_action( 'datamachine_log', 'info', 'Agent call webhook sent successfully', array( 'url' => $this->sanitizeUrlForLog( $url ), 'status_code' => $status_code ) );
231-
return array( 'success' => true, 'url' => $this->sanitizeUrlForLog( $url ), 'status_code' => $status_code );
242+
do_action(
243+
'datamachine_log',
244+
'info',
245+
'Agent call webhook sent successfully',
246+
array(
247+
'url' => $this->sanitizeUrlForLog( $url ),
248+
'status_code' => $status_code,
249+
)
250+
);
251+
return array(
252+
'success' => true,
253+
'url' => $this->sanitizeUrlForLog( $url ),
254+
'status_code' => $status_code,
255+
);
232256
}
233257

234-
do_action( 'datamachine_log', 'warning', 'Agent call webhook received non-success response', array( 'url' => $this->sanitizeUrlForLog( $url ), 'status_code' => $status_code, 'response_body' => wp_remote_retrieve_body( $response ) ) );
235-
return array( 'success' => false, 'url' => $this->sanitizeUrlForLog( $url ), 'status_code' => $status_code, 'error' => 'Webhook returned non-success status code: ' . $status_code );
258+
do_action(
259+
'datamachine_log',
260+
'warning',
261+
'Agent call webhook received non-success response',
262+
array(
263+
'url' => $this->sanitizeUrlForLog( $url ),
264+
'status_code' => $status_code,
265+
'response_body' => wp_remote_retrieve_body( $response ),
266+
)
267+
);
268+
return array(
269+
'success' => false,
270+
'url' => $this->sanitizeUrlForLog( $url ),
271+
'status_code' => $status_code,
272+
'error' => 'Webhook returned non-success status code: ' . $status_code,
273+
);
236274
}
237275

238276
/**

inc/Abilities/Email/EmailAbilities.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ public function executeReply( array $input ): array {
520520
global $phpmailer;
521521
$error = 'wp_mail() returned false';
522522
if ( isset( $phpmailer ) && $phpmailer instanceof \PHPMailer\PHPMailer\PHPMailer ) {
523-
$error = $phpmailer->ErrorInfo ?: $error;
523+
$error = $phpmailer->ErrorInfo ? $phpmailer->ErrorInfo : $error;
524524
}
525525

526526
return array(
@@ -619,14 +619,16 @@ public function executeFlag( array $input ): array {
619619

620620
return array(
621621
'success' => true,
622-
'message' => sprintf( 'Flag %s %s on UID %d', $flag, $action === 'clear' ? 'cleared' : 'set', $uid ),
622+
'message' => sprintf( 'Flag %s %s on UID %d', $flag, 'clear' === $action ? 'cleared' : 'set', $uid ),
623623
);
624624
}
625625

626626
/**
627627
* Test the IMAP connection with stored credentials.
628628
*/
629629
public function executeTestConnection( array $input ): array {
630+
unset( $input );
631+
630632
if ( ! function_exists( 'imap_open' ) ) {
631633
return array(
632634
'success' => false,

inc/Abilities/Fetch/FetchEmailAbility.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,9 @@ private function fetchBody( $connection, int $uid ): string {
563563
private function decodeBody( string $body, int $encoding ): string {
564564
switch ( $encoding ) {
565565
case 3: // BASE64.
566-
return base64_decode( $body, true ) ?: $body;
566+
// phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode -- Decodes MIME transfer encoding, not executable payloads.
567+
$decoded_body = base64_decode( $body, true );
568+
return false !== $decoded_body ? $decoded_body : $body;
567569
case 4: // QUOTED-PRINTABLE.
568570
return quoted_printable_decode( $body );
569571
case 1: // 8BIT.

inc/Engine/AI/System/Tasks/AgentCallTask.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,16 @@ private function resolveQueuedInput( int $jobId, array $params ): ?array {
174174
}
175175
}
176176

177-
$context = is_array( $input['context'] ?? null ) ? $input['context'] : array();
178-
$context = array_merge(
177+
$context = is_array( $input['context'] ?? null ) ? $input['context'] : array();
178+
$context = array_merge(
179179
$context,
180180
array(
181-
'data_packets' => $params['data_packets'] ?? array(),
182-
'engine_data' => $params['engine_data'] ?? array(),
183-
'flow_id' => $params['flow_id'] ?? null,
184-
'pipeline_id' => $params['pipeline_id'] ?? null,
185-
'job_id' => $params['job_id'] ?? $jobId,
186-
'from_queue' => $from_queue,
181+
'data_packets' => $params['data_packets'] ?? array(),
182+
'engine_data' => $params['engine_data'] ?? array(),
183+
'flow_id' => $params['flow_id'] ?? null,
184+
'pipeline_id' => $params['pipeline_id'] ?? null,
185+
'job_id' => $params['job_id'] ?? $jobId,
186+
'from_queue' => $from_queue,
187187
)
188188
);
189189
$input['context'] = $context;

inc/Engine/AI/System/Tasks/ImageOptimizationTask.php

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function executeTask( int $jobId, array $params ): void {
6363

6464
$file_path = get_attached_file( $attachment_id );
6565
if ( empty( $file_path ) || ! file_exists( $file_path ) ) {
66-
$this->failJob( $jobId, 'Attachment file not found: ' . ( $file_path ?: 'empty path' ) );
66+
$this->failJob( $jobId, 'Attachment file not found: ' . ( $file_path ? $file_path : 'empty path' ) );
6767
return;
6868
}
6969

@@ -138,18 +138,27 @@ private function compressImage( string $file_path, string $mime_type, int $quali
138138
$editor = wp_get_image_editor( $file_path );
139139

140140
if ( is_wp_error( $editor ) ) {
141-
return array( 'success' => false, 'error' => 'Image editor not available: ' . $editor->get_error_message() );
141+
return array(
142+
'success' => false,
143+
'error' => 'Image editor not available: ' . $editor->get_error_message(),
144+
);
142145
}
143146

144147
$editor->set_quality( $quality );
145148
$saved = $editor->save( $file_path, $mime_type );
146149

147150
if ( is_wp_error( $saved ) ) {
148-
return array( 'success' => false, 'error' => 'Compression failed: ' . $saved->get_error_message() );
151+
return array(
152+
'success' => false,
153+
'error' => 'Compression failed: ' . $saved->get_error_message(),
154+
);
149155
}
150156

151157
clearstatcache( true, $file_path );
152-
return array( 'success' => true, 'new_size' => filesize( $file_path ) );
158+
return array(
159+
'success' => true,
160+
'new_size' => filesize( $file_path ),
161+
);
153162
}
154163

155164
/**
@@ -162,21 +171,35 @@ private function generateWebP( string $file_path, int $quality, int $attachment_
162171
$webp_path = preg_replace( '/\.(jpe?g|png)$/i', '.webp', $file_path );
163172

164173
if ( file_exists( $webp_path ) ) {
165-
return array( 'success' => true, 'webp_path' => $webp_path, 'webp_size' => filesize( $webp_path ) );
174+
return array(
175+
'success' => true,
176+
'webp_path' => $webp_path,
177+
'webp_size' => filesize( $webp_path ),
178+
);
166179
}
167180

168181
$editor = wp_get_image_editor( $file_path );
169182
if ( is_wp_error( $editor ) ) {
170-
return array( 'success' => false, 'error' => 'Image editor not available: ' . $editor->get_error_message() );
183+
return array(
184+
'success' => false,
185+
'error' => 'Image editor not available: ' . $editor->get_error_message(),
186+
);
171187
}
172188

173189
$editor->set_quality( $quality );
174190
$saved = $editor->save( $webp_path, 'image/webp' );
175191

176192
if ( is_wp_error( $saved ) ) {
177-
return array( 'success' => false, 'error' => 'WebP generation failed: ' . $saved->get_error_message() );
193+
return array(
194+
'success' => false,
195+
'error' => 'WebP generation failed: ' . $saved->get_error_message(),
196+
);
178197
}
179198

180-
return array( 'success' => true, 'webp_path' => $saved['path'], 'webp_size' => filesize( $saved['path'] ) );
199+
return array(
200+
'success' => true,
201+
'webp_path' => $saved['path'],
202+
'webp_size' => filesize( $saved['path'] ),
203+
);
181204
}
182205
}

inc/migrations/scaffolding.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,8 @@ function datamachine_scaffold_soul_content( string $content, string $filename, a
426426
* @return string
427427
*/
428428
function datamachine_scaffold_memory_content( string $content, string $filename, array $context ): string {
429+
unset( $context );
430+
429431
if ( 'MEMORY.md' !== $filename || '' !== $content ) {
430432
return $content;
431433
}
@@ -448,11 +450,14 @@ function datamachine_scaffold_memory_content( string $content, string $filename,
448450
* @return string
449451
*/
450452
function datamachine_scaffold_rules_content( string $content, string $filename, array $context ): string {
453+
unset( $context );
454+
451455
if ( 'RULES.md' !== $filename || '' !== $content ) {
452456
return $content;
453457
}
454458

455-
$site_name = get_bloginfo( 'name' ) ?: 'this site';
459+
$site_name = get_bloginfo( 'name' );
460+
$site_name = $site_name ? $site_name : 'this site';
456461

457462
return <<<MD
458463
# Site Rules

0 commit comments

Comments
 (0)