projectblacklight/blacklight

View on GitHub

Showing 71 of 75 total issues

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

  def page_entries_info(collection, entry_name: nil)
    entry_name = if entry_name
                   entry_name.pluralize(collection.size, I18n.locale)
                 else
                   collection.entry_name(count: collection.size).to_s
Severity: Minor
Found in app/helpers/blacklight/catalog_helper_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 collation has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def collation
      # FIXME: DRY up with words
      spellcheck = response[:spellcheck]
      return unless spellcheck && spellcheck[:suggestions]

Severity: Minor
Found in lib/blacklight/solr/response/spelling.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 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 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_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 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 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 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 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 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 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 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 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 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 append_boolean_query has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def append_boolean_query(bool_operator, query)
                  return if query.blank?
              
                  self[:json] ||= { query: { bool: { bool_operator => [] } } }
                  self[:json][:query] ||= { bool: { bool_operator => [] } }
              Severity: Minor
              Found in lib/blacklight/solr/request.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