wikimedia/mediawiki-core

View on GitHub
includes/debug/logger/LegacyLogger.php

Summary

Maintainability
D
2 days
Test Coverage

File LegacyLogger.php has 279 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/logger/LegacyLogger.php - About 2 hrs to fix

    Function shouldEmit has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function shouldEmit( $channel, $message, $level, $context ) {
            global $wgDebugLogFile, $wgDBerrorLog, $wgDebugLogGroups;
    
            if ( is_string( $level ) ) {
                $level = self::$levelMapping[$level];
    Severity: Minor
    Found in includes/debug/logger/LegacyLogger.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

    Function flatten has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        protected static function flatten( $item ) {
            if ( $item === null ) {
                return '[Null]';
            }
    
    
    Severity: Minor
    Found in includes/debug/logger/LegacyLogger.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 flatten has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected static function flatten( $item ) {
            if ( $item === null ) {
                return '[Null]';
            }
    
    
    Severity: Minor
    Found in includes/debug/logger/LegacyLogger.php - About 1 hr to fix

      Method log has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function log( $level, $message, array $context = [] ) {
              if ( is_string( $level ) ) {
                  $level = self::$levelMapping[$level];
              }
              if ( $level < $this->minimumLevel ) {
      Severity: Minor
      Found in includes/debug/logger/LegacyLogger.php - About 1 hr to fix

        Function format has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function format( $channel, $message, $context ) {
                global $wgDebugLogGroups, $wgLogExceptionBacktrace;
        
                if ( $channel === 'wfDebug' ) {
                    $text = self::formatAsWfDebug( $channel, $message, $context );
        Severity: Minor
        Found in includes/debug/logger/LegacyLogger.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 __construct has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public function __construct( $channel ) {
                global $wgDebugLogFile, $wgDBerrorLog, $wgDebugLogGroups, $wgDebugToolbar, $wgDebugRawPage, $wgShowDebug;
        
                $this->channel = $channel;
                $this->isDB = ( $channel === 'rdbms' );
        Severity: Minor
        Found in includes/debug/logger/LegacyLogger.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 shouldEmit has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function shouldEmit( $channel, $message, $level, $context ) {
                global $wgDebugLogFile, $wgDBerrorLog, $wgDebugLogGroups;
        
                if ( is_string( $level ) ) {
                    $level = self::$levelMapping[$level];
        Severity: Minor
        Found in includes/debug/logger/LegacyLogger.php - About 1 hr to fix

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

              public function log( $level, $message, array $context = [] ) {
                  if ( is_string( $level ) ) {
                      $level = self::$levelMapping[$level];
                  }
                  if ( $level < $this->minimumLevel ) {
          Severity: Minor
          Found in includes/debug/logger/LegacyLogger.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 destination has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              protected static function destination( $channel, $message, $context ) {
                  global $wgDebugLogFile, $wgDBerrorLog, $wgDebugLogGroups;
          
                  // Default destination is the debug log file as historically used by
                  // the wfDebug function.
          Severity: Minor
          Found in includes/debug/logger/LegacyLogger.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

          Avoid too many return statements within this method.
          Open

                      return '[' . $which . ' ' . get_class( $item ) . '( ' .
                          $item->getFile() . ':' . $item->getLine() . ') ' .
                          $item->getMessage() . ']';
          Severity: Major
          Found in includes/debug/logger/LegacyLogger.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return (string)$item;
            Severity: Major
            Found in includes/debug/logger/LegacyLogger.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                          return (string)$item;
              Severity: Major
              Found in includes/debug/logger/LegacyLogger.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return '[Resource ' . get_resource_type( $item ) . ']';
                Severity: Major
                Found in includes/debug/logger/LegacyLogger.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return (string)$item;
                  Severity: Major
                  Found in includes/debug/logger/LegacyLogger.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            return '[Unknown ' . gettype( $item ) . ']';
                    Severity: Major
                    Found in includes/debug/logger/LegacyLogger.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return '[Object ' . get_class( $item ) . ']';
                      Severity: Major
                      Found in includes/debug/logger/LegacyLogger.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return '[Array(' . count( $item ) . ')]';
                        Severity: Major
                        Found in includes/debug/logger/LegacyLogger.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return $item->format( 'c' );
                          Severity: Major
                          Found in includes/debug/logger/LegacyLogger.php - About 30 mins to fix

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

                                public static function emit( $text, $file ) {
                                    if ( str_starts_with( $file, 'udp:' ) ) {
                                        $transport = UDPTransport::newFromString( $file );
                                        $transport->emit( $text );
                                    } else {
                            Severity: Minor
                            Found in includes/debug/logger/LegacyLogger.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