wikimedia/mediawiki-core

View on GitHub
includes/Settings/SettingsBuilder.php

Summary

Maintainability
D
2 days
Test Coverage

SettingsBuilder has 38 functions (exceeds 20 allowed). Consider refactoring.
Open

class SettingsBuilder {

    /**
     * @var int The initial stage in which settings can be loaded,
     * but config values cannot be accessed.
Severity: Minor
Found in includes/Settings/SettingsBuilder.php - About 5 hrs to fix

    File SettingsBuilder.php has 356 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace MediaWiki\Settings;
    
    use MediaWiki\Config\Config;
    Severity: Minor
    Found in includes/Settings/SettingsBuilder.php - About 4 hrs to fix

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

          private function applySettings( array $settings ) {
              // First extract config variables that change the behavior of SettingsBuilder.
              // No merge strategies are applied, defaults are set in the constructor.
              if ( isset( $settings['config'] ) ) {
                  $this->updateSettingsConfig( $settings['config'] );
      Severity: Minor
      Found in includes/Settings/SettingsBuilder.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 applySettings has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function applySettings( array $settings ) {
              // First extract config variables that change the behavior of SettingsBuilder.
              // No merge strategies are applied, defaults are set in the constructor.
              if ( isset( $settings['config'] ) ) {
                  $this->updateSettingsConfig( $settings['config'] );
      Severity: Minor
      Found in includes/Settings/SettingsBuilder.php - About 1 hr to fix

        Method applySchemas has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function applySchemas( array $settings ) {
                $defaults = [];
        
                if ( isset( $settings['config-schema-inverse'] ) ) {
                    $defaults = $settings['config-schema-inverse']['default'] ?? [];
        Severity: Minor
        Found in includes/Settings/SettingsBuilder.php - About 1 hr to fix

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

              private function applySchemas( array $settings ) {
                  $defaults = [];
          
                  if ( isset( $settings['config-schema-inverse'] ) ) {
                      $defaults = $settings['config-schema-inverse']['default'] ?? [];
          Severity: Minor
          Found in includes/Settings/SettingsBuilder.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 loadRecursive has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              private function loadRecursive( array $batch, array $stack = [] ): array {
                  $allSettings = [];
          
                  // Depth-first traversal of settings sources.
                  foreach ( $batch as $source ) {
          Severity: Minor
          Found in includes/Settings/SettingsBuilder.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

          Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  string $baseDir,
                  ExtensionRegistry $extensionRegistry,
                  ConfigBuilder $configSink,
                  PhpIniSink $phpIniSink,
                  BagOStuff $cache = null
          Severity: Minor
          Found in includes/Settings/SettingsBuilder.php - About 35 mins to fix

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

                public function detectDeprecatedConfig(): array {
                    $config = $this->getConfig();
                    $keys = $this->getDefinedConfigKeys();
                    $deprecated = [];
            
            
            Severity: Minor
            Found in includes/Settings/SettingsBuilder.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