Code Duplication    Length = 4-16 lines in 4 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

@@ 144-147 (lines=4) @@
141
			Client::WPCOM_JSON_API_VERSION
142
		);
143
144
		if ( is_wp_error( $response ) ) {
145
			/* translators: %1$s is the error code, %2$s is the error message */
146
			WP_CLI::error( sprintf( __( 'Failed to test connection (#%1$s: %2$s)', 'jetpack' ), $response->get_error_code(), $response->get_error_message() ) );
147
		}
148
149
		$body = wp_remote_retrieve_body( $response );
150
		if ( ! $body ) {
@@ 1357-1365 (lines=9) @@
1354
			empty( $named_args['base_api_path'] ) ? 'rest' : $named_args['base_api_path']
1355
		);
1356
1357
		if ( is_wp_error( $response ) ) {
1358
			WP_CLI::error(
1359
				sprintf(
1360
					/* translators: %1$s is an endpoint route (ex. /sites/123456), %2$d is an error code, %3$s is an error message. */
1361
					__( 'Request to %1$s returned an error: (%2$d) %3$s.', 'jetpack' ),
1362
					$resource_url,
1363
					$response->get_error_code(),
1364
					$response->get_error_message()
1365
				)
1366
			);
1367
		}
1368

class.jetpack.php 1 location

@@ 4093-4108 (lines=16) @@
4090
					self::log( 'register' );
4091
					self::maybe_set_version_option();
4092
					$registered = self::try_registration();
4093
					if ( is_wp_error( $registered ) ) {
4094
						$error = $registered->get_error_code();
4095
						self::state( 'error', $error );
4096
						self::state( 'error', $registered->get_error_message() );
4097
4098
						/**
4099
						 * Jetpack registration Error.
4100
						 *
4101
						 * @since 7.5.0
4102
						 *
4103
						 * @param string|int $error The error code.
4104
						 * @param \WP_Error $registered The error object.
4105
						 */
4106
						do_action( 'jetpack_connection_register_fail', $error, $registered );
4107
						break;
4108
					}
4109
4110
					$from     = isset( $_GET['from'] ) ? $_GET['from'] : false;
4111
					$redirect = isset( $_GET['redirect'] ) ? $_GET['redirect'] : false;