Showing 718 of 718 total issues
Function build
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
public function build( array $config ): array {
$langStem = "{$this->langName}_stemmer";
if ( $this->unpacked ) {
// Analyzer config for char_filter and filter will be in the order below,
- 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 build
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
public function build( $inputDocs, $explain = false ) {
$titleFactory = MediaWikiServices::getInstance()->getTitleFactory();
// Cross namespace titles
$crossNsTitles = [];
$docs = [];
- 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 validateParams
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
private function validateParams() {
$pageOptionCount = (int)$this->hasOption( 'page' ) + (int)$this->hasOption( 'page-list' )
+ (int)$this->hasOption( 'pageid-list' );
if ( $pageOptionCount !== 1 ) {
$this->fatalError( "Exactly one of --page, --page-list and --pageid-list must be used" );
- 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 build
has 133 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function build( SearchContext $searchContext, $term ) {
$searchContext->addSyntaxUsed( 'full_text' );
// Transform MediaWiki specific syntax to filters and extra
// (pre-escaped) query string
foreach ( $this->features as $feature ) {
Function searchMulti
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
protected function searchMulti( MSearchRequests $msearches ) {
$searches = $msearches->getRequests();
$contextResultsType = $this->searchContext->getResultsType();
$cirrusDebugOptions = $this->searchContext->getDebugOptions();
Assert::precondition( !$cirrusDebugOptions->isCirrusDumpQuery(), 'Must not reach this method when dumping the query' );
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
'wsum_inclinks_pv' => [
'score_mode' => 'sum',
'boost_mode' => 'sum',
'functions' => [
[
- 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 188.
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
'wsum_inclinks_pv+' => [
'score_mode' => 'sum',
'boost_mode' => 'sum',
'functions' => [
[
- 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 188.
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
Method buildCirrusSearchRequestEvent
has 126 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function buildCirrusSearchRequestEvent() {
global $wgRequest, $wgServerName;
$webrequest = $wgRequest;
// for the moment RequestLog::getRequests() is still created in the
Method searchMulti
has 125 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function searchMulti( MSearchRequests $msearches ) {
$searches = $msearches->getRequests();
$contextResultsType = $this->searchContext->getResultsType();
$cirrusDebugOptions = $this->searchContext->getDebugOptions();
Assert::precondition( !$cirrusDebugOptions->isCirrusDumpQuery(), 'Must not reach this method when dumping the query' );
Method build
has 123 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function build() {
$resultsType = $this->searchContext->getResultsType();
$query = new Query();
$query->setTrackTotalHits( $this->searchContext->getTrackTotalHits() );
Function postProcess
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
public function postProcess( CompletionResultsCollector $collector, ResultSet $results, $indexName ) {
$suggestResp = $results->getSuggests();
if ( $suggestResp === [] ) {
// Edge case where the index contains 0 documents and does not even return the 'suggest' field
return 0;
- 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 sendData
has 120 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function sendData( $indexSuffix, array $documents ) {
if ( !$documents ) {
return Status::newGood();
}
File CirrusSearch.php
has 366 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace CirrusSearch;
use CirrusSearch\Extra\MultiList\MultiListBuilder;
Function buildCirrusSearchRequestEvent
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
private function buildCirrusSearchRequestEvent() {
global $wgRequest, $wgServerName;
$webrequest = $wgRequest;
// for the moment RequestLog::getRequests() is still created in the
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
private function loadFullTextQueryProfiles( SearchProfileService $service, SearchConfig $config ) {
$service->registerFileRepository( SearchProfileService::FT_QUERY_BUILDER, self::CIRRUS_BASE,
__DIR__ . '/../../profiles/FullTextQueryBuilderProfiles.config.php' );
$service->registerRepository( new ConfigProfileRepository( SearchProfileService::FT_QUERY_BUILDER, self::CIRRUS_CONFIG,
- 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 173.
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
private function loadFallbackProfiles( SearchProfileService $service, SearchConfig $config ) {
$service->registerFileRepository( SearchProfileService::FALLBACKS, self::CIRRUS_BASE,
__DIR__ . '/../../profiles/FallbackProfiles.config.php' );
$service->registerRepository( new ConfigProfileRepository( SearchProfileService::FALLBACKS, self::CIRRUS_CONFIG,
'CirrusSearchFallbackProfiles', $config ) );
- 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 173.
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 replace
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
private function replace( array $profile, array $replacement ) {
$cur = &$profile;
foreach ( $replacement['matches'] as $match ) {
if ( !is_array( $cur ) ) {
return $profile;
- 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 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
AnalyzerBuilder
has 34 functions (exceeds 20 allowed). Consider refactoring. Open
class AnalyzerBuilder {
/**
* Indicate that filters should be automatically appended or prepended, rather
* than inserted before a given filter.
*/
Method getDefaultFields
has 108 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getDefaultFields() {
// Note never to set something as type='object' here because that isn't returned by elasticsearch
// and is inferred anyway.
$titleExtraAnalyzers = [
[ 'analyzer' => 'prefix', 'search_analyzer' => 'near_match', 'index_options' => 'docs', 'norms' => false ],