wikimedia/mediawiki-core

View on GitHub
includes/historyblob/DiffHistoryBlob.php

Summary

Maintainability
C
1 day
Test Coverage

Function compress has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    private function compress() {
        if ( !function_exists( 'xdiff_string_rabdiff' ) ) {
            throw new RuntimeException( "Need xdiff support to write DiffHistoryBlob\n" );
        }
        if ( isset( $this->mDiffs ) ) {
Severity: Minor
Found in includes/historyblob/DiffHistoryBlob.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 compress has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function compress() {
        if ( !function_exists( 'xdiff_string_rabdiff' ) ) {
            throw new RuntimeException( "Need xdiff support to write DiffHistoryBlob\n" );
        }
        if ( isset( $this->mDiffs ) ) {
Severity: Major
Found in includes/historyblob/DiffHistoryBlob.php - About 2 hrs to fix

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

        private function patch( $base, $diff ) {
            if ( function_exists( 'xdiff_string_bpatch' ) ) {
                return xdiff_string_bpatch( $base, $diff );
            }
    
    
    Severity: Minor
    Found in includes/historyblob/DiffHistoryBlob.php - About 1 hr to fix

      Function __sleep has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function __sleep() {
              $this->compress();
              if ( $this->mItems === [] ) {
                  $info = false;
              } else {
      Severity: Minor
      Found in includes/historyblob/DiffHistoryBlob.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

      Function patch has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          private function patch( $base, $diff ) {
              if ( function_exists( 'xdiff_string_bpatch' ) ) {
                  return xdiff_string_bpatch( $base, $diff );
              }
      
      
      Severity: Minor
      Found in includes/historyblob/DiffHistoryBlob.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

      Avoid too many return statements within this method.
      Open

              return $out;
      Severity: Major
      Found in includes/historyblob/DiffHistoryBlob.php - About 30 mins to fix

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

            public function __wakeup() {
                // addItem() doesn't work if mItems is partially filled from mDiffs
                $this->mFrozen = true;
                $info = HistoryBlobUtils::unserializeArray( gzinflate( $this->mCompressed ) );
                $this->mCompressed = null;
        Severity: Minor
        Found in includes/historyblob/DiffHistoryBlob.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