bikeindex/bike_index

View on GitHub
app/models/concerns/bike_searchable.rb

Summary

Maintainability
A
2 hrs
Test Coverage
A
98%

Method extracted_searchable_proximity_hash has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

    def extracted_searchable_proximity_hash(query_params, ip)
      return false unless query_params[:stolenness] == "proximity"
      location = query_params[:location]
      return false unless location && !(location =~ /anywhere/i)
      distance = query_params[:distance]&.to_i
Severity: Minor
Found in app/models/concerns/bike_searchable.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 searchable_query_items_colors has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
Open

    def searchable_query_items_colors(query_params)
      # params[:colors] should be an array (or a comma delineated string) - otherwise we parse out of the query string
      if query_params[:colors].present?
        colors = query_params[:colors].is_a?(String) ? query_params[:colors].split(",") : query_params[:colors]
        return {colors: colors.map { |id| Color.friendly_find_id(id) }.compact}
Severity: Minor
Found in app/models/concerns/bike_searchable.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 searchable_query_items_manufacturer has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
Open

    def searchable_query_items_manufacturer(query_params)
      # we expect a singular manufacturer but deal with arrays because the multi-select search
      manufacturer_id = extracted_query_items_manufacturer_id(query_params)
      if manufacturer_id && !manufacturer_id.is_a?(Integer)
        manufacturer_id = [manufacturer_id].flatten.map { |m_id|
Severity: Minor
Found in app/models/concerns/bike_searchable.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

There are no issues that match your filters.

Category
Status