wsssoftware/cakephp-datatables

View on GitHub

Showing 74 of 74 total issues

Assets has 47 functions (exceeds 20 allowed). Consider refactoring.
Open

class Assets {

    public const BASE_CSS_URL = [
        'prefix' => false,
        'plugin' => 'DataTables',
Severity: Minor
Found in src/Table/Assets.php - About 6 hrs to fix

    OptionsOptionAOTraitTest has 35 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class OptionsOptionAOTraitTest extends TestCase {
    
        /**
         * Test subject
         *
    Severity: Minor
    Found in tests/TestCase/Table/Option/Section/OptionsOptionAOTraitTest.php - About 4 hrs to fix

      Column has 32 functions (exceeds 20 allowed). Consider refactoring.
      Open

      final class Column {
      
          public const TYPE_DATE = 'date';
          public const TYPE_NUM = 'num';
          public const TYPE_NUM_FMT = 'num-fmt';
      Severity: Minor
      Found in src/Table/Column.php - About 4 hrs to fix

        QueryBaseState has 31 functions (exceeds 20 allowed). Consider refactoring.
        Open

        final class QueryBaseState {
        
            /**
             * @var array
             */
        Severity: Minor
        Found in src/Table/QueryBaseState.php - About 3 hrs to fix

          Function processUrlQuery has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

              private function processUrlQuery() {
                  $urlQuery = Router::getRequest()->getQuery("data-tables.{$this->_configBundle->getDataTables()->getAlias()}");
                  if (!empty($urlQuery['page'])) {
                      $this->setCurrentPage($urlQuery['page']);
                  }
          Severity: Minor
          Found in src/Table/Option/MainOption.php - About 3 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

          OptionsOptionPZTraitTest has 29 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class OptionsOptionPZTraitTest extends TestCase {
          
              /**
               * Test subject
               *
          Severity: Minor
          Found in tests/TestCase/Table/Option/Section/OptionsOptionPZTraitTest.php - About 3 hrs to fix

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

                public function setPluginSelectLanguageCells($cells) {
                    if (!in_array(getType($cells), ['string', 'array'])) {
                        throw new InvalidArgumentException('Cells must be a string or a array with plural translations.');
                    } elseif (is_array($cells)) {
                        $allowedKeys = ['_', '0', '1'];
            Severity: Major
            Found in src/Table/Option/Section/PluginSelectTrait.php and 2 other locations - About 3 hrs to fix
            src/Table/Option/Section/PluginSelectTrait.php on lines 115..129
            src/Table/Option/Section/PluginSelectTrait.php on lines 168..182

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

            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 3 locations. Consider refactoring.
            Open

                public function setPluginSelectLanguageColumns($columns) {
                    if (!in_array(getType($columns), ['string', 'array'])) {
                        throw new InvalidArgumentException('Columns must be a string or a array with plural translations.');
                    } elseif (is_array($columns)) {
                        $allowedKeys = ['_', '0', '1'];
            Severity: Major
            Found in src/Table/Option/Section/PluginSelectTrait.php and 2 other locations - About 3 hrs to fix
            src/Table/Option/Section/PluginSelectTrait.php on lines 62..76
            src/Table/Option/Section/PluginSelectTrait.php on lines 168..182

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

            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 3 locations. Consider refactoring.
            Open

                public function setPluginSelectLanguageRows($rows) {
                    if (!in_array(getType($rows), ['string', 'array'])) {
                        throw new InvalidArgumentException('Rows must be a string or a array with plural translations.');
                    } elseif (is_array($rows)) {
                        $allowedKeys = ['_', '0', '1'];
            Severity: Major
            Found in src/Table/Option/Section/PluginSelectTrait.php and 2 other locations - About 3 hrs to fix
            src/Table/Option/Section/PluginSelectTrait.php on lines 62..76
            src/Table/Option/Section/PluginSelectTrait.php on lines 115..129

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

            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

            File Assets.php has 307 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            /**
             * Copyright (c) Allan Carvalho 2020.
             * Under Mit License
             * link: https://github.com/wsssoftware/cakephp-data-renderer
            Severity: Minor
            Found in src/Table/Assets.php - About 3 hrs to fix

              Function execute has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function execute(Arguments $args, ConsoleIo $io): ?int {
                      $this->_bakeType = $args->getArgument('type');
                      $this->_configName = Inflector::camelize($args->getArgument('configName'));
                      $this->_callback = $args->getArgument('callback');
                      $this->connection = $args->getOption('connection');
              Severity: Minor
              Found in src/Command/DataTablesCommand.php - About 3 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

              LanguageOptionTraitTest has 25 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class LanguageOptionTraitTest extends TestCase {
              
                  /**
                   * Test subject
                   *
              Severity: Minor
              Found in tests/TestCase/Table/Option/Section/LanguageOptionTraitTest.php - About 2 hrs to fix

                Function getFilesBody has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function getFilesBody(array $query, string $type): string {
                        $files = [];
                        $md5 = $type . '_' . md5(json_encode($query));
                        $body = Cache::read($md5, '_data_tables_assets_');
                        if ($body === null) {
                Severity: Minor
                Found in src/Controller/Component/AssetsTrait.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

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

                    public function testOrderable() {
                        $col = $this->Columns->getColumnByIndex(0);
                        static::assertEquals(null, $col->isOrderable());
                        $col->setOrderable(true);
                        static::assertEquals(true, $col->isOrderable());
                Severity: Major
                Found in tests/TestCase/Table/ColumnTest.php and 2 other locations - About 2 hrs to fix
                tests/TestCase/Table/ColumnTest.php on lines 229..238
                tests/TestCase/Table/ColumnTest.php on lines 273..282

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

                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 3 locations. Consider refactoring.
                Open

                    public function testVisible() {
                        $col = $this->Columns->getColumnByIndex(0);
                        static::assertEquals(null, $col->isVisible());
                        $col->setVisible(true);
                        static::assertEquals(true, $col->isVisible());
                Severity: Major
                Found in tests/TestCase/Table/ColumnTest.php and 2 other locations - About 2 hrs to fix
                tests/TestCase/Table/ColumnTest.php on lines 215..224
                tests/TestCase/Table/ColumnTest.php on lines 229..238

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

                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 3 locations. Consider refactoring.
                Open

                    public function testSearchable() {
                        $col = $this->Columns->getColumnByIndex(0);
                        static::assertEquals(null, $col->isSearchable());
                        $col->setSearchable(true);
                        static::assertEquals(true, $col->isSearchable());
                Severity: Major
                Found in tests/TestCase/Table/ColumnTest.php and 2 other locations - About 2 hrs to fix
                tests/TestCase/Table/ColumnTest.php on lines 215..224
                tests/TestCase/Table/ColumnTest.php on lines 273..282

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

                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

                Method execute has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function execute(Arguments $args, ConsoleIo $io): ?int {
                        $this->_bakeType = $args->getArgument('type');
                        $this->_configName = Inflector::camelize($args->getArgument('configName'));
                        $this->_callback = $args->getArgument('callback');
                        $this->connection = $args->getOption('connection');
                Severity: Minor
                Found in src/Command/DataTablesCommand.php - About 1 hr to fix

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

                      private function getFormattedColumn(string $columnName, Column $column, EntityInterface $entity): string {
                          $exploded = explode('.', $columnName);
                          if (count($exploded) === 2) {
                              $value = $this->getPropertyUsingPath($column->getAssociationPath(), $entity, $exploded[1]);
                              $integersTypes = ['tinyinteger', 'smallinteger', 'integer', 'biginteger', 'decimal', 'float'];
                  Severity: Minor
                  Found in src/Table/Renderer.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 setSearchCols has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function setSearchCols(array $searchCols) {
                          Validator::getInstance()->checkKeysValueTypesOrFail($searchCols, ['integer'], ['array', 'NULL'], '$searchCols');
                          foreach ($searchCols as $searchCol) {
                              if ($searchCol !== null) {
                                  foreach ($searchCol as $key => $item) {
                  Severity: Minor
                  Found in src/Table/Option/Section/OptionsOptionPZTrait.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 testSimpleOptions has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function testSimpleOptions() {
                          $autoWidth = $this->MainOption->isAutoWidth();
                          $this->MainOption->setAutoWidth(!$autoWidth);
                          $this->assertEquals(!$autoWidth, $this->MainOption->isAutoWidth());
                  
                  
                  Severity: Minor
                  Found in tests/TestCase/Table/Option/Section/FeaturesOptionTraitTest.php - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language