Class has too many lines. [182/100] Open
class SearchPresenter
include ActionView::Helpers::NumberHelper
include ActionView::Helpers::UrlHelper
private
- Read upRead up
- Exclude checks
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
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
- Read upRead up
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
- Exclude checks
TODO found Open
display_menu = true # EOIN: TODO: this method needs to be cleaned up
- Exclude checks
TODO found Open
# EOIN: TODO: not clear where we should pull this from yet
- Exclude checks
FIXME found Open
# FIXME: this model comes from a rails plugin in old kete
- Exclude checks
TODO found Open
# TODO: should this be renamed url_safe_basket_name ??
- Exclude checks
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)
- Read upRead up
- Exclude checks
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)
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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',
- Read upRead up
- Exclude checks
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)
- Read upRead up
- Exclude checks
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
- Read upRead up
- Exclude checks
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 = {})
- Read upRead up
- Exclude checks
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
- Exclude checks
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)
- Read upRead up
- Exclude checks
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)
- Read upRead up
- Exclude checks
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