Code Duplication    Length = 4-9 lines in 3 locations

class.jetpack-cli.php 2 locations

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

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

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