geokit/geokit-rails

View on GitHub

Showing 7 of 9 total issues

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

        def acts_as_mappable(options = {})
          metaclass = (class << self; self; end)

          include Geokit::ActsAsMappable

Severity: Minor
Found in lib/geokit-rails/acts_as_mappable/glue.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 acts_as_mappable has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def acts_as_mappable(options = {})
          metaclass = (class << self; self; end)

          include Geokit::ActsAsMappable

Severity: Minor
Found in lib/geokit-rails/acts_as_mappable/glue.rb - About 1 hr to fix

    Method formulate_bounds_from_distance has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def formulate_bounds_from_distance(options, origin, units)
            distance = options[:within] if options.has_key?(:within) && options[:within].is_a?(Numeric)
            distance = options[:range].last-(options[:range].exclude_end?? 1 : 0) if options.has_key?(:range)
            if distance
              Geokit::Bounds.from_point_and_radius(origin,distance,:units=>units)
    Severity: Minor
    Found in lib/geokit-rails/acts_as_mappable/class_methods.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

    Consider simplifying this complex logical expression.
    Open

              if reflection = Geokit::ActsAsMappable.end_of_reflection_chain(self.through, self)
                metaclass.instance_eval do
                  OPTION_SYMBOLS.each do |method_name|
                    define_method method_name do
                      reflection.klass.send(method_name)
    Severity: Major
    Found in lib/geokit-rails/acts_as_mappable/glue.rb - About 40 mins to fix

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

          def self.end_of_reflection_chain(through, klass)
            while through
              reflection = nil
              if through.is_a?(Hash)
                association, through = through.to_a.first
      Severity: Minor
      Found in lib/geokit-rails/acts_as_mappable.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 bound_conditions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def bound_conditions(bounds, inclusive = false)
              return nil unless bounds
              if inclusive
                lt_operator = :lteq
                gt_operator = :gteq
      Severity: Minor
      Found in lib/geokit-rails/acts_as_mappable/class_methods.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 distance_conditions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def distance_conditions(options)
              origin  = extract_origin_from_options(options)
              units   = extract_units_from_options(options)
              formula = extract_formula_from_options(options)
              distance_column_name = distance_sql(origin, units, formula)
      Severity: Minor
      Found in lib/geokit-rails/acts_as_mappable/class_methods.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

      Severity
      Category
      Status
      Source
      Language