wikimedia/mediawiki-core

View on GitHub
maintenance/includes/MaintenanceParameters.php

Summary

Maintainability
F
3 days
Test Coverage

Function loadWithArgv has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

    public function loadWithArgv( array $argv, int $skip = 0 ) {
        $this->clear();

        $options = [];
        $args = [];
Severity: Minor
Found in maintenance/includes/MaintenanceParameters.php - About 5 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 MaintenanceParameters.php has 376 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
Severity: Minor
Found in maintenance/includes/MaintenanceParameters.php - About 5 hrs to fix

    MaintenanceParameters has 34 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class MaintenanceParameters {
    
        /**
         * Array of desired/allowed params
         * @var array<string,array>
    Severity: Minor
    Found in maintenance/includes/MaintenanceParameters.php - About 4 hrs to fix

      Function getHelp has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getHelp(): string {
              $screenWidth = 80; // TODO: Calculate this!
              $tab = "    ";
              $descWidth = $screenWidth - ( 2 * strlen( $tab ) );
      
      
      Severity: Minor
      Found in maintenance/includes/MaintenanceParameters.php - About 2 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

      Method getHelp has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getHelp(): string {
              $screenWidth = 80; // TODO: Calculate this!
              $tab = "    ";
              $descWidth = $screenWidth - ( 2 * strlen( $tab ) );
      
      
      Severity: Major
      Found in maintenance/includes/MaintenanceParameters.php - About 2 hrs to fix

        Method loadWithArgv has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function loadWithArgv( array $argv, int $skip = 0 ) {
                $this->clear();
        
                $options = [];
                $args = [];
        Severity: Major
        Found in maintenance/includes/MaintenanceParameters.php - About 2 hrs to fix

          Function validate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              public function validate() {
                  $valid = true;
                  # Check to make sure we've got all the required options
                  foreach ( $this->mOptDefs as $opt => $info ) {
                      if ( $info['require'] && !$this->hasOption( $opt ) ) {
          Severity: Minor
          Found in maintenance/includes/MaintenanceParameters.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

          Method addArg has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function addArg( string $arg, string $description, bool $required = true, bool $multi = false ): int {
                  if ( isset( $this->mArgOffsets[$arg] ) ) {
                      throw new UnexpectedValueException( "Argument already defined: $arg" );
                  }
          
          
          Severity: Minor
          Found in maintenance/includes/MaintenanceParameters.php - About 1 hr to fix

            Method addOption has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function addOption( string $name, string $description, bool $required = false,
                    bool $withArg = false, $shortName = false, bool $multiOccurrence = false
            Severity: Minor
            Found in maintenance/includes/MaintenanceParameters.php - About 45 mins to fix

              Function setOptionValue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function setOptionValue( array &$options, string $option, $value ) {
                      $this->optionsSequence[] = [ $option, $value ];
              
                      if ( isset( $this->mOptDefs[$option] ) ) {
                          $multi = $this->mOptDefs[$option]['multiOccurrence'];
              Severity: Minor
              Found in maintenance/includes/MaintenanceParameters.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

              Function addArg has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function addArg( string $arg, string $description, bool $required = true, bool $multi = false ): int {
                      if ( isset( $this->mArgOffsets[$arg] ) ) {
                          throw new UnexpectedValueException( "Argument already defined: $arg" );
                      }
              
              
              Severity: Minor
              Found in maintenance/includes/MaintenanceParameters.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

              Function formatHelpItems has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function formatHelpItems( array $items, $heading, $descWidth, $tab ) {
                      if ( $items === [] ) {
                          return '';
                      }
              
              
              Severity: Minor
              Found in maintenance/includes/MaintenanceParameters.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