src/jiji/model/trading/closing_policy.rb
Class ClosingPolicy
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class ClosingPolicy
include Mongoid::Document
include Jiji::Errors
include Jiji::Utils::ValueObject
Method update_from_order_options
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Open
def update_from_order_options(options, price) #:nodoc:
if options.include?(:stopLoss)
self.stop_loss = !options[:stopLoss].nil? ? \
ClosingPolicy.extract_stop_loss_from_order(options[:stopLoss], price) : 0
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 calculate_trailing_amount
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def calculate_trailing_amount(position, price, amount)
if position.sell_or_buy == :buy
new_price = (price - amount).to_f
trailing_amount&.zero? ?
new_price : [new_price, trailing_amount].max
- 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
unexpected token error
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
Open
return false if take_profit&.zero?
- Exclude checks
unexpected token error
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
Open
return if trailing_stop&.zero?
- Exclude checks
unexpected token error
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
Open
trailing_amount&.zero? ?
- Exclude checks
unexpected token error
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
Open
return false if stop_loss&.zero?
- Exclude checks
unexpected token error
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
Open
return false if trailing_amount&.zero?
- Exclude checks
unexpected token error
(Using Ruby 2.1 parser; configure using TargetRubyVersion
parameter, under AllCops
) Open
Open
trailing_amount&.zero? ?
- Exclude checks