wsssoftware/cakephp-datatables

View on GitHub

Showing 44 of 74 total issues

Method getConfigBundle has 29 lines of code (exceeds 25 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

    Method getFilesBody has 28 lines of code (exceeds 25 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 1 hr to fix

      Method checkKeysValueTypesOrFail has 27 lines of code (exceeds 25 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

        Method init has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

          Method normalizeDataTableField has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function normalizeDataTableField(string $dataBaseField): array {
                  $ormTable = $this->getConfigBundle()->getDataTables()->getOrmTable();
                  $explodedDataBaseField = explode('.', $dataBaseField);
                  if (count($explodedDataBaseField) === 2) {
                      $table = Inflector::camelize($explodedDataBaseField[0]);
          Severity: Minor
          Found in src/Table/Columns.php - About 1 hr to fix

            Method getFormattedColumn has 26 lines of code (exceeds 25 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

              Method buildOptionParser has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser {
                      $parser = $this->_setCommonOptions($parser);
                      $parser->setDescription(
                          sprintf('Bake the plugin DataTables necessaries files.')
                      )->addArgument('type', [
              Severity: Minor
              Found in src/Command/DataTablesCommand.php - About 1 hr to fix

                Function setColumns has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function setColumns(Columns $columns) {
                        $columnsConfig = [];
                        foreach ($columns->getColumns() as $column) {
                            if ($column->isDatabase() === false) {
                                $column->setSearchable(false);
                Severity: Minor
                Found in src/Table/Option/MainOption.php - About 55 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 getConfigAsArray has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function getConfigAsArray(?bool $printAllOptions = null): array {
                        $assets = $this->_configBundle->Assets;
                        if ($assets->isAutoload()) {
                            if (!empty($this->getConfig('select')) && !$assets->isLoadPluginSelect()) {
                                $assets->setLoadPluginSelect(true);
                Severity: Minor
                Found in src/Table/Option/MainOption.php - About 45 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 getConfig has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function getConfig(bool $onlyDirty = true, bool $isDefaultColumn = false): array {
                        $result = [];
                        if ($onlyDirty === false) {
                            $result = $this->_config;
                        }
                Severity: Minor
                Found in src/Table/Column.php - About 45 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 checkIfHaveCustomItemsInSession has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function checkIfHaveCustomItemsInSession(ConfigBundle $configBundle): ConfigBundle {
                        $md5s = [
                            Functions::getInstance()->getConfigBundleAndUrlUniqueMd5($configBundle),
                            Functions::getInstance()->getConfigBundleAndUrlUniqueMd5($configBundle, true),
                        ];
                Severity: Minor
                Found in src/Table/Builder.php - About 45 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

                Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    public function __construct(View $view, string $dataTables, string $name, array $url, array $options) {
                Severity: Minor
                Found in src/Table/UrlQueryBuilder.php - About 35 mins to fix

                  Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      public function __construct(string $name, bool $database = true, array $columnSchema = [], string $associationPath = '', ?FunctionExpression $functionExpression = null) {
                  Severity: Minor
                  Found in src/Table/Column.php - About 35 mins to fix

                    Function setPluginSelectLanguageColumns has a Cognitive Complexity of 7 (exceeds 5 allowed). 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: Minor
                    Found in src/Table/Option/Section/PluginSelectTrait.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

                    Function setRenderer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function setRenderer($renderer) {
                            $rendererType = getType($renderer);
                            if (!in_array($rendererType, ['string', 'array'])) {
                                throw new InvalidArgumentException("\$renderer must be a string or array. Found: $rendererType.");
                            }
                    Severity: Minor
                    Found in src/Table/Option/Section/OptionsOptionPZTrait.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

                    Function setOrderFixed has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function setOrderFixed(array $orderFixed) {
                            if (getType(Functions::getInstance()->arrayKeyFirst($orderFixed)) === 'string') {
                                foreach ($orderFixed as $key => $objectItem) {
                                    if (!in_array($key, ['pre', 'post'])) {
                                        throw new InvalidArgumentException("You must use only 'pre' or 'post' key for objects type. Found: $key.");
                    Severity: Minor
                    Found in src/Table/Option/Section/OptionsOptionAOTrait.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

                    Function getFind has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function getFind(): Query {
                            $select = [];
                            $contains = [];
                            $columns = $this->_configBundle->Columns;
                            $table = $this->_configBundle->getDataTables()->getOrmTable();
                    Severity: Minor
                    Found in src/Table/TableDataUtils.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

                    Function setPluginSelectLanguageCells has a Cognitive Complexity of 7 (exceeds 5 allowed). 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: Minor
                    Found in src/Table/Option/Section/PluginSelectTrait.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

                    Function setPluginSelectLanguageRows has a Cognitive Complexity of 7 (exceeds 5 allowed). 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: Minor
                    Found in src/Table/Option/Section/PluginSelectTrait.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 static::CODE_SUCCESS;
                    Severity: Major
                    Found in src/Command/DataTablesCommand.php - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language