wikimedia/mediawiki-extensions-CirrusSearch

View on GitHub
includes/Maintenance/AnalysisFilter.php

Summary

Maintainability
C
7 hrs
Test Coverage

Function deduplicateAnalysisConfig has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    public function deduplicateAnalysisConfig( array $analysis ) {
        // Deduplicate children first to normalize analyzer configuration.
        foreach ( [ 'tokenizer', 'filter', 'char_filter' ] as $k ) {
            if ( !isset( $analysis[$k] ) ) {
                continue;
Severity: Minor
Found in includes/Maintenance/AnalysisFilter.php - About 3 hrs to fix

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 filterUnusedAnalysisChain has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function filterUnusedAnalysisChain( $analysis, Set $usedAnalyzers ) {
        $sets = [
            'analyzer' => $usedAnalyzers,
            'filter' => new Set(),
            'char_filter' => new Set(),
Severity: Minor
Found in includes/Maintenance/AnalysisFilter.php - About 1 hr to fix

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 pushAnalyzerAliasesIntoField has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function pushAnalyzerAliasesIntoField( array $properties, array $aliases ) {
        foreach ( $properties as &$config ) {
            foreach ( self::$ANALYZER_FIELDS as $key ) {
                if ( isset( $config[$key] ) && isset( $aliases[$config[$key]] ) ) {
                    $config[$key] = $aliases[$config[$key]];
Severity: Minor
Found in includes/Maintenance/AnalysisFilter.php - About 1 hr to fix

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 findUsedFromField has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    private function findUsedFromField( array $properties ) {
        $analyzers = new Set();
        foreach ( $properties as $name => $config ) {
            foreach ( self::$ANALYZER_FIELDS as $key ) {
                if ( isset( $config[$key] ) ) {
Severity: Minor
Found in includes/Maintenance/AnalysisFilter.php - About 1 hr to fix

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

There are no issues that match your filters.

Category
Status