Code Duplication    Length = 4-9 lines in 3 locations

class.jetpack-cli.php 2 locations

@@ 133-136 (lines=4) @@
130
			Jetpack_Client::WPCOM_JSON_API_VERSION
131
		);
132
133
		if ( is_wp_error( $response ) ) {
134
			/* translators: %1$s is the error code, %2$s is the error message */
135
			WP_CLI::error( sprintf( __( 'Failed to test connection (#%1$s: %2$s)', 'jetpack' ), $response->get_error_code(), $response->get_error_message() ) );
136
		}
137
138
		$body = wp_remote_retrieve_body( $response );
139
		if ( ! $body ) {
@@ 1133-1141 (lines=9) @@
1130
			$named_args['base_api_path']
1131
		);
1132
1133
		if ( is_wp_error( $response ) ) {
1134
			WP_CLI::error( sprintf(
1135
				/* translators: %1$s is an endpoint route (ex. /sites/123456), %2$d is an error code, %3$s is an error message. */
1136
				__( 'Request to %1$s returned an error: (%2$d) %3$s.', 'jetpack' ),
1137
				$resource_url,
1138
				$response->get_error_code(),
1139
				$response->get_error_message()
1140
			) );
1141
		}
1142
1143
		if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
1144
			WP_CLI::error( sprintf(

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

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