SpeciesFileGroup/taxonworks

View on GitHub
lib/utilities/geo.rb

Summary

Maintainability
D
1 day
Test Coverage

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

    def self.hunt_lat_long(label, how = ' ')
      if how.nil?
        pieces = [label]
      else
        pieces = label.split(how)
Severity: Minor
Found in lib/utilities/geo.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 geo.rb has 277 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Utilities
  # Special general routines for Geo-specific itams
  module Geo
=begin
To add a new (discovered) symbol:
Severity: Minor
Found in lib/utilities/geo.rb - About 2 hrs to fix

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

        def self.degrees_minutes_seconds_to_decimal_degrees(dms_in) # rubocop:disable Metrics/PerceivedComplexity !! But this is too complex :)
          match_string = nil
          # no_point     = false
          degrees      = 0.0
          minutes      = 0.0
    Severity: Minor
    Found in lib/utilities/geo.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 degrees_minutes_seconds_to_decimal_degrees has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.degrees_minutes_seconds_to_decimal_degrees(dms_in) # rubocop:disable Metrics/PerceivedComplexity !! But this is too complex :)
          match_string = nil
          # no_point     = false
          degrees      = 0.0
          minutes      = 0.0
    Severity: Major
    Found in lib/utilities/geo.rb - About 2 hrs to fix

      Method distance_in_meters has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.distance_in_meters(dist_in)
            dist_in   = '0.0 meters' if dist_in.blank?
            elevation = dist_in.strip.downcase
            pieces    = elevation.split(' ')
            value     = elevation.to_f
      Severity: Minor
      Found in lib/utilities/geo.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 nearby_from_params has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def self.nearby_from_params(params)
            nearby_distance = params['nearby_distance'].to_i
            nearby_distance = CollectingEvent::NEARBY_DISTANCE if nearby_distance == 0
      
            decade = case nearby_distance.to_s.length
      Severity: Minor
      Found in lib/utilities/geo.rb - About 1 hr to fix

        Method hunt_lat_long has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def self.hunt_lat_long(label, how = ' ')
              if how.nil?
                pieces = [label]
              else
                pieces = label.split(how)
        Severity: Minor
        Found in lib/utilities/geo.rb - About 1 hr to fix

          Use if ft.present? instead of unless ft.blank?.
          Open

                scale = 0.3048 unless ft.blank?
          Severity: Minor
          Found in lib/utilities/geo.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use if m.present? instead of unless m.blank?.
          Open

                scale = 1.0 unless m.blank?
          Severity: Minor
          Found in lib/utilities/geo.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use if km.present? instead of unless km.blank?.
          Open

                scale = 1000.0 unless km.blank?
          Severity: Minor
          Found in lib/utilities/geo.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use if mi.present? instead of unless mi.blank?.
          Open

                scale = 1_609.344 unless mi.blank?
          Severity: Minor
          Found in lib/utilities/geo.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          There are no issues that match your filters.

          Category
          Status