CORE-POS/IS4C

View on GitHub
fannie/classlib2.0/data/FileData.php

Summary

Maintainability
C
1 day
Test Coverage
F
16%

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

    public static function xlsToArray($filename, $limit)
    {
        /** 
          PhpOffice can read both file variants just fine if it's
          available.
Severity: Minor
Found in fannie/classlib2.0/data/FileData.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 xlsxToArray has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function xlsxToArray($filename, $limit=0)
    {
        if (!class_exists('\\PhpOffice\\PhpSpreadsheet\\IOFactory') && !class_exists('\\PHPExcel_IOFactory')) {
            return false;
        }
Severity: Minor
Found in fannie/classlib2.0/data/FileData.php - About 1 hr to fix

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

        public static function xlsToArray($filename, $limit)
        {
            /** 
              PhpOffice can read both file variants just fine if it's
              available.
    Severity: Minor
    Found in fannie/classlib2.0/data/FileData.php - About 1 hr to fix

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

          public static function xlsxToArray($filename, $limit=0)
          {
              if (!class_exists('\\PhpOffice\\PhpSpreadsheet\\IOFactory') && !class_exists('\\PHPExcel_IOFactory')) {
                  return false;
              }
      Severity: Minor
      Found in fannie/classlib2.0/data/FileData.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 excelNoFormula has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function excelNoFormula($str)
          {
              $str = trim($str);
              $first = substr(trim($str), 0, 1);
              while ($first == '=' || $first == '@' || $first == '+' || $first == '-') {
      Severity: Minor
      Found in fannie/classlib2.0/data/FileData.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 array();
      Severity: Major
      Found in fannie/classlib2.0/data/FileData.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                        return self::txtToArray($filename, $limit);
        Severity: Major
        Found in fannie/classlib2.0/data/FileData.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return self::pdfToArray($filename, $limit);
          Severity: Major
          Found in fannie/classlib2.0/data/FileData.php - About 30 mins to fix

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

                public static function txtToArray($filename, $limit=0)
                {
                    $fptr = fopen($filename,'r');
                    if (!$fptr) {
                        return array();
            Severity: Minor
            Found in fannie/classlib2.0/data/FileData.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

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

                public static function csvToArray($filename, $limit=0)
                {
                    $fptr = fopen($filename,'r');
                    if (!$fptr) {
                        return array();
            Severity: Minor
            Found in fannie/classlib2.0/data/FileData.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