Showing 718 of 718 total issues
Method build
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function build( array $inputDoc, $suggestType, $score, \Elastica\Document $suggestDoc, $targetNamespace ) {
Method doApply
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function doApply( SearchContext $context, $key, $value, $quotedValue, $negated ) {
Method doApply
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function doApply( SearchContext $context, $key, $value, $quotedValue, $negated ) {
Method __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
$name,
$type,
string $indexAnalyzer,
string $searchAnalyzer,
string $similarity
Similar blocks of code found in 2 locations. Consider refactoring. Open
protected function getTimeout( $searchType = 'default' ) {
$timeout = $this->connection->getConfig()->getElement( 'CirrusSearchSearchShardTimeout', $searchType );
if ( $timeout !== null ) {
return $timeout;
}
- 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 92.
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
protected function getClientTimeout( $searchType = 'default' ) {
$timeout = $this->connection->getConfig()->getElement( 'CirrusSearchClientSideSearchTimeout', $searchType );
if ( $timeout !== null ) {
return $timeout;
}
- 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 92.
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
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
Function reformat
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function reformat( array $problems ): array {
$clean = [];
$indexBaseName = $this->getSearchConfig()->get( SearchConfig::INDEX_BASE_NAME );
// Generic connection for resolving index names, its always the same everywhere
$connection = Connection::getPool( $this->getSearchConfig() );
- 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 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
Function intersect
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function intersect( CrossSearchStrategy $other ) {
if ( $other === self::hostWikiOnlyStrategy() || $this === self::hostWikiOnlyStrategy() ) {
return self::hostWikiOnlyStrategy();
}
$crossL = $other->crossLanguageSearchSupported && $this->crossLanguageSearchSupported;
- 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 onLinksUpdateComplete
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function onLinksUpdateComplete( $linksUpdate, $ticket ) {
if ( !$this->isEnabled() ) {
return;
}
// defer processing the LinksUpdateComplete hook until other hooks tagged in PageChangeTracker
- 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 preparePageReferencesForLinksUpdate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function preparePageReferencesForLinksUpdate( $pageReferences, int $max, $excludeBadUTF = false ) {
$pageReferences = self::pickFromArray( $pageReferences, $max );
$dBKeys = [];
foreach ( $pageReferences as $pageReference ) {
$title = Title::newFromPageReference( $pageReference );
- 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 getDetectors
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getDetectors() {
$detectors = [];
foreach ( $this->config->get( 'CirrusSearchLanguageDetectors' ) as $name => $klass ) {
if ( !class_exists( $klass ) ) {
LoggerFactory::getInstance( 'CirrusSearch' )->info(
- 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 prefixSearch
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function prefixSearch( $search, $variants ) {
$searcher = $this->makeSearcher();
if ( $search ) {
$searcher->setResultsType( new FancyTitleResultsType( 'prefix' ) );
- 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 buildLogMessage
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function buildLogMessage( RequestLog $log, array $context ) {
$message = $log->getDescription();
$message .= " against {index} took {tookMs} millis";
if ( isset( $context['elasticTookMs'] ) ) {
$message .= " and {elasticTookMs} Elasticsearch millis";
- 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 getProfiles
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getProfiles( $profileType, User $user = null ) {
$profileService = $this->config->getProfileService();
$serviceProfileType = null;
switch ( $profileType ) {
case SearchEngine::COMPLETION_PROFILE_TYPE:
- 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 checkExisitingPage
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function checkExisitingPage( $docId, $pageId, $page, array $fromIndex ) {
$inIndex = $fromIndex !== [];
if ( $this->checkIfRedirect( $page ) ) {
if ( $inIndex ) {
foreach ( $fromIndex as $indexInfo ) {
- 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 completionSearchBackend
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function completionSearchBackend( $search ) {
if ( in_array( NS_SPECIAL, $this->namespaces ) ) {
// delegate special search to parent
return parent::completionSearchBackend( $search );
}
- 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 getAllIndexSuffixes
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function getAllIndexSuffixes( $documentType = self::PAGE_DOC_TYPE ) {
Assert::parameter( $documentType === null || isset( self::SUFFIX_MAPPING[$documentType] ),
'$documentType', "Unknown mapping type $documentType" );
$indexSuffixes = [];
- 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 loadProfileByName
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function loadProfileByName( $type, $name, $failIfMissing = true ) {
if ( isset( $this->repositories[$type] ) ) {
$repos = $this->repositories[$type];
foreach ( $repos as $repo ) {
$prof = $repo->getProfile( $name );
- 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"