Showing 58 of 126 total issues
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 calculated_elo
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def calculated_elo
@calcualted_elo ||= begin
winners_delta = []
losers_delta = []
winners_elo = Elo.team_elo(winners)
Function show
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Tab.prototype.show = function () {
var $this = this.element
var $ul = $this.closest('ul:not(.dropdown-menu)')
var selector = $this.data('target')
Function checkPosition
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Affix.prototype.checkPosition = function () {
if (!this.$element.is(':visible')) return
var height = this.$element.height()
var offset = this.options.offset
Method validate_unique_challenge
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def validate_unique_challenge
return unless state == ChallengeState::PROPOSED || state == ChallengeState::ACCEPTED
(challengers + challenged).each do |player|
existing_challenge = ::Challenge.find_by_user(team, channel, 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
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 set_leaderboard_max
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def set_leaderboard_max(client, data, user, v)
raise SlackGamebot::Error, "You're not a captain, sorry." unless v.nil? || user.captain?
unless v.nil?
v = parse_int_with_inifinity(v)
- 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"
Further reading
Function hide
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Collapse.prototype.hide = function () {
if (this.transitioning || !this.$element.hasClass('in')) return
var startEvent = $.Event('hide.bs.collapse')
this.$element.trigger(startEvent)
Function next
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function next() {
$active
.removeClass('active')
.find('> .dropdown-menu > .active')
.removeClass('active')
Function cbpAnimatedHeader
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
var cbpAnimatedHeader = (function() {
var docElem = document.documentElement,
header = document.querySelector( '.navbar-default' ),
didScroll = false,
Function refresh
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
ScrollSpy.prototype.refresh = function () {
var that = this
var offsetMethod = 'offset'
var offsetBase = 0
Method validate_updated_by
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def validate_updated_by
case state
when ChallengeState::ACCEPTED
return if updated_by && challenged.include?(updated_by)
- 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 set_api
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def set_api(client, data, user, v)
raise SlackGamebot::Error, "You're not a captain, sorry." unless v.nil? || user.captain?
client.owner.update_attributes!(api: v.to_b) unless v.nil?
message = [
- 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 set_unbalanced
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def set_unbalanced(client, data, user, v)
raise SlackGamebot::Error, "You're not a captain, sorry." unless v.nil? || user.captain?
client.owner.update_attributes!(unbalanced: v.to_b) unless v.nil?
client.say(channel: data.channel, text: "Unbalanced challenges for team #{client.owner.name} are #{client.owner.unbalanced? ? 'on!' : 'off.'}", gif: 'balance')
- 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 deactivate_dead_teams!
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def deactivate_dead_teams!
Team.active.each do |team|
next if team.subscribed?
next unless team.dead?
- 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 set_gifs
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def set_gifs(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!(gifs: v.to_b)
- 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 deeply nested control flow statements. Open
current = :scores if opponents.count == teammates.count
Avoid deeply nested control flow statements. Open
current = :scores if opponents.count == teammates.count
Method check_trials!
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def check_trials!
Team.active.where(subscribed: false).each do |team|
logger.info "Team #{team} has #{team.remaining_trial_days} trial days left."
next unless team.remaining_trial_days > 0 && team.remaining_trial_days <= 3
- 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"