Showing 56 of 93 total issues
Method process_submission
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def self.process_submission(challenge_id, membername, challenge_submission_id)
# get an admin token for the get requests. fails without an admin token. not sure why.
admin_access_token = RestforceUtils.access_token(:admin)
- 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 update
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
# scrub out this crap when nothing submitted in ckeditor -- <p>Â </p>\r\n (see http://dev.ckeditor.com/ticket/9732)
params[:admin_challenge][:description] = nil if params[:admin_challenge][:description].include?('Â ')
params[:admin_challenge][:requirements] = nil if params[:admin_challenge][:requirements].include?('Â ')
Method advanced_search
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.advanced_search(options)
params = Hashie::Mash.new()
if options[:platforms]
Method getJsConnectString
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def JsConnect.getJsConnectString(user, request = {}, client_id = "", secret = "", secure = true)
error = nil
timestamp = request["timestamp"].to_i
current_timestamp = JsConnect.timestamp
Method process_submission
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.process_submission(challenge_id, membername, challenge_submission_id)
# get an admin token for the get requests. fails without an admin token. not sure why.
admin_access_token = RestforceUtils.access_token(:admin)
Method payload
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def payload
# Get the original challenge to figure out the stuff to be deleted.
# We are re-requesting the original challenge instead of tracking which
# entries are to be deleted client-side to minimize race conditions. Race
# conditions aren't totally eliminated, but the window is largely smaller
Method login_third_party
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def login_third_party(omniauth, sfdc_account)
begin
db_authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])
Method search
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def search
@title = 'Challenge Search Results'
search_default_params
gon.adv_search_display = true
- 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 redis_insert
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def redis_insert
Rails.logger.info "[REDIS] Inserting challenge #{challenge_id}"
nest[:raw_data].hset challenge_id, raw_data.to_json
redis_metaphones.each do |meta|
Function appendItem
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
appendItem: function(source) {
var that = this,
html,
$standardItem;
Method current_access_token
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def current_access_token
if current_user
if current_user.access_token
current_user.last_access_token_refresh_at = Date.yesterday if current_user.last_access_token_refresh_at.nil?
logger.info "[ACCESS_TOKEN] Has access token expired?: #{Time.now.utc} (Now) > 45 minutes past last refresh #{current_user.last_access_token_refresh_at.getutc} - expired? #{Time.now.utc > 45.minutes.since(current_user.last_access_token_refresh_at.getutc)}"
- 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 perform
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.perform(membername, email, challenge_id, challenge_participant_id)
account = {
:name => membername,
:email => email,
Method update
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
user = User.find_by_username(params[:user][:username].downcase)
attributes = params[:user]
if user and attributes[:password].present? and attributes[:password] == attributes[:password_confirmation]
resp = user.account.update_password(attributes[:reset_password_token], attributes[:password])
Method login_third_party
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def login_third_party(omniauth, sfdc_account)
begin
db_authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])
- 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 process_messages
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process_messages(messages, type)
processed_messages = []
messages.each do |m|
new_message = {}
new_message['id'] = m.id
Method show_restricted_info
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def show_restricted_info(participant, user)
# if a challenge admin always return true!
return true if user && user.challenge_admin?(self)
if @require_registration
return false if participant.nil?
- 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_for_appirio_task
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def check_for_appirio_task
if params[:task]
cmc_client = Restforce.new :username => ENV['CMC_USERNAME'],
:password => ENV['CMC_PASSWORD'],
- 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 redis_key_for_prize_money
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def redis_key_for_prize_money(value)
if value.is_a?(Hash)
min = value[:min].blank? ? 0 : value[:min].to_i
max = value[:max].blank? ? 1000000 : value[:max].to_i
nest[:temp][{prize_money: value}.hash].tap do |k|
- 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 results
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def results
if user_signed_in?
unless ['winner selected','no winner selected','failed','no winner selected'].include?(@challenge.status.downcase) ||
@challenge.challenge_type.downcase == "first2finish" ||
(current_user.challenge_admin?(@challenge) && ['review','scored - awaiting approval'].include?(@challenge.status.downcase))
- 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 initialize
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def initialize(params={})
# the api names some fields as challenge_xxx where as the payload needs to be xxx
# params['reviewers'] = params.delete('challenge_reviewers') if params.include? 'challenge_reviewers'
# params['commentNotifiers'] = params.delete('challenge_comment_notifiers') if params.include? 'challenge_comment_notifiers'
params['prizes'] = params.delete('challenge_prizes__r') if params.include? 'challenge_prizes__r'
- 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"