wikimedia/mediawiki-extensions-UploadWizard

View on GitHub
includes/Campaign.php

Summary

Maintainability
D
2 days
Test Coverage

Function getParsedConfig has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    public function getParsedConfig( Language $lang = null ) {
        if ( $lang === null ) {
            $lang = $this->context->getLanguage();
        }

Severity: Minor
Found in includes/Campaign.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

File Campaign.php has 309 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace MediaWiki\Extension\UploadWizard;

use InvalidArgumentException;
Severity: Minor
Found in includes/Campaign.php - About 3 hrs to fix

    Method getParsedConfig has 68 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getParsedConfig( Language $lang = null ) {
            if ( $lang === null ) {
                $lang = $this->context->getLanguage();
            }
    
    
    Severity: Major
    Found in includes/Campaign.php - About 2 hrs to fix

      Campaign has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Campaign {
      
          /**
           * The campaign configuration.
           *
      Severity: Minor
      Found in includes/Campaign.php - About 2 hrs to fix

        Function parseArrayValues has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            private function parseArrayValues( $array, Language $lang, $forKeys = null ) {
                $parsed = [];
                foreach ( $array as $key => $value ) {
                    if ( $forKeys !== null ) {
                        if ( in_array( $key, $forKeys ) ) {
        Severity: Minor
        Found in includes/Campaign.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 modifyIfNecessary has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function modifyIfNecessary() {
                foreach ( $this->parsedConfig as $cnf => $modifiers ) {
                    if ( $cnf === 'whileActive' && $this->isActive() ) {
                        $activeModifiers = $modifiers;
                    } elseif ( $cnf === 'afterActive' && $this->wasActive() ) {
        Severity: Minor
        Found in includes/Campaign.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 applyObjectReferenceToButtons has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            private function applyObjectReferenceToButtons( $objRef ) {
                $customizableButtons = [ 'homeButton', 'beginButton' ];
        
                foreach ( $customizableButtons as $button ) {
                    if ( isset( $this->parsedConfig['display'][$button]['target'] ) &&
        Severity: Minor
        Found in includes/Campaign.php - About 45 mins 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 __construct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function __construct( $title, $config = null, $context = null ) {
                $services = MediaWikiServices::getInstance();
                $this->wanObjectCache = $services->getMainWANObjectCache();
                $this->dbr = $services->getDBLoadBalancerFactory()->getReplicaDatabase();
                $this->parser = $services->getParser();
        Severity: Minor
        Found in includes/Campaign.php - About 25 mins 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