Mirocow/yii2-elasticsearch

View on GitHub

Showing 31 of 34 total issues

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

    public static function createIndex($className, $indexConfig = [])
    {
        if(!class_exists($className)){
            throw new SearchQueryException("Index class not found");
        }
Severity: Minor
Found in src/components/factories/IndexerFactory.php - About 1 hr to fix

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

        private static function buildOrderBy($columns) :array
        {
            $orders = [];
            foreach ($columns as $name => $direction) {
                if (is_string($direction)) {
    Severity: Minor
    Found in src/components/queries/helpers/QueryHelper.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 generateQuery has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function generateQuery($nestedAggs = [])
        {
            if (empty($nestedAggs)) {
                $nestedAggs = $this->nestedAggs;
                if ($this->nestedAggMulti !== null) {
    Severity: Minor
    Found in src/components/queries/Aggregation/Aggregation.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 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function __construct(string $requestQuery, string $message = null, $code = 0, $filename = __FILE__, $lineno = __LINE__, \Exception $previous = null)
    Severity: Minor
    Found in src/exceptions/SearchQueryException.php - About 45 mins to fix

      Function prepareModels has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function prepareModels()
          {
      
              if (!$this->query instanceof QueryBuilder) {
                  throw new InvalidConfigException('The "query" property must be an instance of a class \mirocow\elasticsearch\components\queries\QueryBuilder or its subclasses.');
      Severity: Minor
      Found in src/components/indexes/SearchDataProvider.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 dateHistogram has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public function dateHistogram($field, $dateHistogramOptions = [], $nestedAgg = null, $aggName = '', $keyAsString = true)
      Severity: Minor
      Found in src/components/queries/AggBuilder.php - About 35 mins to fix

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

            public function range($field, $ranges, $rangeOptions = [], $nestedAgg = null, $aggName = '')
        Severity: Minor
        Found in src/components/queries/AggBuilder.php - About 35 mins to fix

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

              public function filter($field, $query, $nestedAgg = null, $aggName = '', $filterKey = '')
          Severity: Minor
          Found in src/components/queries/AggBuilder.php - About 35 mins to fix

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

                public function result()
                {
                    if($this->result instanceof SearchResponseIterator){
                        return new SearchHitIterator($this->result);
                    } else {
            Severity: Minor
            Found in src/components/indexes/AbstractSearchIndex.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 generateQuery has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function generateQuery()
                {
            
                    $fields = [
            
            
            Severity: Minor
            Found in src/components/queries/QueryBuilder.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 index has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function index($document)
                {
                    foreach ($this->indexes as $index) {
                        if (!$index->accepts($document)) {
                            continue;
            Severity: Minor
            Found in src/components/indexers/SearchIndexer.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