DerDu/SPHERE-Framework

View on GitHub
Application/Platform/System/Protocol/Difference/finediff.php

Summary

Maintainability
F
6 days
Test Coverage

Function doFragmentDiff has a Cognitive Complexity of 89 (exceeds 5 allowed). Consider refactoring.
Open

    private static function doFragmentDiff($from_text, $to_text, $delimiters)
    {

        // Empty delimiter means character-level diffing.
        // In such case, use code path optimized for character-level
Severity: Minor
Found in Application/Platform/System/Protocol/Difference/finediff.php - About 1 day 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 finediff.php has 506 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * FINE granularity DIFF
 *
 * Computes a set of instructions to convert the content of
Severity: Major
Found in Application/Platform/System/Protocol/Difference/finediff.php - About 1 day to fix

    Function doCharDiff has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
    Open

        private static function doCharDiff($from_text, $to_text)
        {
    
            $result = array();
            $jobs = array(array(0, strlen($from_text), 0, strlen($to_text)));
    Severity: Minor
    Found in Application/Platform/System/Protocol/Difference/finediff.php - About 6 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 doFragmentDiff has 103 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private static function doFragmentDiff($from_text, $to_text, $delimiters)
        {
    
            // Empty delimiter means character-level diffing.
            // In such case, use code path optimized for character-level
    Severity: Major
    Found in Application/Platform/System/Protocol/Difference/finediff.php - About 4 hrs to fix

      Method doCharDiff has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static function doCharDiff($from_text, $to_text)
          {
      
              $result = array();
              $jobs = array(array(0, strlen($from_text), 0, strlen($to_text)));
      Severity: Major
      Found in Application/Platform/System/Protocol/Difference/finediff.php - About 2 hrs to fix

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

            public function renderDiffToHTML()
            {
        
                $in_offset = 0;
                ob_start();
        Severity: Minor
        Found in Application/Platform/System/Protocol/Difference/finediff.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 renderFromOpcodes has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function renderFromOpcodes($from, $opcodes, $callback)
            {
        
                if (!is_callable($callback)) {
                    return;
        Severity: Minor
        Found in Application/Platform/System/Protocol/Difference/finediff.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 _processGranularity has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            private function _processGranularity($from_segment, $to_segment)
            {
        
                $delimiters = $this->granularityStack[$this->stackpointer++];
                $has_next_stage = $this->stackpointer < count($this->granularityStack);
        Severity: Minor
        Found in Application/Platform/System/Protocol/Difference/finediff.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 renderFromOpcodes has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function renderFromOpcodes($from, $opcodes, $callback)
            {
        
                if (!is_callable($callback)) {
                    return;
        Severity: Minor
        Found in Application/Platform/System/Protocol/Difference/finediff.php - About 1 hr to fix

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

              private static function renderDiffToHTMLFromOpcode($opcode, $from, $from_offset, $from_len)
              {
          
                  if ($opcode === 'c') {
                      echo htmlentities(substr($from, $from_offset, $from_len));
          Severity: Minor
          Found in Application/Platform/System/Protocol/Difference/finediff.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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                      if ($best_copy_length) {
                          $jobs[] = array($from_segment_start, $best_from_start, $to_segment_start, $best_to_start);
                          $result[$best_from_start * 4 + 2] = new FineDiffCopyOp($best_copy_length);
                          $jobs[] = array(
                              $best_from_start + $best_copy_length,
          Severity: Major
          Found in Application/Platform/System/Protocol/Difference/finediff.php and 1 other location - About 2 hrs to fix
          Application/Platform/System/Protocol/Difference/finediff.php on lines 596..609

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 124.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                      if ($copy_len) {
                          $jobs[] = array($from_segment_start, $from_copy_start, $to_segment_start, $to_copy_start);
                          $result[$from_copy_start * 4 + 2] = new FineDiffCopyOp($copy_len);
                          $jobs[] = array(
                              $from_copy_start + $copy_len,
          Severity: Major
          Found in Application/Platform/System/Protocol/Difference/finediff.php and 1 other location - About 2 hrs to fix
          Application/Platform/System/Protocol/Difference/finediff.php on lines 504..516

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 124.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                      if ($from_segment_len >= $to_segment_len) {
                          $copy_len = $to_segment_len;
                          while ($copy_len) {
                              $to_copy_start = $to_segment_start;
                              $to_copy_start_max = $to_segment_end - $copy_len;
          Application/Platform/System/Protocol/Difference/finediff.php on lines 578..594

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 113.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                      } else {
                          $copy_len = $from_segment_len;
                          while ($copy_len) {
                              $from_copy_start = $from_segment_start;
                              $from_copy_start_max = $from_segment_end - $copy_len;
          Application/Platform/System/Protocol/Difference/finediff.php on lines 562..594

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 113.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          There are no issues that match your filters.

          Category
          Status