Noosfero/noosfero

View on GitHub
app/helpers/search_helper.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Method display_selector has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

  def display_selector(asset, display, float = "right")
    display = nil if display.blank?
    display ||= asset_class(asset).default_search_display
    if [display?(asset, :map), display?(asset, :compact), display?(asset, :full)].select { |option| option }.count > 1
      compact_link = display?(asset, :compact) ? (display == "compact" ? _("Compact") : link_to(_("Compact"), params.merge(display: "compact"))) : nil
Severity: Minor
Found in app/helpers/search_helper.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

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

  def filters(asset)
    return if !asset || asset == :tag

    klass = asset_class(asset)
    filters = safe_join(klass::SEARCH_FILTERS.map do |name, options|
Severity: Minor
Found in app/helpers/search_helper.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 city_with_state has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def city_with_state(city)
    if city && city.kind_of?(City)
      s = city.parent
      if s && s.kind_of?(State) && s.acronym
        city.name + ", " + s.acronym
Severity: Minor
Found in app/helpers/search_helper.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