Method classifyError
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function classifyError( \Elastica\Exception\ExceptionInterface $exception = null ) {
if ( $exception === null ) {
return 'unknown';
}
$error = self::extractFullError( $exception );
Function extractFullError
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public static function extractFullError( \Elastica\Exception\ExceptionInterface $exception ): array {
if ( $exception instanceof BulkResponseException ) {
$actionReasons = [];
foreach ( $exception->getActionExceptions() as $actionException ) {
$actionReasons[] = $actionException->getMessage() . ': '
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method extractFullError
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function extractFullError( \Elastica\Exception\ExceptionInterface $exception ): array {
if ( $exception instanceof BulkResponseException ) {
$actionReasons = [];
foreach ( $exception->getActionExceptions() as $actionException ) {
$actionReasons[] = $actionException->getMessage() . ': '
Method extractMessageAndStatus
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function extractMessageAndStatus( \Elastica\Exception\ExceptionInterface $exception = null ) {
if ( !$exception ) {
return [ Status::newFatal( 'cirrussearch-backend-error' ), '' ];
}
Function extractMessageAndStatus
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public static function extractMessageAndStatus( \Elastica\Exception\ExceptionInterface $exception = null ) {
if ( !$exception ) {
return [ Status::newFatal( 'cirrussearch-backend-error' ), '' ];
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
File ElasticaErrorHandler.php
has 255 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace CirrusSearch;
use Elastica\Exception\Bulk\ResponseException as BulkResponseException;
Function classifyError
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function classifyError( \Elastica\Exception\ExceptionInterface $exception = null ) {
if ( $exception === null ) {
return 'unknown';
}
$error = self::extractFullError( $exception );
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function formatMessage
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected static function formatMessage( array $error ) {
if ( isset( $error['actionReasons'] ) ) {
$message = $error['type'] . ': ' . $error['reason'];
foreach ( $error['actionReasons'] as $actionReason ) {
$message .= " - $actionReason\n";
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this method. Open
return [ $status, 'Regex syntax error: ' . $syntaxError ];
Avoid too many return
statements within this method. Open
return [
Status::newFatal( 'cirrussearch-backend-error' ),
$formattedMessage
];
Avoid too many return
statements within this method. Open
return $error;
Avoid too many return
statements within this method. Open
return "unknown";
Avoid too many return
statements within this method. Open
return [
Status::newFatal( 'cirrussearch-backend-error' ),
self::formatMessage( $cause )
];