Showing 6 of 9 total issues
Method parse_params
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
Open
def parse_params
params = @text.split(',')
params.each do |param|
key_vals = param.split('=>', 2)
param_name = key_vals[0].strip
- 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
Method render
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
Open
def render(context)
tags = context.registers[:site].tags.map do |tag, posts|
[tag, posts.count] if posts.count >= @threshold
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
Method render
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def render(context)
tags = context.registers[:site].tags.map do |tag, posts|
[tag, posts.count] if posts.count >= @threshold
end
Method parse_params
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def parse_params
params = @text.split(',')
params.each do |param|
key_vals = param.split('=>', 2)
param_name = key_vals[0].strip
Avoid deeply nested control flow statements. Open
Open
if param_value.eql? 'time'
@sort_by = 'time'
elsif param_value.eql? 'count'
@sort_by = 'count'
else
Avoid deeply nested control flow statements. Open
Open
elsif param_name.eql? ':limit'
param_value = param_value.to_i
@limit = param_value if param_value > 0
else
next