Showing 718 of 718 total issues
Method searchTextInternal
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function searchTextInternal( $term ) {
// Searcher needs to be cloned before any actual query building is done.
$interleaveSearcher = $this->buildInterleaveSearcher();
$qb = $this->buildFullTextSearch( $term );
Method execute
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute() {
$this->disablePoolCountersAndLogging();
$this->indexSuffix = $this->getBackCompatOption( 'indexSuffix', 'indexType' );
$this->indexBaseName = $this->getOption( 'baseName',
Method mergeStatusWithChildren
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function mergeStatusWithChildren( array $status, array $childResponse ) {
foreach ( $childResponse['nodes'] as $nodeData ) {
foreach ( $nodeData['tasks'] as $taskId => $childData ) {
$sliceId = $childData['status']['slice_id'];
$status['slices'][$sliceId] = $childData['status'];
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' ), '' ];
}
File RequestLogger.php
has 271 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace CirrusSearch;
use ISearchResultSet;
SearchQueryBuilder
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
final class SearchQueryBuilder {
/**
* @var ParsedQuery
*/
BaseCirrusSearchResultSet
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class BaseCirrusSearchResultSet extends BaseSearchResultSet implements CirrusSearchResultSet {
use SearchResultSetTrait;
/** @var bool */
private $hasMoreResults = false;
Similar blocks of code found in 2 locations. Consider refactoring. Open
try {
$this->requireCirrusReady();
$this->builder = SuggestBuilder::create( $this->getConnection(),
$this->getOption( 'scoringMethod' ), $this->indexBaseName );
# check for broken indices and delete them
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 131.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
try {
$indexSuffixes = $this->getConnection()->getAllIndexSuffixes( null );
if ( !in_array( $this->indexSuffix, $indexSuffixes ) ) {
$this->fatalError( 'indexSuffix option must be one of ' .
implode( ', ', $indexSuffixes ) );
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 131.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
File SuggestBuilder.php
has 270 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace CirrusSearch\BuildDocument\Completion;
use CirrusSearch\Connection;
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
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
Function traceRedirects
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function traceRedirects( $title ) {
// Loop through redirects until we get to the ultimate target
$redirects = [];
$wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory();
while ( true ) {
- 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 doTitleSnippet
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
private function doTitleSnippet( Title $title, \Elastica\Result $result, array $highlights ) {
$matched = false;
foreach ( $this->highligtedFields[ArrayCirrusSearchResult::TITLE_SNIPPET] as $hlField ) {
if ( isset( $highlights[$hlField->getFieldName()] ) ) {
$nstext = $title->getNamespace() === 0 ? '' : $this->titleHelper->getNamespaceText( $title ) . ':';
- 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 getNamespaces
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function getNamespaces(): array {
$additionalRequired = null;
if ( $this->initialNamespaces != [] && $this->contextualFilters != [] ) {
foreach ( $this->contextualFilters as $filter ) {
$additional = $filter->requiredNamespaces();
- 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 enableICUFolding
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function enableICUFolding( array $config, $language ) {
$unicodeSetFilter = $this->getICUSetFilter( $language );
$filter = [
'type' => 'icu_folding',
];
- 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 indexData
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
private function indexData(): int {
// We build the suggestions by reading CONTENT and GENERAL indices.
// This does not support extra indices like FILES on commons.
$sourceIndexSuffixes = [ Connection::CONTENT_INDEX_SUFFIX, Connection::GENERAL_INDEX_SUFFIX ];
- 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 execute
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function execute() {
$indexPattern = $this->getSearchConfig()->get( SearchConfig::INDEX_BASE_NAME ) . '_*';
$end = microtime( true ) + 60;
while ( true ) {
try {
- 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 sendConfigDumpRequest
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function sendConfigDumpRequest( $endpoints ) {
$logger = LoggerFactory::getInstance( 'CirrusSearch' );
$reqs = [];
foreach ( $endpoints as $prefix => $info ) {
$reqs[$prefix] = [