Showing 718 of 718 total issues
Function unify
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public static function unify( array $mustFilters, array $mustNotFilters ) {
// We want to make sure that we execute script filters last. So we do these steps:
// 1. Strip script filters from $must and $mustNot.
// 2. Unify the non-script filters.
// 3. Build a BoolAnd filter out of the script filters if there are any.
- 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 extractSimilars
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function extractSimilars( $groupHead, array $candidates, $checkVariants = false ) {
$group = [
'text' => $groupHead,
'variants' => []
];
- 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 3 locations. Consider refactoring. Open
<?php
namespace CirrusSearch\Parser\AST;
use CirrusSearch\Parser\AST\Visitor\Visitor;
- 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 119.
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 3 locations. Consider refactoring. Open
<?php
namespace CirrusSearch\Parser\AST;
use CirrusSearch\Parser\AST\Visitor\Visitor;
- 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 119.
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 3 locations. Consider refactoring. Open
<?php
namespace CirrusSearch\Parser\AST;
use CirrusSearch\Parser\AST\Visitor\Visitor;
- 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 119.
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
'globo_norm' => [
'type' => 'mapping',
'mappings' => [
// map lots of apostrophe-like characters to apostrophe (T315118);
// formerly apostrophe_norm
- 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 119.
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
'word_break_helper' => [
'type' => 'mapping',
'mappings' => [
'_=>\u0020', // a space for mw
',=>\u0020', // useful for "Lastname, Firstname"
- 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 119.
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 loadConfigFromAPI
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function loadConfigFromAPI( $wikis, array $hashConfigFlags, $fallbackConfig ) {
$endpoints = [];
foreach ( $wikis as $prefix => $wiki ) {
$iw = $this->interwikiLookup->fetch( $prefix );
if ( !$iw || !$this->useConfigDumpApi || !$iw->isLocal() ) {
Method get
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get( array $docIds, $sourceFiltering, $usePoolCounter = true ) {
$connection = $this->getOverriddenConnection();
$indexSuffix = $connection->pickIndexSuffixForNamespaces(
$this->searchContext->getNamespaces()
);
Method parse
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function parse( string $query ): ParsedQuery {
$this->reInit( $query );
$queryLen = mb_strlen( $query );
if ( $queryLen > self::QUERY_LEN_HARD_LIMIT ) {
throw new SearchQueryParseException( 'cirrussearch-query-too-long',
Method readLineBatch
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function readLineBatch( SplFileObject $file, bool $useIds ) {
$titleParser = MediaWikiServices::getInstance()->getTitleParser();
$pageStore = MediaWikiServices::getInstance()->getPageStore();
$linkBatchFactory = MediaWikiServices::getInstance()->getLinkBatchFactory();
$batchSize = $this->getBatchSize();
Method updatePages
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function updatePages( $pages, $flags, string $updateKind = null, int $rootEventTime = null ): int {
// Don't update the same page twice. We shouldn't, but meh
$pageIds = [];
$pages = array_filter( $pages, static function ( WikiPage $page ) use ( &$pageIds ) {
if ( !in_array( $page->getId(), $pageIds ) ) {
Method getInterwikiResults
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getInterwikiResults( SearchQuery $query ): Status {
$sources = MediaWikiServices::getInstance()
->getService( InterwikiResolver::SERVICE )
->getSisterProjectConfigs();
if ( !$sources ) {
Method __construct
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct( SearchConfig $config, $weight, $profile ) {
parent::__construct( $config, $weight );
if ( isset( $profile['impact'] ) ) {
$this->impact = $this->getOverriddenFactor( $profile['impact'] );
Method buildConfig
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function buildConfig() {
global $wgCirrusSearchWeights;
$page = $this->getDefaultFields();
Method validate
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function validate() {
$this->out->outputIndented( "Validating new index is different..." );
if ( !$this->oldIndex->exists() ) {
$this->out->output( "ok\n" );
return Status::newGood( true );
Method updateIndices
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function updateIndices( array $add, array $remove ) {
if ( !$remove ) {
return $this->updateFreeIndices( $add );
}
Function __construct
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function __construct( $repoType, $repoName, SearchConfig $config, callable $arrayLoader ) {
$this->wrapped = ArrayProfileRepository::lazyLoaded( $repoType, $repoName, static function () use ( $arrayLoader, $config ) {
$profiles = [];
$allowedFields = [ 'suggest' => true, 'suggest-stop' => 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 loadDocuments
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function loadDocuments( PageIdentity $title, $sourceFiltering = true ) {
[ $docId, $hasRedirects ] = $this->determineCirrusDocId( $title );
if ( $docId === null ) {
return [];
}
- 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 score
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function score( \CirrusSearch\Search\SearchQuery $query ) {
Assert::parameter( $query->getSearchEngineEntryPoint() === $this->searchEngineEntryPoint,
'query',
"must be {$this->searchEngineEntryPoint} but {$query->getSearchEngineEntryPoint()} given." );
- 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"