wikimedia/mediawiki-extensions-UploadWizard

View on GitHub
maintenance/migrateCampaigns.php

Summary

Maintainability
B
4 hrs
Test Coverage

Method getConfigForJSON has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function getConfigForJSON( $campaign, $oldConfig ) {
        $config = [
            'enabled' => $campaign->campaign_enabled === '1',
            'display' => [
                'headerLabelPage' => $oldConfig['headerLabelPage'],
Severity: Major
Found in maintenance/migrateCampaigns.php - About 2 hrs to fix

    Method execute has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function execute() {
            $services = $this->getServiceContainer();
    
            $username = $this->getOption( 'user', 'Maintenance script' );
    
    
    Severity: Minor
    Found in maintenance/migrateCampaigns.php - About 1 hr to fix

      Function getConfigFromDB has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          private function getConfigFromDB( $id ) {
              $config = [];
      
              $confProps = $this->dbr->newSelectQueryBuilder()
                  ->select( [ 'cc_property', 'cc_value' ] )
      Severity: Minor
      Found in maintenance/migrateCampaigns.php - About 55 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 trimArray has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          private function trimArray( $array ) {
              $newArray = [];
              foreach ( $array as $key => $value ) {
                  if ( is_array( $value ) ) {
                      $trimmedValue = $this->trimArray( $value );
      Severity: Minor
      Found in maintenance/migrateCampaigns.php - About 35 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