Showing 718 of 718 total issues
Function execute
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function execute() {
$this->disablePoolCountersAndLogging();
$profiles = [];
$profileService = $this->getSearchConfig()->getProfileService();
if ( $this->hasOption( '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 execute
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function execute() {
if ( $this->hasOption( 'nagios' ) ) {
// Force silent running mode so we can match Nagios expected output.
$this->mQuiet = 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
Method retry
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function retry( $cause, $newFrom, $cluster = null ) {
if ( $this->params['retryCount'] >= self::JOB_MAX_RETRIES ) {
LoggerFactory::getInstance( 'CirrusSearch' )->info(
"Sanitize CheckerJob: $cause ({fromPageId}:{toPageId}), Abandonning CheckerJob after {retries} retries " .
"for {cluster}, (jobs_chunk_size too high?).",
Method switchAliasTo
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function switchAliasTo( $index ) {
$name = $index->getName();
$oldIndexName = $this->getAliasedIndexName();
if ( $oldIndexName !== null ) {
$this->log( "Switching " . self::INDEX_NAME . " alias from $oldIndexName to $name.\n" );
Method suggest
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function suggest( $text, $variants = null ) {
$suggestSearch = $this->getSuggestSearchRequest( $text, $variants );
$mSearchRequests = new MSearchRequests();
if ( $suggestSearch !== null ) {
Method buildRegexWithGroovy
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function buildRegexWithGroovy( $pattern, $insensitive ) {
$filters = [];
foreach ( $this->fields as $field ) {
$script = <<<GROOVY
import org.apache.lucene.util.automaton.*;
Method explainTemplateBoosts
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function explainTemplateBoosts( array $doc ) {
if ( !isset( $doc['template'] ) ) {
return [
'value' => 1,
'description' => 'No templates'
Similar blocks of code found in 2 locations. Consider refactoring. Open
'wsum_inclinks_pv' => [
'i18n_msg' => 'cirrussearch-qi-profile-wsum-inclinks-pv',
'supported_namespaces' => 'content',
'fallback_profile' => 'wsum_inclinks',
'rescore' => [
- 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 108.
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
'popular_inclinks_pv' => [
'supported_namespaces' => 'content',
'fallback_profile' => 'popular_inclinks',
'i18n_msg' => 'cirrussearch-qi-profile-popular-pv',
'rescore' => [
- 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 108.
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 getHighlightingConfiguration
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getHighlightingConfiguration( array $extraHighlightFields = [] ) {
global $wgCirrusSearchUseExperimentalHighlighter;
if ( $wgCirrusSearchUseExperimentalHighlighter ) {
// This is much less esoteric then the plain highlighter based
Method validate
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function validate(): Status {
// arrays of aliases to be added/removed
$add = $remove = [];
$this->outputIndented( "\tValidating $this->aliasName alias..." );
Method __construct
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct(
SearchConfig $config,
CirrusSearchHookRunner $cirrusSearchHookRunner = null,
NamespacePrefixParser $namespacePrefixParser = null,
SparqlClient $client = null
Method addSharedOptions
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function addSharedOptions( $maintenance ) {
$maintenance->addOption( 'startOver', 'Blow away the identified index and rebuild it with ' .
'no data.' );
$maintenance->addOption( 'indexIdentifier', "Set the identifier of the index to work on. " .
"You'll need this if you have an index in production serving queries and you have " .
Method createIndex
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function createIndex() {
// This is "create only" for now.
if ( $this->getIndex()->exists() ) {
throw new RuntimeException( "Index already exists." );
}
Similar blocks of code found in 2 locations. Consider refactoring. Open
foreach ( $feature->getValueDelimiters() as $delimConfig ) {
Assert::precondition( strlen( $delimConfig['delimiter'] ) === 1,
"Value delimiter must be a single byte char" );
$delim = preg_quote( $delimConfig['delimiter'], '/' );
$allDelims .= $delim;
- 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 107.
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
foreach ( $this->getValueDelimiters() as $delimConfig ) {
Assert::precondition( strlen( $delimConfig['delimiter'] ) === 1,
"Value delimiter must be a single byte char" );
$delim = preg_quote( $delimConfig['delimiter'], '/' );
$allDelims .= $delim;
- 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 107.
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 reportUpdateMetrics
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function reportUpdateMetrics(
\Elastica\Bulk\ResponseSet $responseSet, $indexSuffix, $sent
) {
$updateStats = [
'sent' => $sent,
Method determineCirrusDocId
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function determineCirrusDocId( PageIdentity $title ) {
$hasRedirects = false;
$seen = [];
$now = wfTimestamp( TS_MW );
$services = MediaWikiServices::getInstance();
Method fixupWholeQueryString
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function fixupWholeQueryString( $string ) {
$escapeBadSyntax = static function ( $matches ) {
return preg_replace( '/(?=[^\s\w])/', '\\', $matches[0] );
};
Method __construct
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct(
$langCode,
array $plugins,
SearchConfig $config = null,
CirrusSearchHookRunner $cirrusSearchHookRunner = null