BenMusch/nu-tab

View on GitHub
app/policies/stats/round.rb

Summary

Maintainability
A
1 hr
Test Coverage
# frozen_string_literal: true
Add an empty line after magic comments.
module Stats
module Round
# rubocop:disable Metrics/PerceivedComplexity
Assignment Branch Condition size for policy_for is too high. [18.81/15]
Method `policy_for` has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
def self.policy_for(debater, round)
if round.bye? || round.all_win?
AverageStatsPolicy.new debater, round
elsif round.forfeit? || round.all_drop?
klass = round.winner?(debater.team) ? AverageStatsPolicy : self.forfeit_policy
klass.new debater, round
elsif round.didnt_compete?(debater)
self.forfeit_policy.new debater, round
elsif round.iron_person?(debater)
IronPersonPolicy.new debater, round
elsif round.standard_result?
StandardPolicy.new debater, round
else
BlankPolicy.new debater, round
end
end
# rubocop:enable Metrics/PerceivedComplexity
 
def self.forfeit_policy
TournamentSetting.get_bool('punish_forfeits') ? PunitivePolicy : AverageStatsPolicy
end
end
end