increments/es-query-builder

View on GitHub

Showing 6 of 6 total issues

Method create_bool_filters has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def create_bool_filters(filter_tokens)
      must, must_not = [], []
      filter_tokens.each do |token|
        token.term.split.each do |term|
          if @hierarchy_fields.include?(token.field)
Severity: Minor
Found in lib/es-query-builder/parser.rb - 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 create_bool_queries has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def create_bool_queries(query_tokens)
      must, must_not = [], []
      query_tokens.each do |token|
        queries = token.minus? ? must_not : must

Severity: Minor
Found in lib/es-query-builder/parser.rb - 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 build_query_hash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def build_query_hash(query_tokens)
      return { match_all: {} } if query_tokens.empty?
      must, must_not = create_bool_queries(query_tokens)
      if must.size == 1 && must_not.empty?
        must.first
Severity: Minor
Found in lib/es-query-builder/parser.rb - 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 build_filter_hash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def build_filter_hash(filter_tokens)
      return {} if filter_tokens.empty?
      must, must_not = create_bool_filters(filter_tokens)
      if must.size == 1 && must_not.empty?
        # Term filter is cached by default.
Severity: Minor
Found in lib/es-query-builder/parser.rb - 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 create_token has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def create_token(full, minus, field, quoted, simple)
Severity: Minor
Found in lib/es-query-builder/tokenizer.rb - About 35 mins to fix

    Method create_token has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def create_token(full, minus, field, quoted, simple)
          if @filter_fields.include?(field)
            type = :filter
          elsif OR_CONDITION =~ full
            type = :or
    Severity: Minor
    Found in lib/es-query-builder/tokenizer.rb - 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

    Severity
    Category
    Status
    Source
    Language