Fitbark::Handler::V2::ActivitySeries#build_params has 4 parameters Open
def build_params(slug, from, to, res)
- Read upRead up
- Exclude checks
A Long Parameter List
occurs when a method has a lot of parameters.
Example
Given
class Dummy
def long_list(foo,bar,baz,fling,flung)
puts foo,bar,baz,fling,flung
end
end
Reek would report the following warning:
test.rb -- 1 warning:
[2]:Dummy#long_list has 5 parameters (LongParameterList)
A common solution to this problem would be the introduction of parameter objects.
Method validate_input
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def validate_input
unless RESOLUTIONS.include? resolution
raise(Fitbark::Errors::FormatError
.new(message: "Wrong or missing param 'resolution', must be kind of:
#{Fitbark::Handler::V2::ActivitySeries::RESOLUTIONS.join(', ')}"))
- 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
Fitbark::Handler::V2::ActivitySeries#format_resolution doesn't depend on instance state (maybe move it to another class?) Open
def format_resolution(val)
- Read upRead up
- Exclude checks
A Utility Function is any instance method that has no dependency on the state of the instance.
Fitbark::Handler::V2 has the name 'V2' Open
module V2
- Read upRead up
- Exclude checks
An Uncommunicative Module Name
is a module name that doesn't communicate its intent well enough.
Poor names make it hard for the reader to build a mental picture of what's going on in the code. They can also be mis-interpreted; and they hurt the flow of reading, because the reader must slow down to interpret the names.
unexpected token $end
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
- Exclude checks
unexpected token tCOLON
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
"from": from,
- Exclude checks
unexpected token tRCURLY
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
}
- Exclude checks
unexpected token tCOLON
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
"activity_series": {
- Exclude checks
unexpected token tCOLON
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
"to": to,
- Exclude checks
unexpected token tCOLON
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
"resolution": format_resolution(res)
- Exclude checks