Showing 190 of 190 total issues

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

    public function process(\ECL\SymbolTable $table) {
        $result = $table[\ECL\SymbolTable::DEFAULT_SYMBOL];
        $ret = [];

        $key_cache = [];
Severity: Minor
Found in src/Command/Map.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

The class Elasticsearch has an overall complexity of 57 which is very high. The configured complexity threshold is 50.
Open

class Elasticsearch extends \ECL\Command {
    /** @var \Elasticsearch\Client Client object. */
    private $client = null;
    /** @var \Elasticsearch\Client Client object for indexing. */
    private $index_client = null;
Severity: Minor
Found in src/Command/Elasticsearch.php by phpmd

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

    public function process(\ECL\SymbolTable $table) {
        $result = $table[\ECL\SymbolTable::DEFAULT_SYMBOL];
        $source = $table->resolve(new \ECL\Symbol($this->source), \ECL\Symbol::T_RES);
        // Convert a left join into a right join.
        if($this->type == self::T_LEFT) {
Severity: Minor
Found in src/Command/Join.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

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

    private function resolveFilter(\ECL\SymbolTable $table, $node) {
        if(is_array($node)) {
            foreach($node as $k=>$entry) {
                $node[$k] = $this->resolveFilter($table, $entry);
            }
Severity: Minor
Found in src/Command/Elasticsearch.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

File Elasticsearch.php has 262 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace ECL\Command;

/**
Severity: Minor
Found in src/Command/Elasticsearch.php - About 2 hrs to fix

    Function resolve has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        public function resolve($sym, $type=Symbol::T_NULL) {
            $val = $sym;
            if($sym instanceof \ECL\Symbol) {
               $val = $this->offsetGet($sym->getName());
               if($type == Symbol::T_NULL) {
    Severity: Minor
    Found in src/SymbolTable.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 process has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function process(\ECL\SymbolTable $table) {
            $result = $table[\ECL\SymbolTable::DEFAULT_SYMBOL];
            $ret = [];
    
            $key_cache = [];
    Severity: Minor
    Found in src/Command/Map.php - About 1 hr to fix

      Method process has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function process(\ECL\SymbolTable $table) {
              $result = $table[\ECL\SymbolTable::DEFAULT_SYMBOL];
              $source = $table->resolve(new \ECL\Symbol($this->source), \ECL\Symbol::T_RES);
              // Convert a left join into a right join.
              if($this->type == self::T_LEFT) {
      Severity: Minor
      Found in src/Command/Join.php - About 1 hr to fix

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

            private function resolveFilter(\ECL\SymbolTable $table, $node) {
                if(is_array($node)) {
                    foreach($node as $k=>$entry) {
                        $node[$k] = $this->resolveFilter($table, $entry);
                    }
        Severity: Minor
        Found in src/Command/Elasticsearch.php - About 1 hr to fix

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

              public function resolve($sym, $type=Symbol::T_NULL) {
                  $val = $sym;
                  if($sym instanceof \ECL\Symbol) {
                     $val = $this->offsetGet($sym->getName());
                     if($type == Symbol::T_NULL) {
          Severity: Minor
          Found in src/SymbolTable.php - About 1 hr to fix

            Method constructQuery has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function constructQuery(\ECL\SymbolTable $table, array $filters, \ECL\Command\Elasticsearch\Agg $agg=null, array $settings=[]) {
                    foreach($settings as $key=>$val) {
                        $settings[$key] = $table->resolve($val);
                    }
                    $from = \ECL\Util::get($settings, 'from');
            Severity: Minor
            Found in src/Command/Elasticsearch.php - About 1 hr to fix

              Method generateDateIndices has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function generateDateIndices($format, $interval, $from_ts, $to_ts) {
                      $fmt_arr = [];
                      $escaped = false;
              
                      foreach(str_split($format) as $chr) {
              Severity: Minor
              Found in src/Util.php - About 1 hr to fix

                Method setSettings has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function setSettings(array $settings) {
                        $this->settings = $settings;
                
                        $hosts = \ECL\Util::get($settings, 'hosts', []);
                        $index_hosts = \ECL\Util::get($settings, 'index_hosts', []);
                Severity: Minor
                Found in src/Command/Elasticsearch.php - About 1 hr to fix

                  Method constructQueryBody has 9 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      private function constructQueryBody(\ECL\SymbolTable $table, array $filters, \ECL\Command\Elasticsearch\Agg $agg=null, $fields=null, $sort=null, $size=null, $date_field=null, $from=null, $to=null) {
                  Severity: Major
                  Found in src/Command/Elasticsearch.php - About 1 hr to fix

                    Function pluck has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static function pluck($arr, $path) {
                            $ret = [];
                            $path = (array) $path;
                            foreach($arr as $v) {
                                $node = &$v;
                    Severity: Minor
                    Found in src/Util.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

                    Avoid variables with short names like $ok. Configured minimum length is 3.
                    Open

                                $ok = true;
                    Severity: Minor
                    Found in src/Util.php by phpmd

                    ShortVariable

                    Since: 0.2

                    Detects when a field, local, or parameter has a very short name.

                    Example

                    class Something {
                        private $q = 15; // VIOLATION - Field
                        public static function main( array $as ) { // VIOLATION - Formal
                            $r = 20 + $this->q; // VIOLATION - Local
                            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                                $r += $this->q;
                            }
                        }
                    }

                    Source https://phpmd.org/rules/naming.html#shortvariable

                    Avoid variables with short names like $el. Configured minimum length is 3.
                    Open

                            $el = new \ECL\ExpressionLanguage;
                    Severity: Minor
                    Found in src/Command/Sort/Expr.php by phpmd

                    ShortVariable

                    Since: 0.2

                    Detects when a field, local, or parameter has a very short name.

                    Example

                    class Something {
                        private $q = 15; // VIOLATION - Field
                        public static function main( array $as ) { // VIOLATION - Formal
                            $r = 20 + $this->q; // VIOLATION - Local
                            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                                $r += $this->q;
                            }
                        }
                    }

                    Source https://phpmd.org/rules/naming.html#shortvariable

                    Avoid variables with short names like $x. Configured minimum length is 3.
                    Open

                            return implode('', array_map(function($x) {
                    Severity: Minor
                    Found in src/Command/Elasticsearch.php by phpmd

                    ShortVariable

                    Since: 0.2

                    Detects when a field, local, or parameter has a very short name.

                    Example

                    class Something {
                        private $q = 15; // VIOLATION - Field
                        public static function main( array $as ) { // VIOLATION - Formal
                            $r = 20 + $this->q; // VIOLATION - Local
                            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                                $r += $this->q;
                            }
                        }
                    }

                    Source https://phpmd.org/rules/naming.html#shortvariable

                    Avoid variables with short names like $el. Configured minimum length is 3.
                    Open

                            $el = new \ECL\ExpressionLanguage;
                    Severity: Minor
                    Found in src/Statement/Cond.php by phpmd

                    ShortVariable

                    Since: 0.2

                    Detects when a field, local, or parameter has a very short name.

                    Example

                    class Something {
                        private $q = 15; // VIOLATION - Field
                        public static function main( array $as ) { // VIOLATION - Formal
                            $r = 20 + $this->q; // VIOLATION - Local
                            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                                $r += $this->q;
                            }
                        }
                    }

                    Source https://phpmd.org/rules/naming.html#shortvariable

                    Avoid variables with short names like $el. Configured minimum length is 3.
                    Open

                            $el = new \ECL\ExpressionLanguage;
                    Severity: Minor
                    Found in src/Command/Filter.php by phpmd

                    ShortVariable

                    Since: 0.2

                    Detects when a field, local, or parameter has a very short name.

                    Example

                    class Something {
                        private $q = 15; // VIOLATION - Field
                        public static function main( array $as ) { // VIOLATION - Formal
                            $r = 20 + $this->q; // VIOLATION - Local
                            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                                $r += $this->q;
                            }
                        }
                    }

                    Source https://phpmd.org/rules/naming.html#shortvariable

                    Severity
                    Category
                    Status
                    Source
                    Language