activerecord-hackery/ransack

View on GitHub

Showing 51 of 59 total issues

Class Condition has 37 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Condition < Node
      i18n_word :attribute, :predicate, :combinator, :value
      i18n_alias a: :attribute, p: :predicate,
                 m: :combinator, v: :value

Severity: Minor
Found in lib/ransack/nodes/condition.rb - About 4 hrs to fix

    Class FormBuilder has 31 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class FormBuilder < (ENV[RANSACK_FORM_BUILDER].try(:constantize) ||
          ActionView::Helpers::FormBuilder)
    
          def label(method, *args, &block)
            options = args.extract_options!
    Severity: Minor
    Found in lib/ransack/helpers/form_builder.rb - About 3 hrs to fix

      Method evaluate has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

              def evaluate(search, opts = {})
                viz = Visitor.new
                relation = @object.where(viz.accept(search.base))
      
                if search.sorts.any?
      Severity: Minor
      Found in lib/ransack/adapters/active_record/context.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

      File condition.rb has 289 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module Ransack
        module Nodes
          class Condition < Node
            i18n_word :attribute, :predicate, :combinator, :value
            i18n_alias a: :attribute, p: :predicate,
      Severity: Minor
      Found in lib/ransack/nodes/condition.rb - About 2 hrs to fix

        Method collapse_multiparameter_attributes! has a Cognitive Complexity of 19 (exceeds 5 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 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

        Class Grouping has 23 methods (exceeds 20 allowed). Consider refactoring.
        Open

            class Grouping < Node
              attr_reader :conditions
              attr_accessor :combinator
              alias :m :combinator
              alias :m= :combinator=
        Severity: Minor
        Found in lib/ransack/nodes/grouping.rb - About 2 hrs to fix

          Method table_aliases_for has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              def table_aliases_for(parent, node)
                @joined_tables ||= {}
                node.reflection.chain.map { |reflection|
                  table, terminated = @joined_tables[reflection]
                  root = reflection == node.reflection
          Severity: Minor
          Found in lib/polyamorous/activerecord/join_dependency.rb - 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

          File context.rb has 264 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require 'ransack/context'
          require 'polyamorous/polyamorous'
          
          module Ransack
            module Adapters
          Severity: Minor
          Found in lib/ransack/adapters/active_record/context.rb - About 2 hrs to fix

            Class Context has 22 methods (exceeds 20 allowed). Consider refactoring.
            Open

                  class Context < ::Ransack::Context
            
                    def relation_for(object)
                      object.all
                    end
            Severity: Minor
            Found in lib/ransack/adapters/active_record/context.rb - About 2 hrs to fix

              Class SortLink has 22 methods (exceeds 20 allowed). Consider refactoring.
              Open

                    class SortLink
                      def initialize(search, attribute, args, params)
                        @search         = search
                        @params         = parameters_hash(params)
                        @field          = attribute.to_s
              Severity: Minor
              Found in lib/ransack/helpers/form_helper.rb - About 2 hrs to fix

                Method cast_to_time has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                      def cast_to_time(val)
                        if val.is_a?(Array)
                          Time.zone.local(*val) rescue nil
                        else
                          unless val.acts_like?(:time)
                Severity: Minor
                Found in lib/ransack/nodes/value.rb - 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

                Class Context has 21 methods (exceeds 20 allowed). Consider refactoring.
                Open

                  class Context
                    attr_reader :search, :object, :klass, :base, :engine, :arel_visitor
                    attr_accessor :auth_object, :search_key
                    attr_reader :arel_visitor
                
                
                Severity: Minor
                Found in lib/ransack/context.rb - About 2 hrs to fix

                  Method attribute_select has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def attribute_select(options = nil, html_options = nil, action = nil)
                          options ||= {}
                          html_options ||= {}
                          action ||= Constants::SEARCH
                          default = options.delete(:default)
                  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 extract_correlated_key has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                          def extract_correlated_key(join_root)
                            case join_root
                            when Arel::Nodes::OuterJoin
                              # one of join_root.right/join_root.left is expected to be Arel::Nodes::On
                              if join_root.right.is_a?(Arel::Nodes::On)
                  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 build has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def build(associations, base_klass)
                        associations.map do |name, right|
                          if name.is_a? Join
                            reflection = find_reflection base_klass, name.name
                            reflection.check_validity!
                  Severity: Minor
                  Found in lib/polyamorous/activerecord/join_dependency.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 initialize has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def initialize(object, params = {}, options = {})
                        strip_whitespace = options.fetch(:strip_whitespace, Ransack.options[:strip_whitespace])
                        params = params.to_unsafe_h if params.respond_to?(:to_unsafe_h)
                        if params.is_a? Hash
                          params = params.dup
                  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 traverse has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def traverse(str, base = @base)
                        str ||= ''.freeze
                        segments = str.split(Constants::UNDERSCORE)
                        unless segments.empty?
                          remainder = []
                  Severity: Minor
                  Found in lib/ransack/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 join_constraints_with_tables has a Cognitive Complexity of 12 (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_7_2.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 association_path has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def association_path(str, base = @base)
                        base = klassify(base)
                        str ||= ''.freeze
                        path = []
                        segments = str.split(Constants::UNDERSCORE)
                  Severity: Minor
                  Found in lib/ransack/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 join_constraints_with_tables has 33 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_7_2.rb - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language