SpeciesFileGroup/taxonworks

View on GitHub
lib/queries/query/filter.rb

Summary

Maintainability
D
2 days
Test Coverage

File filter.rb has 396 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Queries

  # Overview
  #
  # This class manages params and nesting of filter queries.
Severity: Minor
Found in lib/queries/query/filter.rb - About 5 hrs to fix

    Class Filter has 34 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Query::Filter < Queries::Query
    
        include Queries::Concerns::Users
        # include Queries::Concerns::Identifiers # Presently in Queries for other use in autocompletes
    
    
    Severity: Minor
    Found in lib/queries/query/filter.rb - About 4 hrs to fix

      Method included_annotator_facets has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.included_annotator_facets
            f = [
              ::Queries::Concerns::Users
            ]
      
      
      Severity: Minor
      Found in lib/queries/query/filter.rb - 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

      Method has too many lines. [40/25]
      Open

          def permitted_params(hsh)
            h = self.class::PARAMS.deep_dup
            h.unshift(:per)
            h.unshift(:page)
            h.unshift(:paginate)
      Severity: Minor
      Found in lib/queries/query/filter.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Method permitted_params has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def permitted_params(hsh)
            h = self.class::PARAMS.deep_dup
            h.unshift(:per)
            h.unshift(:page)
            h.unshift(:paginate)
      Severity: Minor
      Found in lib/queries/query/filter.rb - About 1 hr to fix

        Method permitted_params has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def permitted_params(hsh)
              h = self.class::PARAMS.deep_dup
              h.unshift(:per)
              h.unshift(:page)
              h.unshift(:paginate)
        Severity: Minor
        Found in lib/queries/query/filter.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 annotator_merge_clauses has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def annotator_merge_clauses
              a = []
        
              # !! Interesting `.compact` removes #<ActiveRecord::Relation []>,
              # so patterns that us collect.flatten.compact return empty,
        Severity: Minor
        Found in lib/queries/query/filter.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 all has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def all(nil_empty = false)
        
              # TODO: should turn off/on project_id here on nil empty?
        
              a = all_and_clauses
        Severity: Minor
        Found in lib/queries/query/filter.rb - 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 annotator_params has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.annotator_params
              h = nil
              if i = included_annotator_facets
                # Setup with the first
                a = i.shift
        Severity: Minor
        Found in lib/queries/query/filter.rb - 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

        Method set_nested_queries has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def set_nested_queries(params)
        
              if n = params.select{|k, p| k.to_s =~ /_query/ }
                return nil if n.keys.count != 1 # !!! can't have multiple nested queries inside one level !!! This lets us eliminate infinite loops at the cost of expressiveness?!
        
        
        Severity: Minor
        Found in lib/queries/query/filter.rb - 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

        Method annotator_and_clauses has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def annotator_and_clauses
              a = []
              self.class.included_annotator_facets.each do |c|
                if c.respond_to?(:and_clauses)
                  c.and_clauses.each do |f|
        Severity: Minor
        Found in lib/queries/query/filter.rb - 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

        TODO found
        Open

            # TODO: macro these dynamically
        Severity: Minor
        Found in lib/queries/query/filter.rb by fixme

        TODO found
        Open

                # TODO: Think we need to handle ' and '
        Severity: Minor
        Found in lib/queries/query/filter.rb by fixme

        TODO found
        Open

                # TODO There is room for an AlternateValue concern here
        Severity: Minor
        Found in lib/queries/query/filter.rb by fixme

        TODO found
        Open

            # TODO: when a nesting problem is found we need to flag the query as invalid
        Severity: Minor
        Found in lib/queries/query/filter.rb by fixme

        TODO found
        Open

              # TODO: should turn off/on project_id here on nil empty?
        Severity: Minor
        Found in lib/queries/query/filter.rb by fixme

        There are no issues that match your filters.

        Category
        Status