Code Duplication    Length = 4-9 lines in 3 locations

_inc/lib/debugger/class-jetpack-cxn-tests.php 1 location

@@ 235-239 (lines=5) @@
232
			Client::WPCOM_JSON_API_VERSION
233
		);
234
235
		if ( is_wp_error( $response ) ) {
236
			/* translators: %1$s is the error code, %2$s is the error message */
237
			$message = sprintf( __( 'Connection test failed (#%1$s: %2$s)', 'jetpack' ), $response->get_error_code(), $response->get_error_message() );
238
			return self::failing_test( $name, $message );
239
		}
240
241
		$body = wp_remote_retrieve_body( $response );
242
		if ( ! $body ) {

class.jetpack-cli.php 2 locations

@@ 145-148 (lines=4) @@
142
			Client::WPCOM_JSON_API_VERSION
143
		);
144
145
		if ( is_wp_error( $response ) ) {
146
			/* translators: %1$s is the error code, %2$s is the error message */
147
			WP_CLI::error( sprintf( __( 'Failed to test connection (#%1$s: %2$s)', 'jetpack' ), $response->get_error_code(), $response->get_error_message() ) );
148
		}
149
150
		$body = wp_remote_retrieve_body( $response );
151
		if ( ! $body ) {
@@ 1345-1353 (lines=9) @@
1342
			empty( $named_args['base_api_path'] ) ? 'rest' : $named_args['base_api_path']
1343
		);
1344
1345
		if ( is_wp_error( $response ) ) {
1346
			WP_CLI::error( sprintf(
1347
				/* translators: %1$s is an endpoint route (ex. /sites/123456), %2$d is an error code, %3$s is an error message. */
1348
				__( 'Request to %1$s returned an error: (%2$d) %3$s.', 'jetpack' ),
1349
				$resource_url,
1350
				$response->get_error_code(),
1351
				$response->get_error_message()
1352
			) );
1353
		}
1354
1355
		if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
1356
			WP_CLI::error( sprintf(