wsssoftware/cakephp-datatables

View on GitHub

Showing 44 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

            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

                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

                    Function getPluginCurrentCommit has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function getPluginCurrentCommit(): string {
                            $subPath = 'composer' . DS . 'installed.json';
                            $filePaths = [
                                ROOT . DS . 'vendor' . DS,
                                DATA_TABLES_ROOT . DS . '..' . DS . '..' . DS,
                    Severity: Minor
                    Found in src/Tools/Functions.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 processUrlQuery has 36 lines of code (exceeds 25 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 1 hr to fix

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

                          public function checkKeysValueTypesOrFail(?array $array, $allowedKeyTypes = [], $allowedValueTypes = [], ?string $inString = null): void {
                              if (empty($array)) {
                                  return;
                              }
                              $allowedKeyTypesType = getType($allowedKeyTypes);
                      Severity: Minor
                      Found in src/Tools/Validator.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 init has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function init(): void {
                              $this->records = [
                                  [
                                      'id' => 1,
                                      'user_id' => 1,
                      Severity: Minor
                      Found in tests/Fixture/ArticlesFixture.php - About 1 hr to fix

                        Function getConfigBundle has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function getConfigBundle(string $dataTables, bool $cache = true): ConfigBundle {
                                $dataTablesFQN = $this->parseClassNameToFQN($dataTables);
                                $dataTablesName = explode('\\', $dataTables);
                                $dataTablesName = array_pop($dataTablesName);
                                $configure = TableConfigure::getInstance();
                        Severity: Minor
                        Found in src/Table/Builder.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 getI18nTranslation has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function getI18nTranslation() {
                                $json = [
                                    'oAria' => [
                                        'sSortAscending' => __d('data_tables', '{0} activate to sort column ascending', ':'),
                                        'sSortDescending' => __d('data_tables', '{0} activate to sort column descending', ':'),
                        Severity: Minor
                        Found in src/Controller/ProviderController.php - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language