lib/queries/geographic_area/autocomplete.rb
Method has too many lines. [36/25] Open
Open
def autocomplete
#t = Time.now
pr_id = project_id.join(',') if project_id.present?
return [] if query_string.blank?
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method autocomplete
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def autocomplete
#t = Time.now
pr_id = project_id.join(',') if project_id.present?
return [] if query_string.blank?
Method autocomplete
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
def autocomplete
#t = Time.now
pr_id = project_id.join(',') if project_id.present?
return [] if query_string.blank?
- 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
TODO found Open
Open
# TODO: use or_clauses
- Exclude checks
Use 2 (not 3) spaces for indentation. Open
Open
a = a.left_outer_joins(:asserted_distributions)
- Read upRead up
- Exclude checks
This cop checks for indentation that doesn't use the specified number of spaces.
See also the IndentationConsistency cop which is the companion to this one.
Example:
# bad
class A
def test
puts 'hello'
end
end
# good
class A
def test
puts 'hello'
end
end
Example: IgnoredPatterns: ['^\s*module']
# bad
module A
class B
def test
puts 'hello'
end
end
end
# good
module A
class B
def test
puts 'hello'
end
end
end