Showing 93 of 93 total issues
File challenge.rb
has 260 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Challenge < ApiModel
include Redis::ChallengeSearchable
attr_accessor :id, :challenge_id, :challenge_type, :attributes,
:prize_type, :total_prize_money, :top_prize,
Class Participant
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class Participant < ApiModel
def self.api_endpoint
"participants"
end
Method authenticate_account
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def authenticate_account
ApiModel.access_token = guest_access_token
account = Account.new(User.new(:username => params[:user][:username]))
- 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 authenticate_account
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
def authenticate_account
ApiModel.access_token = guest_access_token
account = Account.new(User.new(:username => params[:user][:username]))
Method create
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
data = {}
data[:name] = params[:name]
data[:description] = '<p>Your
Method search
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def search
@title = 'Challenge Search Results'
search_default_params
gon.adv_search_display = true
Method process_messages
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def process_messages(messages, type)
processed_messages = []
messages.each do |m|
new_message = {}
new_message['id'] = m.id
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
}else{
$('.tip .arrow').css({left:$(this).position().left-$(this).parents("ul").position().left+50})
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 70.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if($('.techs').width()==134){
$('.tip .arrow').css({top:$(this).position().top-$(this).parents("ul").position().top+40})
}else{
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 70.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method create
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def create
# find out how the user is logging in
login_type = Member.login_type params[:username].downcase
# if we found a valid user
if login_type
- 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_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
Similar blocks of code found in 2 locations. Consider refactoring. Open
nameTmpl: function(item, typeahead) {
return $("<span class='challenge'>")
.append("<i class='icon-leaf'>")
.append(typeahead.highlighter(item.name))
.append(" (<span class='prizes'>$" + item.total_prize_money + "</span>)")
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 67.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
nameTmpl: function(item, typeahead) {
return $("<span class='member'>")
.append("<i class='icon-user'>")
.append(typeahead.highlighter(item.name))
.append("(<span class='wins'>" + item.total_wins + " wins</span>)")
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 67.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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'])
Similar blocks of code found in 2 locations. 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
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 60.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76