Showing 58 of 126 total issues
Avoid deeply nested control flow statements. Open
current = :scores if opponents.count == teammates.count
Avoid deeply nested control flow statements. Open
challenge.draw_scores? ? "Recorded #{Score.scores_to_string(challenge.draw_scores)}." : nil
Consider simplifying this complex logical expression. Open
if (code && game && (game == 'pong' || game == 'chess' || game == 'pool' || game == 'tic-tac-toe')) {
PlayPlay.register();
PlayPlay.message('Working, please wait ...');
$.ajax({
type: "POST",
Consider simplifying this complex logical expression. Open
if ((version[0] < 2 && version[1] < 9) || (version[0] == 1 && version[1] == 9 && version[2] < 1) || (version[0] > 2)) {
throw new Error('Bootstrap\'s JavaScript requires jQuery version 1.9.1 or higher, but lower than version 3')
}
Method unset
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def unset(client, data, user, k, v)
Method new_from_teammates_and_opponents
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.new_from_teammates_and_opponents(client, channel, challenger, names, separator = 'with')
Method set
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def set(client, data, user, k, v)
Method create_from_teammates_and_opponents!
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.create_from_teammates_and_opponents!(client, channel, challenger, names, separator = 'with')
Method set_aliases
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def set_aliases(client, data, user, v)
raise SlackGamebot::Error, "You're not a captain, sorry." unless v.nil? || user.captain?
unless v.nil?
client.owner.update_attributes!(aliases: v.split(/[\s,;]+/))
- 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 score_verb
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def score_verb
if tied?
'tied with'
elsif !scores
'defeated'
- 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 draw!
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def draw!(player, scores = nil)
raise SlackGamebot::Error, 'Challenge must first be accepted.' if state == ChallengeState::PROPOSED
raise SlackGamebot::Error, "Challenge has already been #{state}." unless state == ChallengeState::ACCEPTED || state == ChallengeState::DRAWN
raise SlackGamebot::Error, "Already recorded a draw from #{player.user_name}." if draw.include?(player)
- 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
Avoid too many return
statements within this function. Open
if (offsetBottom != null && (colliderTop + colliderHeight >= scrollHeight - offsetBottom)) return 'bottom'
Avoid too many return
statements within this function. Open
return false
Method to_s
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def to_s
[
"#{label}: #{winners ? winners.map(&:to_s).and : 'n/a'}",
"#{team.matches.count} match#{team.matches.count == 1 ? '' : 'es'}",
"#{players.count} player#{players.count == 1 ? '' : 's'}"
- 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 check_active_subscriptions_without_teams!
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def check_active_subscriptions_without_teams!
Stripe::Subscription.all(plan: 'slack-playplay-yearly').each do |subscription|
next if subscription.cancel_at_period_end
next if Team.where(stripe_customer_id: subscription.customer).exists?
- 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 activated!
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def activated!
return unless active? && activated_user_id && bot_user_id
return unless active_changed? || activated_user_id_changed?
inform_activated!
- 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 sort
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def sort(coll, options = {})
sort_order = sort_order(options)
unless sort_order.empty?
if coll.respond_to?(:asc) && coll.respond_to?(:desc)
sort_order.each do |s|
- 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 ping_if_active!
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def ping_if_active!
return unless active?
ping!
rescue Slack::Web::Api::Errors::SlackError => e
- 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"