Class has too many lines. [110/100] Open
class PositionBuilder
include Jiji::Model::Trading
include Jiji::Model::Trading::Utils
- 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.
Assignment Branch Condition size for build_from_order is too high. [17.29/15] Open
def build_from_order(order, tick, account_currency, agent = nil)
position = Position.new do |p|
initialize_trading_information(p, @backtest, order.internal_id,
order.pair_name, order.units, order.sell_or_buy)
price = order.type == :market ? PricingUtils.calculate_entry_price(
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [11/10] Open
def build_from_order(order, tick, account_currency, agent = nil)
position = Position.new do |p|
initialize_trading_information(p, @backtest, order.internal_id,
order.pair_name, order.units, order.sell_or_buy)
price = order.type == :market ? PricingUtils.calculate_entry_price(
- 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 build_from_tick
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def build_from_tick(internal_id, pair_name,
units, sell_or_buy, tick, account_currency, options = {})
Method initialize_trading_information
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize_trading_information(position,
backtest, internal_id, pair_name, units, sell_or_buy)
Method initialize_price_and_time_from_tick
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
position, tick, pair_name, sell_or_buy, account_currency)
Method create_splited_position
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def create_splited_position(position,
units, price, time, agent)
Method split_and_close
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def split_and_close(position, units,
price, time, agent = nil)
Similar blocks of code found in 2 locations. Consider refactoring. Open
def initialize_trading_information_from_trade_opend_of_order_result(position, trade)
pair_name = Jiji::Model::Securities::Internal::Utils::Converter\
.convert_instrument_to_pair_name(trade['instrument'])
initialize_trading_information(position, @backtest,
trade['tradeID'], pair_name, trade['units'].to_i.abs,
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 30.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def initialize_trading_information_from_trade(position, trade)
pair_name = Jiji::Model::Securities::Internal::Utils::Converter\
.convert_instrument_to_pair_name(trade['instrument'])
initialize_trading_information(position, @backtest,
trade['id'], pair_name, trade['currentUnits'].to_i.abs,
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 30.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def build_from_trade(trade)
Position.new do |p|
initialize_trading_information_from_trade(p, trade)
initialize_price_and_time(p, trade['price'].to_f, Time.parse(trade['openTime']), nil)
p.closing_policy = ClosingPolicy.create_from_trade(trade)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 27.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def build_from_trade_opend_of_order_result(trade)
Position.new do |p|
initialize_trading_information_from_trade_opend_of_order_result(p, trade)
initialize_price_and_time(p, trade['price'].to_f, Time.parse(trade['time']), nil)
p.closing_policy = ClosingPolicy.create_from_trade(trade)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 27.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Line is too long. [93/80] Open
initialize_price_and_time(p, trade['price'].to_f, Time.parse(trade['openTime']), nil)
- Exclude checks
Line is too long. [81/80] Open
initialize_trading_information_from_trade_opend_of_order_result(p, trade)
- Exclude checks
Line is too long. [88/80] Open
def initialize_trading_information_from_trade_opend_of_order_result(position, trade)
- Exclude checks
Line is too long. [89/80] Open
initialize_price_and_time(p, trade['price'].to_f, Time.parse(trade['time']), nil)
- Exclude checks