BenMusch/nu-tab

View on GitHub
app/models/concerns/rankable.rb

Summary

Maintainability
A
25 mins
Test Coverage
# frozen_string_literal: true
Add an empty line after magic comments.
module Rankable
`%w`-literals should be delimited by `[` and `]`.
RANKING_PRIORITY = %w(speaks
ranks
single_adjusted_speaks
single_adjusted_ranks
double_adjusted_speaks
double_adjusted_ranks
average_opponent_wins).freeze
 
Method `<=>` has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def <=>(other)
RANKING_PRIORITY.each do |attr|
difference = other.stats.send(attr) - stats.send(attr)
next if difference.zero?
return attr.include?('ranks') ? -1 * difference : difference
end
coin_flip
end
 
def coin_flip
rand(2).zero? ? -1 : 1
end
end