app/models/search_presenter.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Class has too many lines. [182/100]
Open

class SearchPresenter
  include ActionView::Helpers::NumberHelper
  include ActionView::Helpers::UrlHelper

  private
Severity: Minor
Found in app/models/search_presenter.rb by rubocop

This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Class SearchPresenter has 48 methods (exceeds 20 allowed). Consider refactoring.
Open

class SearchPresenter
  include ActionView::Helpers::NumberHelper
  include ActionView::Helpers::UrlHelper

  private
Severity: Minor
Found in app/models/search_presenter.rb - About 6 hrs to fix

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

      def current_privacy
        default = current_basket.private_default_with_inheritance? ? 'private' : 'public'
        display_menu = true # EOIN: TODO: this method needs to be cleaned up
        ((params[:privacy_type] unless clear_values) || (SystemSetting.default_search_privacy if display_menu) || default)
      end
    Severity: Minor
    Found in app/models/search_presenter.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

    FIXME found
    Open

        Basket.site_basket # FIXME: make this find the basket the user is ucrrently in
    Severity: Minor
    Found in app/models/search_presenter.rb by fixme

    TODO found
    Open

        display_menu = true # EOIN: TODO: this method needs to be cleaned up
    Severity: Minor
    Found in app/models/search_presenter.rb by fixme

    TODO found
    Open

        # EOIN: TODO: not clear where we should pull this from yet
    Severity: Minor
    Found in app/models/search_presenter.rb by fixme

    FIXME found
    Open

        # FIXME: this model comes from a rails plugin in old kete
    Severity: Minor
    Found in app/models/search_presenter.rb by fixme

    TODO found
    Open

      # TODO: should this be renamed url_safe_basket_name ??
    Severity: Minor
    Found in app/models/search_presenter.rb by fixme

    Unused method argument - title_so_far. If it's necessary, use _ or _title_so_far as an argument name to indicate that it won't be used. You can also write as title_setup_first_part(*) if you want the method to accept any arguments but don't care about them.
    Open

      def title_setup_first_part(title_so_far, span_around_zoom_class = false)
    Severity: Minor
    Found in app/models/search_presenter.rb by rubocop

    This cop checks for unused method arguments.

    Example:

    # bad
    
    def some_method(used, unused, _unused_but_allowed)
      puts used
    end

    Example:

    # good
    
    def some_method(used, _unused, _unused_but_allowed)
      puts used
    end

    Unused method argument - add_links. If it's necessary, use _ or _add_links as an argument name to indicate that it won't be used. You can also write as last_part_of_title_if_refinement_of(*) if you want the method to accept any arguments but don't care about them.
    Open

      def last_part_of_title_if_refinement_of(add_links = true)
    Severity: Minor
    Found in app/models/search_presenter.rb by rubocop

    This cop checks for unused method arguments.

    Example:

    # bad
    
    def some_method(used, unused, _unused_but_allowed)
      puts used
    end

    Example:

    # good
    
    def some_method(used, _unused, _unused_but_allowed)
      puts used
    end

    Put empty method definitions on a single line.
    Open

      def sort_type_options_for(*args)
      end
    Severity: Minor
    Found in app/models/search_presenter.rb by rubocop

    This cop checks for the formatting of empty method definitions. By default it enforces empty method definitions to go on a single line (compact style), but it can be configured to enforce the end to go on its own line (expanded style).

    Note: A method definition is not considered empty if it contains comments.

    Example: EnforcedStyle: compact (default)

    # bad
    def foo(bar)
    end
    
    def self.foo(bar)
    end
    
    # good
    def foo(bar); end
    
    def foo(bar)
      # baz
    end
    
    def self.foo(bar); end

    Example: EnforcedStyle: expanded

    # bad
    def foo(bar); end
    
    def self.foo(bar); end
    
    # good
    def foo(bar)
    end
    
    def self.foo(bar)
    end

    Avoid comma after the last item of a hash.
    Open

          'Document' => 'Documents',
    Severity: Minor
    Found in app/models/search_presenter.rb by rubocop

    This cop checks for trailing comma in array and hash literals.

    Example: EnforcedStyleForMultiline: consistent_comma

    # bad
    a = [1, 2,]
    
    # good
    a = [
      1, 2,
      3,
    ]
    
    # good
    a = [
      1,
      2,
    ]

    Example: EnforcedStyleForMultiline: comma

    # bad
    a = [1, 2,]
    
    # good
    a = [
      1,
      2,
    ]

    Example: EnforcedStyleForMultiline: no_comma (default)

    # bad
    a = [1, 2,]
    
    # good
    a = [
      1,
      2
    ]

    %w-literals should be delimited by [ and ].
    Open

        %w(Topic StillImage AudioRecording Video WebLink Document)
    Severity: Minor
    Found in app/models/search_presenter.rb by rubocop

    This cop enforces the consistent usage of %-literal delimiters.

    Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

    Example:

    # Style/PercentLiteralDelimiters:
    #   PreferredDelimiters:
    #     default: '[]'
    #     '%i':    '()'
    
    # good
    %w[alpha beta] + %i(gamma delta)
    
    # bad
    %W(alpha #{beta})
    
    # bad
    %I(alpha beta)

    Method SearchPresenter#extended_field is defined at both app/models/search_presenter.rb:72 and app/models/search_presenter.rb:124.
    Open

      def extended_field
    Severity: Minor
    Found in app/models/search_presenter.rb by rubocop

    This cop checks for duplicated instance (or singleton) method definitions.

    Example:

    # bad
    
    def duplicated
      1
    end
    
    def duplicated
      2
    end

    Example:

    # bad
    
    def duplicated
      1
    end
    
    alias duplicated other_duplicated

    Example:

    # good
    
    def duplicated
      1
    end
    
    def other_duplicated
      2
    end

    Unused method argument - options. If it's necessary, use _ or _options as an argument name to indicate that it won't be used. You can also write as link_to_add_item(*) if you want the method to accept any arguments but don't care about them.
    Open

      def link_to_add_item(options = {})
    Severity: Minor
    Found in app/models/search_presenter.rb by rubocop

    This cop checks for unused method arguments.

    Example:

    # bad
    
    def some_method(used, unused, _unused_but_allowed)
      puts used
    end

    Example:

    # good
    
    def some_method(used, _unused, _unused_but_allowed)
      puts used
    end

    Use the return of the conditional for variable assignment and comparison.
    Open

        if query
          @query = query
        else
          @query = SearchQuery.new(params)
        end
    Severity: Minor
    Found in app/models/search_presenter.rb by rubocop

    Unused method argument - span_around_zoom_class. If it's necessary, use _ or _span_around_zoom_class as an argument name to indicate that it won't be used. You can also write as title_setup_first_part(*) if you want the method to accept any arguments but don't care about them.
    Open

      def title_setup_first_part(title_so_far, span_around_zoom_class = false)
    Severity: Minor
    Found in app/models/search_presenter.rb by rubocop

    This cop checks for unused method arguments.

    Example:

    # bad
    
    def some_method(used, unused, _unused_but_allowed)
      puts used
    end

    Example:

    # good
    
    def some_method(used, _unused, _unused_but_allowed)
      puts used
    end

    Unused method argument - type. If it's necessary, use _ or _type as an argument name to indicate that it won't be used. You can also write as topic_type_useful_here?(*) if you want the method to accept any arguments but don't care about them.
    Open

      def topic_type_useful_here?(type)
    Severity: Minor
    Found in app/models/search_presenter.rb by rubocop

    This cop checks for unused method arguments.

    Example:

    # bad
    
    def some_method(used, unused, _unused_but_allowed)
      puts used
    end

    Example:

    # good
    
    def some_method(used, _unused, _unused_but_allowed)
      puts used
    end

    There are no issues that match your filters.

    Category
    Status