Noosfero/noosfero

View on GitHub
plugins/solr/lib/solr_plugin/search_helper.rb

Summary

Maintainability
C
1 day
Test Coverage

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

  def facet_link_html(facet, params, value, label, count)
    params = params ? params.dup : {}
    has_extra = label.kind_of?(Array)
    link_label = has_extra ? label[0] : label
    id = facet[:solr_field].to_s
Severity: Minor
Found in plugins/solr/lib/solr_plugin/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 solr_options has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  def solr_options(asset, category)
    asset_class = asset_class(asset)
    solr_options = {}
    if !multiple_search?
      if !results_only? && asset_class.respond_to?(:facets)
Severity: Minor
Found in plugins/solr/lib/solr_plugin/search_helper.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 facet_selecteds_html_for has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def facet_selecteds_html_for(environment, klass, params)
    def name_with_extra(klass, facet, value)
      name = klass.facet_result_name(facet, value)
      name = name[0] + name[1] if name.kind_of?(Array)
      name
Severity: Minor
Found in plugins/solr/lib/solr_plugin/search_helper.rb - About 1 hr to fix

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

      def facet_selecteds_html_for(environment, klass, params)
        def name_with_extra(klass, facet, value)
          name = klass.facet_result_name(facet, value)
          name = name[0] + name[1] if name.kind_of?(Array)
          name
    Severity: Minor
    Found in plugins/solr/lib/solr_plugin/search_helper.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 facet_link_html has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def facet_link_html(facet, params, value, label, count)
    Severity: Minor
    Found in plugins/solr/lib/solr_plugin/search_helper.rb - About 35 mins to fix

      There are no issues that match your filters.

      Category
      Status