arastta/arastta

View on GitHub
system/PHPExcel/Classes/PHPExcel/Calculation/TextData.php

Summary

Maintainability
F
4 days
Test Coverage

File TextData.php has 340 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * PHPExcel
 *
 * Copyright (c) 2006 - 2014 PHPExcel
Severity: Minor
Found in system/PHPExcel/Classes/PHPExcel/Calculation/TextData.php - About 4 hrs to fix

    Function SUBSTITUTE has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function SUBSTITUTE($text = '', $fromText = '', $toText = '', $instance = 0) {
            $text        = PHPExcel_Calculation_Functions::flattenSingleValue($text);
            $fromText    = PHPExcel_Calculation_Functions::flattenSingleValue($fromText);
            $toText        = PHPExcel_Calculation_Functions::flattenSingleValue($toText);
            $instance    = floor(PHPExcel_Calculation_Functions::flattenSingleValue($instance));
    Severity: Minor
    Found in system/PHPExcel/Classes/PHPExcel/Calculation/TextData.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

    PHPExcel_Calculation_TextData has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class PHPExcel_Calculation_TextData {
    
        private static $_invalidChars = Null;
    
        private static function _uniord($c) {
    Severity: Minor
    Found in system/PHPExcel/Classes/PHPExcel/Calculation/TextData.php - About 2 hrs to fix

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

          public static function SEARCHSENSITIVE($needle,$haystack,$offset=1) {
              $needle        = PHPExcel_Calculation_Functions::flattenSingleValue($needle);
              $haystack    = PHPExcel_Calculation_Functions::flattenSingleValue($haystack);
              $offset        = PHPExcel_Calculation_Functions::flattenSingleValue($offset);
      
      
      Severity: Minor
      Found in system/PHPExcel/Classes/PHPExcel/Calculation/TextData.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 SEARCHINSENSITIVE has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function SEARCHINSENSITIVE($needle,$haystack,$offset=1) {
              $needle        = PHPExcel_Calculation_Functions::flattenSingleValue($needle);
              $haystack    = PHPExcel_Calculation_Functions::flattenSingleValue($haystack);
              $offset        = PHPExcel_Calculation_Functions::flattenSingleValue($offset);
      
      
      Severity: Minor
      Found in system/PHPExcel/Classes/PHPExcel/Calculation/TextData.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 ASCIICODE has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function ASCIICODE($characters) {
              if (($characters === NULL) || ($characters === ''))
                  return PHPExcel_Calculation_Functions::VALUE();
              $characters    = PHPExcel_Calculation_Functions::flattenSingleValue($characters);
              if (is_bool($characters)) {
      Severity: Minor
      Found in system/PHPExcel/Classes/PHPExcel/Calculation/TextData.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 SUBSTITUTE has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function SUBSTITUTE($text = '', $fromText = '', $toText = '', $instance = 0) {
              $text        = PHPExcel_Calculation_Functions::flattenSingleValue($text);
              $fromText    = PHPExcel_Calculation_Functions::flattenSingleValue($fromText);
              $toText        = PHPExcel_Calculation_Functions::flattenSingleValue($toText);
              $instance    = floor(PHPExcel_Calculation_Functions::flattenSingleValue($instance));
      Severity: Minor
      Found in system/PHPExcel/Classes/PHPExcel/Calculation/TextData.php - About 1 hr to fix

        Method VALUE has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function VALUE($value = '') {
                $value    = PHPExcel_Calculation_Functions::flattenSingleValue($value);
        
                if (!is_numeric($value)) {
                    $numberValue = str_replace(
        Severity: Minor
        Found in system/PHPExcel/Classes/PHPExcel/Calculation/TextData.php - About 1 hr to fix

          Function VALUE has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function VALUE($value = '') {
                  $value    = PHPExcel_Calculation_Functions::flattenSingleValue($value);
          
                  if (!is_numeric($value)) {
                      $numberValue = str_replace(
          Severity: Minor
          Found in system/PHPExcel/Classes/PHPExcel/Calculation/TextData.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 _uniord has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              private static function _uniord($c) {
                  if (ord($c{0}) >=0 && ord($c{0}) <= 127)
                      return ord($c{0});
                  if (ord($c{0}) >= 192 && ord($c{0}) <= 223)
                      return (ord($c{0})-192)*64 + (ord($c{1})-128);
          Severity: Minor
          Found in system/PHPExcel/Classes/PHPExcel/Calculation/TextData.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 CONCATENATE has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function CONCATENATE() {
                  // Return value
                  $returnValue = '';
          
                  // Loop through arguments
          Severity: Minor
          Found in system/PHPExcel/Classes/PHPExcel/Calculation/TextData.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 0;
          Severity: Major
          Found in system/PHPExcel/Classes/PHPExcel/Calculation/TextData.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return $text;
            Severity: Major
            Found in system/PHPExcel/Classes/PHPExcel/Calculation/TextData.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return (float) $value;
              Severity: Major
              Found in system/PHPExcel/Classes/PHPExcel/Calculation/TextData.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return PHPExcel_Calculation_Functions::VALUE();
                Severity: Major
                Found in system/PHPExcel/Classes/PHPExcel/Calculation/TextData.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return (ord($c{0})-252)*1073741824 + (ord($c{1})-128)*16777216 + (ord($c{2})-128)*262144 + (ord($c{3})-128)*4096 + (ord($c{4})-128)*64 + (ord($c{5})-128);
                  Severity: Major
                  Found in system/PHPExcel/Classes/PHPExcel/Calculation/TextData.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return (ord($c{0})-248)*16777216 + (ord($c{1})-128)*262144 + (ord($c{2})-128)*4096 + (ord($c{3})-128)*64 + (ord($c{4})-128);
                    Severity: Major
                    Found in system/PHPExcel/Classes/PHPExcel/Calculation/TextData.php - About 30 mins to fix

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

                          public static function DOLLAR($value = 0, $decimals = 2) {
                              $value        = PHPExcel_Calculation_Functions::flattenSingleValue($value);
                              $decimals    = is_null($decimals) ? 0 : PHPExcel_Calculation_Functions::flattenSingleValue($decimals);
                      
                              // Validate parameters
                      Severity: Minor
                      Found in system/PHPExcel/Classes/PHPExcel/Calculation/TextData.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

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

                          public static function SEARCHINSENSITIVE($needle,$haystack,$offset=1) {
                              $needle        = PHPExcel_Calculation_Functions::flattenSingleValue($needle);
                              $haystack    = PHPExcel_Calculation_Functions::flattenSingleValue($haystack);
                              $offset        = PHPExcel_Calculation_Functions::flattenSingleValue($offset);
                      
                      
                      Severity: Major
                      Found in system/PHPExcel/Classes/PHPExcel/Calculation/TextData.php and 1 other location - About 7 hrs to fix
                      system/PHPExcel/Classes/PHPExcel/Calculation/TextData.php on lines 232..257

                      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 236.

                      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

                          public static function SEARCHSENSITIVE($needle,$haystack,$offset=1) {
                              $needle        = PHPExcel_Calculation_Functions::flattenSingleValue($needle);
                              $haystack    = PHPExcel_Calculation_Functions::flattenSingleValue($haystack);
                              $offset        = PHPExcel_Calculation_Functions::flattenSingleValue($offset);
                      
                      
                      Severity: Major
                      Found in system/PHPExcel/Classes/PHPExcel/Calculation/TextData.php and 1 other location - About 7 hrs to fix
                      system/PHPExcel/Classes/PHPExcel/Calculation/TextData.php on lines 268..293

                      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 236.

                      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

                                  return (ord($c{0})-248)*16777216 + (ord($c{1})-128)*262144 + (ord($c{2})-128)*4096 + (ord($c{3})-128)*64 + (ord($c{4})-128);
                      Severity: Minor
                      Found in system/PHPExcel/Classes/PHPExcel/Calculation/TextData.php and 1 other location - About 30 mins to fix
                      system/PHPExcel/Classes/PHPExcel/Calculation/TextData.php on lines 62..62

                      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 90.

                      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

                                  return (ord($c{0})-252)*1073741824 + (ord($c{1})-128)*16777216 + (ord($c{2})-128)*262144 + (ord($c{3})-128)*4096 + (ord($c{4})-128)*64 + (ord($c{5})-128);
                      Severity: Minor
                      Found in system/PHPExcel/Classes/PHPExcel/Calculation/TextData.php and 1 other location - About 30 mins to fix
                      system/PHPExcel/Classes/PHPExcel/Calculation/TextData.php on lines 60..60

                      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 90.

                      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