allanmcarvalho/cakephp-datatables

View on GitHub

Showing 18 of 20 total issues

OptionsOption has 51 functions (exceeds 20 allowed). Consider refactoring.
Open

final class OptionsOption extends ChildOptionAbstract {

    const ALLOWED_PAGING_TYPES = [
        'numbers',
        'simple',
Severity: Major
Found in src/Table/Option/Section/OptionsOption.php - About 7 hrs to fix

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

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

      File OptionsOption.php has 319 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /**
       * Copyright (c) Allan Carvalho 2020.
       * Under Mit License
       * php version 7.2
      Severity: Minor
      Found in src/Table/Option/Section/OptionsOption.php - About 3 hrs to fix

        FeaturesOption has 24 functions (exceeds 20 allowed). Consider refactoring.
        Open

        final class FeaturesOption extends ChildOptionAbstract {
        
            /**
             * @var array
             * @inheritDoc
        Severity: Minor
        Found in src/Table/Option/Section/FeaturesOption.php - About 2 hrs to fix

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

              public function setSearchCols(array $searchCols): MainOption {
                  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/OptionsOption.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 isInCurrentUrl has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              public function isInCurrentUrl(array $url = []): bool {
                  $currentController = Router::getRequest()->getParam('controller');
                  $currentAction = Router::getRequest()->getParam('action');
                  $currentQuery = Router::getRequest()->getQuery();
                  $currentPrefix = Router::getRequest()->getParam('prefix');
          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

          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

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

              private function normalizeDataTableField(string $dataBaseField, ?string $title): Column {
                  $ormTable = $this->_tables->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

          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 isInCurrentUrl has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function isInCurrentUrl(array $url = []): bool {
                  $currentController = Router::getRequest()->getParam('controller');
                  $currentAction = Router::getRequest()->getParam('action');
                  $currentQuery = Router::getRequest()->getQuery();
                  $currentPrefix = Router::getRequest()->getParam('prefix');
          Severity: Minor
          Found in src/Tools/Functions.php - About 1 hr to fix

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

                private function normalizeDataTableField(string $dataBaseField, ?string $title): Column {
                    $ormTable = $this->_tables->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 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

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

                    public function setDefault(Column $column): void {
                        $ignoredMethods = ['setDefault', 'setTitle', 'setDatabase', 'setName'];
                        $methods = get_class_methods($this);
                        foreach ($methods as $method) {
                            if (substr($method, 0, 3) === 'set' && !in_array($method, $ignoredMethods)) {
                Severity: Minor
                Found in src/Table/Column.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

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

                    private function getUrlMd5(string $controller, string $action, array $query = [], ?string $prefix = null, array $pass = []): string {
                Severity: Minor
                Found in src/Tools/Functions.php - About 35 mins to fix

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

                      public function setRenderer($renderer): MainOption {
                          $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/OptionsOption.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): MainOption {
                          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/OptionsOption.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 setOrder has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function setOrder(array $order): MainOption {
                          Validator::getInstance()->checkKeysValueTypesOrFail($order, 'integer', 'array', '$order');
                          foreach ($order as $item) {
                              Validator::getInstance()->checkArraySizeOrFail($item, 2, 'In setOrder($order) you must pass the index and order (asc or desc). Eg.: [0, \'asc\'].');
                              Validator::getInstance()->checkKeysValueTypesOrFail($item, 'integer', ['integer', 'string'], '$order');
                  Severity: Minor
                  Found in src/Table/Option/Section/OptionsOption.php - About 25 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 getConfigBundle has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function getConfigBundle(string $tableAndConfig, bool $cache = true): ConfigBundle {
                          $exploded = explode('::', $tableAndConfig);
                          if (count($exploded) !== 2) {
                              throw new InvalidArgumentException('Table param must be a concatenation of Tables class and config. Eg.: Foo::method.');
                          }
                  Severity: Minor
                  Found in src/Tools/Builder.php - About 25 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 checkOrderDefault has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private function checkOrderDefault(array $orderFixed) {
                          Validator::getInstance()->checkKeysValueTypesOrFail($orderFixed, ['integer', 'string'], 'array', '$orderFixed');
                          foreach ($orderFixed as $item) {
                              Validator::getInstance()->checkArraySizeOrFail($item, 2, "In \$orderFixed you must pass the index and after the order (asc or desc). Eg.: [0, 'asc'].");
                              $param1 = $item[Functions::getInstance()->arrayKeyFirst($item)];
                  Severity: Minor
                  Found in src/Table/Option/Section/OptionsOption.php - About 25 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

                  Severity
                  Category
                  Status
                  Source
                  Language