Method find_by_slack_mention!
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
def self.find_by_slack_mention!(client, user_name)
team = client.owner
slack_id = slack_mention?(user_name)
user = if slack_id
team.users.where(user_id: slack_id).first
- 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 find_create_or_update_by_slack_id!
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def self.find_create_or_update_by_slack_id!(client, slack_id)
instance = User.where(team: client.owner, user_id: slack_id).first
users_info = client.web_client.users_info(user: slack_id)
instance_info = Hashie::Mash.new(users_info).user if users_info
if users_info && instance
- 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 to_s
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def to_s
wins_s = "#{wins} win#{wins == 1 ? '' : 's'}"
losses_s = "#{losses} loss#{losses == 1 ? '' : 'es'}"
ties_s = "#{ties} tie#{ties == 1 ? '' : 's'}" if ties && ties > 0
elo_s = "elo: #{team_elo}"
- 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 find_by_slack_mention!
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.find_by_slack_mention!(client, user_name)
team = client.owner
slack_id = slack_mention?(user_name)
user = if slack_id
team.users.where(user_id: slack_id).first
Method calculate_streaks!
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def calculate_streaks!
longest_winning_streak = 0
longest_losing_streak = 0
current_winning_streak = 0
current_losing_streak = 0
- 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 rank!
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.rank!(team)
rank = 1
players = any_of({ :wins.gt => 0 }, { :losses.gt => 0 }, :ties.gt => 0).where(team: team, registered: true).desc(:elo).desc(:wins).asc(:losses).desc(:ties)
players.each_with_index do |player, index|
if player.registered?
- 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"