projectblacklight/blacklight

View on GitHub

Showing 74 of 74 total issues

Method facet_field_aggregations has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def facet_field_aggregations
    list_as_hash(facet_fields).each_with_object({}) do |(facet_field_name, values), hash|
      items = values.map do |value, hits|
        i = FacetItem.new(value: value, hits: hits)

Severity: Minor
Found in lib/blacklight/solr/response/facets.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 initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def initialize(group, facet_item, facet_config, view_context, facet_field, search_state = view_context.search_state)
Severity: Minor
Found in app/presenters/blacklight/facet_grouped_item_presenter.rb - About 45 mins to fix

    Method values has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def values(except: [])
            params = search_state.params
            return [] if params.blank?
    
            f = except.include?(:filters) ? [] : [params.dig(filters_key, key)].flatten.compact
    Severity: Minor
    Found in lib/blacklight/search_state/filter_field.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 append_query has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def append_query(query)
        return if query.nil?
    
        if self['q'] || dig(:json, :query, :bool)
          self[:json] ||= { query: { bool: { must: [] } } }
    Severity: Minor
    Found in lib/blacklight/solr/request.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 initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def initialize(values, config, document, context, options, stack)
    Severity: Minor
    Found in app/presenters/blacklight/rendering/abstract_step.rb - About 45 mins to fix

      Method initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def initialize(values, config, document, context, operations, options)
      Severity: Minor
      Found in app/presenters/blacklight/rendering/pipeline.rb - About 45 mins to fix

        Method render has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def self.render(values, config, document, context, options)
        Severity: Minor
        Found in app/presenters/blacklight/rendering/pipeline.rb - About 35 mins to fix

          Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def initialize(facet_item, facet_config, view_context, facet_field, search_state = view_context.search_state)
          Severity: Minor
          Found in app/presenters/blacklight/facet_item_presenter.rb - About 35 mins to fix

            Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def initialize(key, user_parameters, field_config, view_context, search_state = view_context.search_state)
            Severity: Minor
            Found in app/presenters/blacklight/clause_presenter.rb - About 35 mins to fix

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

                  def flatten_hash(hash = params, ancestor_names = [])
                    flat_hash = {}
                    hash.each do |k, v|
                      names = Array.new(ancestor_names)
                      names << k
              Severity: Minor
              Found in app/components/blacklight/hidden_search_state_component.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 has? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def has?(k, *values)
                  if !key?(k)
                    false
                  elsif values.empty?
                    self[k].present?
              Severity: Minor
              Found in app/models/concerns/blacklight/document.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 fields_to_render has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def fields_to_render(document_fields = fields, **kwargs)
                    return to_enum(:fields_to_render, document_fields, **kwargs) unless block_given?
              
                    document_fields.each do |name, field_config|
                      field_presenter = field_presenter(field_config, kwargs)
              Severity: Minor
              Found in app/presenters/blacklight/document_presenter.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 display_type has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def display_type(base_name = nil, default: nil)
                    fields = []
                    fields += Array.wrap(view_config[:"#{base_name}_display_type_field"]) if base_name && view_config.key?(:"#{base_name}_display_type_field")
                    fields += Array.wrap(view_config.display_type_field)
              
              
              Severity: Minor
              Found in app/presenters/blacklight/document_presenter.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def initialize(display_facet_or_field_config: nil, display_facet: nil, field_config: nil, response: nil, blacklight_config: nil, component: nil, **component_args)
                    if display_facet_or_field_config.is_a? Blacklight::FacetFieldPresenter
                      @facet_field_presenter = display_facet_or_field_config
                      @field_config = @facet_field_presenter.facet_field
                      @display_facet = @facet_field_presenter.display_facet
              Severity: Minor
              Found in app/components/blacklight/facet_component.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 render_filtered_partials has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def render_filtered_partials(partials, options = {})
                    content = []
                    filter_partials(partials, options).each do |key, config|
                      config.key ||= key
                      rendered = render(partial: config.partial || key.to_s, locals: { document_action_config: config }.merge(options))
              Severity: Minor
              Found in app/helpers/blacklight/component_helper_behavior.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 values has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                    def values(except: [])
                      return nil unless pivot.is_a?(Array) && pivot.present?
              
                      params = search_state.params
                      # values should have at most one terminal blank pivot
              Severity: Minor
              Found in lib/blacklight/search_state/pivot_filter_field.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 remove has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                    def remove(item)
                      new_state = search_state.reset_search
              
                      return new_state.filter(item.field).remove(item) if item.respond_to?(:field) && item.field != key
              
              
              Severity: Minor
              Found in lib/blacklight/search_state/filter_field.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 track has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def track
                  search_session['counter'] = params[:counter]
                  search_session['id'] = params[:search_id]
                  search_session['per_page'] = params[:per_page]
                  search_session['document_id'] = params[:document_id]
              Severity: Minor
              Found in app/controllers/concerns/blacklight/catalog.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 add_blacklight_field has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def add_blacklight_field config_key, *args, &block
                      field_config = case args.first
                                     when String
                                       field_config_from_key_and_hash(config_key, *args)
                                     when Symbol
              Severity: Minor
              Found in lib/blacklight/configuration/fields.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

              Severity
              Category
              Status
              Source
              Language