Showing 718 of 718 total issues
File FullTextQueryStringQueryBuilder.php
has 344 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace CirrusSearch\Query;
use CirrusSearch\Extra\Query\TokenCountRouter;
Function readLineBatch
has a Cognitive Complexity of 29 (exceeds 5 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();
- 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
Searcher
has 33 functions (exceeds 20 allowed). Consider refactoring. Open
class Searcher extends ElasticsearchIntermediary implements SearcherFactory {
public const SUGGESTION_HIGHLIGHT_PRE = '<em>';
public const SUGGESTION_HIGHLIGHT_POST = '</em>';
public const HIGHLIGHT_PRE_MARKER = ''; // \uE000. Can't be a unicode literal until php7
public const HIGHLIGHT_PRE = '<span class="searchmatch">';
File Reindexer.php
has 338 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace CirrusSearch\Maintenance;
use CirrusSearch\Connection;
Function build
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
public function build() {
$resultsType = $this->searchContext->getResultsType();
$query = new Query();
$query->setTrackTotalHits( $this->searchContext->getTrackTotalHits() );
- 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 28 (exceeds 5 allowed). Consider refactoring. Open
public function execute() {
$this->disablePoolCountersAndLogging();
$wiki = sprintf( "[%20s]", WikiMap::getCurrentWikiId() );
// Make sure we've actually got indices to populate
- 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 getProfile
has 99 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getProfile( $name ) {
$settings = $this->wrapped->getProfile( $name );
if ( $settings === null ) {
return null;
}
Method siteMatrixLoader
has 97 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function siteMatrixLoader() {
return function () {
global $wgConf;
$matrix = new SiteMatrix;
Method build
has 95 lines of code (exceeds 25 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,
Method expression
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function expression() {
$clauses = [];
$left = null;
// Last boolean operator seen, -1 means none
$lastBoolType = -1;
Method execute
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute() {
$this->disablePoolCountersAndLogging();
$wiki = sprintf( "[%20s]", WikiMap::getCurrentWikiId() );
// Make sure we've actually got indices to populate
Function parse
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
public function parse( $query, KeywordFeature $feature, OffsetTracker $tracker, $startOffset = 0 ) {
if ( $feature->greedy() ) {
Assert::precondition( !$feature->allowEmptyValue(),
"greedy keywords must not accept empty value" );
// XXX: we ignore value delimiter for greedy keywords
- 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 buildExpQuery
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
private function buildExpQuery( $queryString ) {
$query = new \Elastica\Query\BoolQuery();
$query->setMinimumShouldMatch( 0 );
$this->attachFilter( $this->filter, $queryString, $query );
$dismaxQueries = [];
- 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
Hooks
has 30 functions (exceeds 20 allowed). Consider refactoring. Open
class Hooks implements
UserGetDefaultOptionsHook,
GetPreferencesHook,
APIAfterExecuteHook,
ApiBeforeMainHook,
UpdateOneSearchIndexConfig
has 30 functions (exceeds 20 allowed). Consider refactoring. Open
class UpdateOneSearchIndexConfig extends Maintenance {
/**
* @var string
*/
private $indexSuffix;
File Util.php
has 318 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace CirrusSearch;
use MediaWiki\Context\RequestContext;
Function updateLinkedArticles
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public function updateLinkedArticles( $titles ): void {
$pages = [];
$wikiPageFactory = MediaWikiServices::getInstance()->getWikiPageFactory();
foreach ( $titles as $title ) {
// Special pages don't get updated, we only index
- 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
BaseHighlightedField
has 29 functions (exceeds 20 allowed). Consider refactoring. Open
class BaseHighlightedField extends HighlightedField {
public const TYPE = 'highlighting';
public const FVH_HL_TYPE = 'fvh';
Similar blocks of code found in 3 locations. Consider refactoring. Open
private function loadDocumentSizeLimiterProfiles( SearchProfileService $service, SearchConfig $config ) {
$service->registerFileRepository( SearchProfileService::DOCUMENT_SIZE_LIMITER, self::CIRRUS_BASE,
__DIR__ . '/../../profiles/DocumentSizeLimiterProfiles.config.php' );
$service->registerRepository( new ConfigProfileRepository( SearchProfileService::DOCUMENT_SIZE_LIMITER,
self::CIRRUS_CONFIG, 'CirrusSearchDocumentSizeLimiterProfiles', $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 152.
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
private function loadCrossProjectBlockScorer( SearchProfileService $service, SearchConfig $config ) {
$service->registerFileRepository( SearchProfileService::CROSS_PROJECT_BLOCK_SCORER,
self::CIRRUS_BASE, __DIR__ . '/../../profiles/CrossProjectBlockScorerProfiles.config.php' );
$service->registerRepository( new ConfigProfileRepository( SearchProfileService::CROSS_PROJECT_BLOCK_SCORER,
self::CIRRUS_CONFIG, 'CirrusSearchCrossProjectBlockScorerProfiles', $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 152.
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