activerecord-hackery/ransack

View on GitHub

Showing 59 of 59 total issues

Method add_scope has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def add_scope(key, args)
      sanitized_args = if Ransack.options[:sanitize_scope_args] && !@context.ransackable_scope_skip_sanitize_args?(key, @context.object)
        sanitized_scope_args(args)
      else
        args
Severity: Minor
Found in lib/ransack/search.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 join_constraints_with_tables has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def join_constraints_with_tables(foreign_table, foreign_klass, join_type, alias_tracker, tables)
      joins = []
      chain = []

      reflection.chain.each.with_index do |reflection, i|
Severity: Minor
Found in lib/polyamorous/activerecord/join_association.rb - About 1 hr to fix

    Method attribute has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def attribute(key, options = {})
            unless context = options.delete(:context)
              raise ArgumentError, "A context is required to translate attributes"
            end
    
    
    Severity: Minor
    Found in lib/ransack/translate.rb - About 1 hr to fix

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

              def build_joins(relation)
                buckets = relation.joins_values + relation.left_outer_joins_values
      
                buckets = buckets.group_by do |join|
                  case join
      Severity: Minor
      Found in lib/ransack/adapters/active_record/context.rb - About 1 hr to fix

        Method predicate_select has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def predicate_select(options = {}, html_options = {})
                options[:compounds] = true if options[:compounds].nil?
                default = options.delete(:default) || Constants::CONT
        
                keys =
        Severity: Minor
        Found in lib/ransack/helpers/form_builder.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 attribute_method? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

                def attribute_method?(str, klass = @klass)
                  exists = false
                  if ransackable_attribute?(str, klass)
                    exists = true
                  elsif (segments = str.split(Constants::UNDERSCORE)).size > 1
        Severity: Minor
        Found in lib/ransack/adapters/active_record/context.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 collapse_multiparameter_attributes! has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def collapse_multiparameter_attributes!(attrs)
              attrs.keys.each do |k|
                if k.include?(Constants::LEFT_PARENTHESIS)
                  real_attribute, position = k.split(/\(|\)/)
                  cast =
        Severity: Minor
        Found in lib/ransack/search.rb - About 1 hr to fix

          Method extract_values_for_condition has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                    def extract_values_for_condition(key, context = nil)
                      str = key.dup
                      name = Predicate.detect_and_strip_from_string!(str)
                      predicate = Predicate.named(name)
          
          
          Severity: Minor
          Found in lib/ransack/nodes/condition.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 join_constraints_with_tables has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def join_constraints_with_tables(foreign_table, foreign_klass, join_type, alias_tracker, tables)
                joins = []
                chain = []
          
                reflection.chain.each.with_index do |reflection, i|
          Severity: Minor
          Found in lib/polyamorous/activerecord/join_association.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 arel_predicate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def arel_predicate
                  predicate = attributes.map { |attribute|
                    association = attribute.parent
                    if negative? && attribute.associated_collection?
                      query = context.build_correlated_subquery(association)
          Severity: Minor
          Found in lib/ransack/nodes/condition.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 get_parent_and_attribute_name has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                  def get_parent_and_attribute_name(str, parent = @base)
                    attr_name = nil
          
                    if ransackable_attribute?(str, klassify(parent))
                      attr_name = str
          Severity: Minor
          Found in lib/ransack/adapters/active_record/context.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 search_form_for has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def search_form_for(record, options = {}, &proc)
                  if record.is_a? Ransack::Search
                    search = record
                    options[:url] ||= polymorphic_path(
                      search.klass, format: options.delete(:format)
          Severity: Minor
          Found in lib/ransack/helpers/form_helper.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 cast_to_date has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def cast_to_date(val)
                  if val.respond_to?(:to_date)
                    val.to_date rescue nil
                  else
                    y, m, d = *[val].flatten
          Severity: Minor
          Found in lib/ransack/nodes/value.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 extract has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                  def extract(context, key, values)
                    attributes, predicate, combinator =
                      extract_values_for_condition(key, context)
          
                    if attributes.size > 0 && predicate
          Severity: Minor
          Found in lib/ransack/nodes/condition.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 join_constraints_with_tables has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def join_constraints_with_tables(foreign_table, foreign_klass, join_type, alias_tracker, tables)
          Severity: Minor
          Found in lib/polyamorous/activerecord/join_association_7_2.rb - About 35 mins to fix

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

                def join_constraints_with_tables(foreign_table, foreign_klass, join_type, alias_tracker, tables)
            Severity: Minor
            Found in lib/polyamorous/activerecord/join_association.rb - About 35 mins to fix

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

                      def type_for(attr)
                        return nil unless attr && attr.valid?
                        relation     = attr.arel_attribute.relation
                        name         = attr.arel_attribute.name.to_s
                        table        = relation.respond_to?(:table_name) ? relation.table_name : relation.name
              Severity: Minor
              Found in lib/ransack/adapters/active_record/context.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

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

                    def attribute(key, options = {})
                      unless context = options.delete(:context)
                        raise ArgumentError, "A context is required to translate attributes"
                      end
              
              
              Severity: Minor
              Found in lib/ransack/translate.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

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

                    def conditions=(conditions)
                      case conditions
                      when Array
                        conditions.each do |attrs|
                          condition = Condition.new(@context).build(attrs)
              Severity: Minor
              Found in lib/ransack/nodes/grouping.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

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

                    def detect_from_string(str, chomp: false)
                      return unless str
              
                      Ransack.predicates.sorted_names_with_underscores.each do |predicate, underscored|
                        if str.end_with? underscored
              Severity: Minor
              Found in lib/ransack/predicate.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