Showing 48 of 48 total issues
Method raw_ranking_configuration
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def raw_ranking_configuration
Hash[{
large_tournament_multiplier:
params['large_tournament_multiplier'].blank? || (params['large_tournament_multiplier'] == 'true') ? nil : params['large_tournament_multiplier'],
widespread_use_multiplier:
- 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 initialize
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(ranking_configuration, ship_id: nil, ship_combo_id: nil, pilot_id: nil, upgrade_id: nil, limit: nil)
start_date = ranking_configuration[:ranking_start]
end_date = ranking_configuration[:ranking_end]
tournament_type = ranking_configuration[:tournament_type]
joins = <<-SQL
Method initialize
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(ranking_configuration, ship_id: nil, pilot_id: nil, limit: nil, upgrade_id: nil, ship_combo_id: nil)
start_date = ranking_configuration[:ranking_start]
end_date = ranking_configuration[:ranking_end]
tournament_type = ranking_configuration[:tournament_type]
joins = <<-SQL
Method build_ranking_data
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def build_ranking_data(tournament_id)
if (tournament_id.to_f / 50) == (tournament_id.to_i / 50)
print "#{tournament_id}."
else
print '.'
- 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 sync_tournaments
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def sync_tournaments(minimum_id: nil, start_date: nil, add_missing: false)
uri = URI.parse('http://lists.starwarsclubhouse.com/api/v1/tournaments')
response = Net::HTTP.get_response(uri)
tournaments = JSON.parse(response.body).try(:[], 'tournaments') || []
tournaments.sort.each do |lists_juggler_id|
- 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 initialize
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(ranking_configuration, ship_id: nil, pilot_id: nil, ship_combo_id: nil, upgrade_id: nil)
start_date = ranking_configuration[:ranking_start]
end_date = ranking_configuration[:ranking_end]
tournament_type = ranking_configuration[:tournament_type]
joins = <<-SQL
Method initialize
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(ranking_configuration, ship_id: nil, ship_combo_id: nil, group_by_faction: false, faction_id: nil)
start_date = ranking_configuration[:ranking_start]
end_date = ranking_configuration[:ranking_end]
tournament_type = ranking_configuration[:tournament_type]
joins = <<-SQL
Method initialize
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(ranking_configuration, ship_id: nil, pilot_id: nil, upgrade_id: nil, ship_combo_id: nil, limit: 2)
start_date = ranking_configuration[:ranking_start]
end_date = ranking_configuration[:ranking_end]
tournament_type = ranking_configuration[:tournament_type]
joins = <<-SQL
Method build_ranking_data
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_ranking_data(tournament_id)
if (tournament_id.to_f / 50) == (tournament_id.to_i / 50)
print "#{tournament_id}."
else
print '.'
Method build_weight_query
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_weight_query
weight_query = case ranking_configuration[:use_ranking_data]
when 'swiss'
<<-SQL
avg(
Method sync_tournament
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def sync_tournament(tournament)
uri = URI.parse("http://lists.starwarsclubhouse.com/api/v2/tournament/#{tournament.lists_juggler_id}")
response = Net::HTTP.get_response(uri)
begin
tournament_data = JSON.parse(response.body).try(:[], 'tournament')
Method initialize
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(ranking_configuration, ship_combo_id)
start_date = ranking_configuration[:ranking_start]
end_date = ranking_configuration[:ranking_end]
tournament_type = ranking_configuration[:tournament_type]
joins = <<-SQL
Method ranking_configuration
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def ranking_configuration
{
large_tournament_multiplier: params['large_tournament_multiplier'].nil? ? true : (params['large_tournament_multiplier'] == 'true'),
widespread_use_multiplier: params['widespread_use_multiplier'].nil? ? true : (params['widespread_use_multiplier'] == 'true'),
use_ranking_data: params['use_ranking_data'].nil? ? 'all' : params['use_ranking_data'],
- 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 build_squadron
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_squadron(squadron_xws)
squadron_xws = JSON.parse(squadron_xws) if squadron_xws.is_a?(String)
faction_xws = squadron_xws.try(:[], 'faction')
faction = Faction.find_by(xws: faction_xws, is_subfaction: false)
squadron = Squadron.new({
Method preset_dates
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def preset_dates
[
['', nil],
[I18n.t('shared.filter_configurator.dates.wave_1'), Date.new(2012, 9, 14)],
[I18n.t('shared.filter_configurator.dates.wave_2'), Date.new(2013, 2, 28)],
Method generate_ship_combos
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate_ship_combos(context, ship_combos, ships, ids = [])
::CSV.generate do |csv|
csv << [
context.t('ship_combos.csv.position'),
context.t('ship_combos.csv.archetype_name'),
Method update
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
ActiveRecord::Base.transaction do
suggestion = ArchetypeNameSuggestion.find(params[:id])
ship_combo = suggestion.ship_combo
case params[:mod_action]
Method build_win_loss_query
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_win_loss_query
case ranking_configuration[:use_ranking_data]
when 'swiss'
<<-SQL
avg(squadrons.win_loss_ratio_swiss)
Method generate_pilots
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate_pilots(context, pilots, ids = [])
::CSV.generate do |csv|
csv << [
context.t('pilots.csv.position'),
context.t('pilots.csv.pilot_name'),
Method find_with_key
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def find_with_key(relation, key, faction_xws = nil)
if faction_xws.present?
model = relation.where(xws: key).where(faction_id: Faction.where(xws: faction_xws)).first
else
model = relation.find_by(xws: key)