luyadev/yii-helpers

View on GitHub

Showing 51 of 53 total issues

File XLSXWriter.php has 1038 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace luya\yii\helpers;

use ZipArchive;
Severity: Major
Found in src/helpers/XLSXWriter.php - About 2 days to fix

    Function numberFormatStandardized has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
    Open

        private static function numberFormatStandardized($num_format)
        {
            if ($num_format == 'money') {
                $num_format = 'dollar';
            }
    Severity: Minor
    Found in src/helpers/XLSXWriter.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 styleFontIndexes has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function styleFontIndexes()
        {
            static $border_allowed = ['left', 'right', 'top', 'bottom'];
            static $border_style_allowed = [
                'thin',
    Severity: Minor
    Found in src/helpers/XLSXWriter.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

    XLSXWriter has 41 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class XLSXWriter
    {
        //https://www.ecma-international.org/publications/standards/Ecma-376.htm
        //http://officeopenxml.com/SSstyles.php
        //------------------------------------------------------------------
    Severity: Minor
    Found in src/helpers/XLSXWriter.php - About 5 hrs to fix

      Function generateContentArray has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

          protected static function generateContentArray($contentRows, array $keys, $generateHeader = true, $options  = [])
          {
              if (is_scalar($contentRows)) {
                  throw new Exception("Content must be either an array, object or traversable.");
              }
      Severity: Minor
      Found in src/helpers/ExportHelper.php - About 5 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 writeStylesXML has 123 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function writeStylesXML()
          {
              $r = $this->styleFontIndexes();
              $fills = $r['fills'];
              $fonts = $r['fonts'];
      Severity: Major
      Found in src/helpers/XLSXWriter.php - About 4 hrs to fix

        Function writeStylesXML has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function writeStylesXML()
            {
                $r = $this->styleFontIndexes();
                $fills = $r['fills'];
                $fonts = $r['fonts'];
        Severity: Minor
        Found in src/helpers/XLSXWriter.php - About 4 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 styleFontIndexes has 102 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function styleFontIndexes()
            {
                static $border_allowed = ['left', 'right', 'top', 'bottom'];
                static $border_style_allowed = [
                    'thin',
        Severity: Major
        Found in src/helpers/XLSXWriter.php - About 4 hrs to fix

          Method initializeSheet has 96 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function initializeSheet(
                  $sheet_name,
                  $col_widths = [],
                  $auto_filter = false,
                  $freeze_rows = false,
          Severity: Major
          Found in src/helpers/XLSXWriter.php - About 3 hrs to fix

            Function csvFromResource has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function csvFromResource($resource, array $options = []): array
                {
                    if (!is_resource($resource)) {
                        throw new \InvalidArgumentException("The provided resource is not a valid resource.");
                    }
            Severity: Minor
            Found in src/helpers/ImportHelper.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 highlightWord has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function highlightWord($content, $word, $markup = '<b>%s</b>')
                {
                    $transliterateContent = Inflector::transliterate($content);
                    $highlights = [];
            
            
            Severity: Minor
            Found in src/helpers/StringHelper.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 convert_date_time has 56 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function convert_date_time($date_input) //thanks to Excel::Writer::XLSX::Worksheet.pm (perl)
                {
                    $days = 0;    # Number of days since epoch
                    $seconds = 0;    # Time expressed as fraction of 24h hours in seconds
                    $year = $month = $day = 0;
            Severity: Major
            Found in src/helpers/XLSXWriter.php - About 2 hrs to fix

              Method numberFormatStandardized has 55 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private static function numberFormatStandardized($num_format)
                  {
                      if ($num_format == 'money') {
                          $num_format = 'dollar';
                      }
              Severity: Major
              Found in src/helpers/XLSXWriter.php - About 2 hrs to fix

                Function writeCell has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function writeCell(
                        XLSXWriter_BuffererWriter &$file,
                        $row_number,
                        $column_number,
                        $value,
                Severity: Minor
                Found in src/helpers/XLSXWriter.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 generateContentArray has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected static function generateContentArray($contentRows, array $keys, $generateHeader = true, $options  = [])
                    {
                        if (is_scalar($contentRows)) {
                            throw new Exception("Content must be either an array, object or traversable.");
                        }
                Severity: Minor
                Found in src/helpers/ExportHelper.php - About 1 hr to fix

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

                      public static function unlink($file)
                      {
                          // no errors should be thrown, return false instead.
                          try {
                              if (parent::unlink($file)) {
                  Severity: Minor
                  Found in src/helpers/FileHelper.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 writeToFile has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function writeToFile($filename)
                      {
                          foreach ($this->sheets as $sheet_name => $sheet) {
                              $this->finalizeSheet($sheet_name);//making sure all footers have been written
                          }
                  Severity: Minor
                  Found in src/helpers/XLSXWriter.php - About 1 hr to fix

                    Method writeSheetRow has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function writeSheetRow($sheet_name, array $row, $row_options = null)
                        {
                            if (empty($sheet_name)) {
                                return;
                            }
                    Severity: Minor
                    Found in src/helpers/XLSXWriter.php - About 1 hr to fix

                      Method highlightWord has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public static function highlightWord($content, $word, $markup = '<b>%s</b>')
                          {
                              $transliterateContent = Inflector::transliterate($content);
                              $highlights = [];
                      
                      
                      Severity: Minor
                      Found in src/helpers/StringHelper.php - About 1 hr to fix

                        Function convert_date_time has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public static function convert_date_time($date_input) //thanks to Excel::Writer::XLSX::Worksheet.pm (perl)
                            {
                                $days = 0;    # Number of days since epoch
                                $seconds = 0;    # Time expressed as fraction of 24h hours in seconds
                                $year = $month = $day = 0;
                        Severity: Minor
                        Found in src/helpers/XLSXWriter.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

                        Severity
                        Category
                        Status
                        Source
                        Language