Noosfero/noosfero

View on GitHub
plugins/solr/lib/acts_as_faceted.rb

Summary

Maintainability
D
2 days
Test Coverage

Method map_facet_results has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
Open

      def map_facet_results(facet, facet_params, facets_data, unfiltered_facets_data = {}, options = {})
        raise "Use map_facets_for before this method" if facet[:solr_field].nil?

        facets_data = {} if facets_data.blank? # could be empty array
        solr_facet = to_solr_fields_names[facet[:solr_field]]
Severity: Minor
Found in plugins/solr/lib/acts_as_faceted.rb - About 7 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_faceted has 140 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def acts_as_faceted(options)
      extend ClassMethods
      extend ActsAsSolr::CommonMethods

      cattr_accessor :facets
Severity: Major
Found in plugins/solr/lib/acts_as_faceted.rb - About 5 hrs to fix

    Method facets_find_options has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

          def facets_find_options(facets_selected = {}, options = {})
            browses = []
            facets_selected ||= {}
            facets_selected.map do |id, value|
              next unless facets[id.to_sym]
    Severity: Minor
    Found in plugins/solr/lib/acts_as_faceted.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_result_name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def facet_result_name(facet, data)
            if facet[:queries]
              gettext(facet[:queries][data])
            elsif facet[:proc]
              if facet[:multi]
    Severity: Minor
    Found in plugins/solr/lib/acts_as_faceted.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 map_facets_for has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def map_facets_for(environment)
            facets_order.map do |id|
              facet = facet_by_id(id)
              next if facet[:type_if] && !facet[:type_if].call(self.new)
    
    
    Severity: Minor
    Found in plugins/solr/lib/acts_as_faceted.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

    There are no issues that match your filters.

    Category
    Status