wikimedia/mediawiki-core

View on GitHub
includes/debug/MWDebug.php

Summary

Maintainability
D
2 days
Test Coverage

File MWDebug.php has 405 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 includes/debug/MWDebug.php - About 5 hrs to fix

    Function debugMsg has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function debugMsg( $str, $context = [] ) {
            global $wgDebugComments, $wgShowDebug;
    
            if ( self::$enabled || $wgDebugComments || $wgShowDebug ) {
                if ( $context ) {
    Severity: Minor
    Found in includes/debug/MWDebug.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

    MWDebug has 25 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class MWDebug {
        /**
         * Log lines
         *
         * @var array
    Severity: Minor
    Found in includes/debug/MWDebug.php - About 2 hrs to fix

      Method debugMsg has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function debugMsg( $str, $context = [] ) {
              global $wgDebugComments, $wgShowDebug;
      
              if ( self::$enabled || $wgDebugComments || $wgShowDebug ) {
                  if ( $context ) {
      Severity: Minor
      Found in includes/debug/MWDebug.php - About 1 hr to fix

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

            public static function deprecatedMsg( $msg, $version = false,
                $component = false, $callerOffset = 2
            ) {
                if ( $callerOffset === false ) {
                    $callerFunc = '';
        Severity: Minor
        Found in includes/debug/MWDebug.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 deprecatedMsg has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function deprecatedMsg( $msg, $version = false,
                $component = false, $callerOffset = 2
            ) {
                if ( $callerOffset === false ) {
                    $callerFunc = '';
        Severity: Minor
        Found in includes/debug/MWDebug.php - About 1 hr to fix

          Function getCallerDescription has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              private static function getCallerDescription( $callerOffset ) {
                  $callers = wfDebugBacktrace();
          
                  if ( isset( $callers[$callerOffset] ) ) {
                      $callerfile = $callers[$callerOffset];
          Severity: Minor
          Found in includes/debug/MWDebug.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 getDebugInfo has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function getDebugInfo( IContextSource $context ) {
                  if ( !self::$enabled ) {
                      return [];
                  }
          
          
          Severity: Minor
          Found in includes/debug/MWDebug.php - About 1 hr to fix

            Method query has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function query( $sql, $function, $runTime, $dbhost ) {
                    if ( !self::$enabled ) {
                        return false;
                    }
            
            
            Severity: Minor
            Found in includes/debug/MWDebug.php - About 1 hr to fix

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

                  public static function detectDeprecatedOverride( $instance, $class, $method, $version = false,
                      $component = false, $callerOffset = 2
              Severity: Minor
              Found in includes/debug/MWDebug.php - About 45 mins to fix

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

                    public static function appendDebugInfoToApiResult( IContextSource $context, ApiResult $result ) {
                        if ( !self::$enabled ) {
                            return;
                        }
                
                
                Severity: Minor
                Found in includes/debug/MWDebug.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 sendRawDeprecated has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function sendRawDeprecated( $msg, $sendToLog = true, $callerFunc = '' ) {
                        foreach ( self::$deprecationFilters as $filter => $callback ) {
                            if ( preg_match( $filter, $msg ) ) {
                                if ( is_callable( $callback ) ) {
                                    $callback();
                Severity: Minor
                Found in includes/debug/MWDebug.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