piotrpolak/pepiscms

View on GitHub
pepiscms/application/libraries/Spreadsheet.php

Summary

Maintainability
F
6 days
Test Coverage

Function parseCSV has a Cognitive Complexity of 77 (exceeds 5 allowed). Consider refactoring.
Open

    public function parseCSV($path, $first_row_as_keys = true, $normalize_keys = true, $separator = false)
    {
        $lines = array();
        $keys = array();
        if (file_exists($path)) {
Severity: Minor
Found in pepiscms/application/libraries/Spreadsheet.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

Function generateCSV has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
Open

    public function generateCSV($feed, $headers = false, $file_name = false, $send = true, $separator = false, $print_headers = true)
    {
        if (!$separator) {
            $separator = ',';
        }
Severity: Minor
Found in pepiscms/application/libraries/Spreadsheet.php - About 7 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 generateExcel has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

    public function generateExcel($feed, $headers = false, $file_name = false, $send = true, $print_headers = true, $excel_type = Spreadsheet::EXCEL_XLS)
    {
        if (!$this->isFullyEnabled()) {
            throw new \RuntimeException("PhpSpreadsheet is not enabled. Please refer to README.md");
        }
Severity: Minor
Found in pepiscms/application/libraries/Spreadsheet.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

File Spreadsheet.php has 381 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * PepisCMS
 *
Severity: Minor
Found in pepiscms/application/libraries/Spreadsheet.php - About 5 hrs to fix

    Method generateExcel has 114 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function generateExcel($feed, $headers = false, $file_name = false, $send = true, $print_headers = true, $excel_type = Spreadsheet::EXCEL_XLS)
        {
            if (!$this->isFullyEnabled()) {
                throw new \RuntimeException("PhpSpreadsheet is not enabled. Please refer to README.md");
            }
    Severity: Major
    Found in pepiscms/application/libraries/Spreadsheet.php - About 4 hrs to fix

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

          public function parseExcel($path, $first_row_as_keys = true, $normalize_keys = true)
          {
              if (!$this->isFullyEnabled()) {
                  throw new \RuntimeException("PhpSpreadsheet is not enabled. Please refer to README.md");
              }
      Severity: Minor
      Found in pepiscms/application/libraries/Spreadsheet.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 generateCSV has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function generateCSV($feed, $headers = false, $file_name = false, $send = true, $separator = false, $print_headers = true)
          {
              if (!$separator) {
                  $separator = ',';
              }
      Severity: Major
      Found in pepiscms/application/libraries/Spreadsheet.php - About 2 hrs to fix

        Method parseCSV has 66 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function parseCSV($path, $first_row_as_keys = true, $normalize_keys = true, $separator = false)
            {
                $lines = array();
                $keys = array();
                if (file_exists($path)) {
        Severity: Major
        Found in pepiscms/application/libraries/Spreadsheet.php - About 2 hrs to fix

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

              public function generateXML($feed, $headers = false, $file_name = false, $send = true, $root_name = false, $item_name = false)
              {
                  if (!$file_name) {
                      $file_name = 'spreadsheet-' . date('Y-m-d-h-i-s') . '.xml';
                  }
          Severity: Minor
          Found in pepiscms/application/libraries/Spreadsheet.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 generateXML has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function generateXML($feed, $headers = false, $file_name = false, $send = true, $root_name = false, $item_name = false)
              {
                  if (!$file_name) {
                      $file_name = 'spreadsheet-' . date('Y-m-d-h-i-s') . '.xml';
                  }
          Severity: Major
          Found in pepiscms/application/libraries/Spreadsheet.php - About 2 hrs to fix

            Method parseExcel has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function parseExcel($path, $first_row_as_keys = true, $normalize_keys = true)
                {
                    if (!$this->isFullyEnabled()) {
                        throw new \RuntimeException("PhpSpreadsheet is not enabled. Please refer to README.md");
                    }
            Severity: Minor
            Found in pepiscms/application/libraries/Spreadsheet.php - About 1 hr to fix

              Method generateExcel has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public function generateExcel($feed, $headers = false, $file_name = false, $send = true, $print_headers = true, $excel_type = Spreadsheet::EXCEL_XLS)
              Severity: Minor
              Found in pepiscms/application/libraries/Spreadsheet.php - About 45 mins to fix

                Method generateCSV has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    public function generateCSV($feed, $headers = false, $file_name = false, $send = true, $separator = false, $print_headers = true)
                Severity: Minor
                Found in pepiscms/application/libraries/Spreadsheet.php - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                              for ($i = 0; $i < 99; $i++) {
                                                  $keys[] = $i;
                                              }
                  Severity: Major
                  Found in pepiscms/application/libraries/Spreadsheet.php - About 45 mins to fix

                    Method generateXML has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        public function generateXML($feed, $headers = false, $file_name = false, $send = true, $root_name = false, $item_name = false)
                    Severity: Minor
                    Found in pepiscms/application/libraries/Spreadsheet.php - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                                  if ($normalize_keys) {
                                                      foreach ($keys as &$key) {
                                                          $key = $this->normalizeKey($key);
                                                      }
                                                  }
                      Severity: Major
                      Found in pepiscms/application/libraries/Spreadsheet.php - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                        if (!$key) {
                                                            $key = $ki;
                                                        }
                        Severity: Major
                        Found in pepiscms/application/libraries/Spreadsheet.php - About 45 mins to fix

                          There are no issues that match your filters.

                          Category
                          Status