File DataSender.php
has 507 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace CirrusSearch;
use CirrusSearch\BuildDocument\BuildDocument;
Method sendData
has 120 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function sendData( $indexSuffix, array $documents ) {
if ( !$documents ) {
return Status::newGood();
}
Function sendData
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
public function sendData( $indexSuffix, array $documents ) {
if ( !$documents ) {
return Status::newGood();
}
- 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 bulkResponseExceptionIsJustDocumentMissing
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
protected function bulkResponseExceptionIsJustDocumentMissing(
ResponseException $exception, $logCallback = null
) {
$justDocumentMissing = true;
foreach ( $exception->getResponseSet()->getBulkResponses() as $bulkResponse ) {
- 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 sendWeightedTagsUpdate
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function sendWeightedTagsUpdate(
string $indexSuffix,
string $tagPrefix,
array $tagWeights,
int $batchSize = 30
Method sendOtherIndexUpdates
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function sendOtherIndexUpdates( $localSite, $indexName, array $otherActions, $batchSize = 30 ) {
$client = $this->connection->getClient();
$status = Status::newGood();
foreach ( array_chunk( $otherActions, $batchSize ) as $updates ) {
'@phan-var array[] $updates';
Function sendWeightedTagsUpdate
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function sendWeightedTagsUpdate(
string $indexSuffix,
string $tagPrefix,
array $tagWeights,
int $batchSize = 30
- 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 sendDeletes
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function sendDeletes( $docIds, $indexSuffix = null ) {
if ( $indexSuffix === null ) {
$indexes = $this->connection->getAllIndexSuffixes( Connection::PAGE_DOC_TYPE );
} else {
$indexes = [ $indexSuffix ];
Function sendOtherIndexUpdates
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function sendOtherIndexUpdates( $localSite, $indexName, array $otherActions, $batchSize = 30 ) {
$client = $this->connection->getClient();
$status = Status::newGood();
foreach ( array_chunk( $otherActions, $batchSize ) as $updates ) {
'@phan-var array[] $updates';
- 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 reportUpdateMetrics
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function reportUpdateMetrics(
\Elastica\Bulk\ResponseSet $responseSet, $indexSuffix, $sent
) {
$updateStats = [
'sent' => $sent,
Function reportUpdateMetrics
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function reportUpdateMetrics(
\Elastica\Bulk\ResponseSet $responseSet, $indexSuffix, $sent
) {
$updateStats = [
'sent' => $sent,
- 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 bulkResponseExceptionIsJustDocumentMissing
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function bulkResponseExceptionIsJustDocumentMissing(
ResponseException $exception, $logCallback = null
) {
$justDocumentMissing = true;
foreach ( $exception->getResponseSet()->getBulkResponses() as $bulkResponse ) {
Method sendUpdateWeightedTags
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
string $indexSuffix,
array $docIds,
string $tagField,
string $tagPrefix,
$tagNames = null,
Method sendResetWeightedTags
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
string $indexSuffix,
array $docIds,
string $tagField,
string $tagPrefix,
int $batchSize = 30
Function sendDeletes
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function sendDeletes( $docIds, $indexSuffix = null ) {
if ( $indexSuffix === null ) {
$indexes = $this->connection->getAllIndexSuffixes( Connection::PAGE_DOC_TYPE );
} else {
$indexes = [ $indexSuffix ];
- 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 (string)( $d->getId() );
Avoid too many return
statements within this method. Open
return Status::newGood();
Avoid too many return
statements within this method. Open
return Status::newFatal( 'cirrussearch-failed-send-data' );