collectiveidea/acts_as_geocodable

View on GitHub

Showing 7 of 7 total issues

Method update_address has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def update_address(force = false)
      unless self.geocode.blank?
        if self.acts_as_geocodable_options[:address].is_a? Symbol
          method = self.acts_as_geocodable_options[:address]
          if self.respond_to?("#{method}=") && (self.send(method).blank? || force)
Severity: Minor
Found in lib/acts_as_geocodable.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

Method acts_as_geocodable has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def acts_as_geocodable(options = {})
    options = {
      address: {
        street: :street, locality: :locality, region: :region,
        postal_code: :postal_code, country: :country},
Severity: Minor
Found in lib/acts_as_geocodable.rb - About 1 hr to fix

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

          def validates_as_geocodable(options = {})
            options = options.reverse_merge message: "Address could not be geocoded.", allow_nil: false
            validate do |model|
              is_blank = model.to_location.attributes.except(:precision).all?(&:blank?)
              unless options[:allow_nil] && is_blank
    Severity: Minor
    Found in lib/acts_as_geocodable.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 up has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.up
        create_table "geocodes" do |t|
          t.column "latitude", :decimal, precision: 15, scale: 12
          t.column "longitude", :decimal, precision: 15, scale: 12
          t.column "query", :string
    Severity: Minor
    Found in lib/generators/acts_as_geocodable/templates/migration.rb - About 1 hr to fix

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

          def geo_attribute(attr_key)
            if self.acts_as_geocodable_options[:address].is_a? Symbol
              attr_name = self.acts_as_geocodable_options[:address]
              attr_key == :street ? self.send(attr_name) : nil
            else
      Severity: Minor
      Found in lib/acts_as_geocodable.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 attach_geocode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def attach_geocode
            new_geocode = Geocode.find_or_create_by_location(self.to_location) unless self.to_location.blank?
            if new_geocode && self.geocode != new_geocode
              run_callbacks :geocoding do
                self.geocoding = Geocoding.new(geocode: new_geocode)
      Severity: Minor
      Found in lib/acts_as_geocodable.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 acts_as_geocodable has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def acts_as_geocodable(options = {})
          options = {
            address: {
              street: :street, locality: :locality, region: :region,
              postal_code: :postal_code, country: :country},
      Severity: Minor
      Found in lib/acts_as_geocodable.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