projectblacklight/blacklight

View on GitHub
lib/blacklight/solr/search_builder_behavior.rb

Summary

Maintainability
C
1 day
Test Coverage

File search_builder_behavior.rb has 294 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Blacklight::Solr
  module SearchBuilderBehavior
    extend ActiveSupport::Concern

    included do
Severity: Minor
Found in lib/blacklight/solr/search_builder_behavior.rb - About 3 hrs to fix

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

        def facet_value_to_fq_string(facet_field, value, use_local_params: true)
          facet_config = blacklight_config.facet_fields[facet_field]
    
          solr_field = facet_config.field if facet_config && !facet_config.query
          solr_field ||= facet_field
    Severity: Minor
    Found in lib/blacklight/solr/search_builder_behavior.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 add_facet_fq_to_solr has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_facet_fq_to_solr(solr_parameters)
          # convert a String value into an Array
          if solr_parameters[:fq].is_a? String
            solr_parameters[:fq] = [solr_parameters[:fq]]
          end
    Severity: Minor
    Found in lib/blacklight/solr/search_builder_behavior.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 add_facetting_to_solr has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_facetting_to_solr(solr_parameters)
          facet_fields_to_include_in_request.each do |field_name, facet|
            solr_parameters[:facet] ||= true
    
            if facet.json
    Severity: Minor
    Found in lib/blacklight/solr/search_builder_behavior.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 add_adv_search_clauses has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_adv_search_clauses(solr_parameters)
          return if search_state.clause_params.blank?
    
          defaults = { must: [], must_not: [], should: [] }
          default_op = blacklight_params[:op]&.to_sym || :must
    Severity: Minor
    Found in lib/blacklight/solr/search_builder_behavior.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 add_facet_paging_to_solr has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_facet_paging_to_solr(solr_params)
          return if facet.blank?
    
          facet_config = blacklight_config.facet_fields[facet]
    
    
    Severity: Minor
    Found in lib/blacklight/solr/search_builder_behavior.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 add_solr_fields_to_query has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_solr_fields_to_query solr_parameters
          blacklight_config.show_fields.select(&method(:should_add_field_to_request?)).each_value do |field|
            field.solr_params.each do |k, v|
              solr_parameters[:"f.#{field.field}.#{k}"] = v
            end if field.solr_params
    Severity: Minor
    Found in lib/blacklight/solr/search_builder_behavior.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

    Method facet_inclusive_value_to_fq_string has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def facet_inclusive_value_to_fq_string(facet_field, values)
          return if values.blank?
    
          return facet_value_to_fq_string(facet_field, values.first) if values.length == 1
    
    
    Severity: Minor
    Found in lib/blacklight/solr/search_builder_behavior.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