Showing 686 of 688 total issues
Method add
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add
if current_user && params[:type] == "tag"
tag = Tag.find_by(name: params[:name])
- Create a ticketCreate a ticket
Method list
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def list
sort_param = params[:sort]
@tagname_param = params[:tagname]
order_string = if params[:id]
- Create a ticketCreate a ticket
Method save_settings
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def save_settings
user_settings = [
'notify-comment-direct:false',
'notify-likes-direct:false',
'notify-comment-indirect:false',
- Create a ticketCreate a ticket
Method update
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def update
@password_verification = user_verification_params
@user = current_user
@user = User.find_by(username: params[:id]) if params[:id] && logged_in_as(['admin'])
if @user.valid_password?(user_verification_params["current_password"]) || user_verification_params["ui_update"].nil? || (user_verification_params["current_password"].blank? && user_verification_params["password"].blank? && user_verification_params["password_confirmation"].blank?)
- Read upRead up
- Create a ticketCreate a ticket
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 graph_data
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def self.graph_data(limit = 250, type = 'nodes', weight = 0)
Rails.cache.fetch("graph-data/#{limit}/#{type}/#{weight}", expires_in: 1.weeks) do
data = {}
data["tags"] = []
if type == 'nodes' # notes
- Read upRead up
- Create a ticketCreate a ticket
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 promptTag
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function promptTag(val) {
var input;
switch(val) {
case "series:":
- Read upRead up
- Create a ticketCreate a ticket
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 delete
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def delete
output = {
status: false,
tid: 0,
errors: []
- Read upRead up
- Create a ticketCreate a ticket
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 delete
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def delete
@node = Node.find(params[:id])
if current_user && (current_user.uid == @node.uid || current_user.can_moderate?)
if @node.authors.uniq.length == 1
@node.destroy
- Read upRead up
- Create a ticketCreate a ticket
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 diffString
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
function diffString( o, n ) {
o = o.replace(/\s+$/, '');
n = n.replace(/\s+$/, '');
var out = diff(o == "" ? [] : o.split(/\s+/), n == "" ? [] : n.split(/\s+/) );
- Create a ticketCreate a ticket
Method create
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
@user = User.new(user_params)
@user.status = 1
using_recaptcha = !params[:spamaway] && Rails.env == "production"
recaptcha = verify_recaptcha(model: @user) if using_recaptcha
- Create a ticketCreate a ticket
Method subscribe_multiple_tag
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def subscribe_multiple_tag(tag_list)
if !tag_list || tag_list == ''
flash[:notice] = "Please enter tags for subscription in the url."
else
if tag_list.is_a? String
- Create a ticketCreate a ticket
Method subscribe_multiple_tag
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def subscribe_multiple_tag(tag_list)
if !tag_list || tag_list == ''
flash[:notice] = "Please enter tags for subscription in the url."
else
if tag_list.is_a? String
- Create a ticketCreate a ticket
Method new_note
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.new_note(params)
saved = false
author = User.find(params[:uid])
node = Node.new(uid: author.uid,
title: params[:title],
- Create a ticketCreate a ticket
Method tagNearbyNodes
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def tagNearbyNodes(coordinates, tag, period = { "from" => nil, "to" => nil }, sort_by = nil, order_direction = nil, limit = 10)
raise("Must contain all four coordinates") if coordinates["nwlat"].nil?
raise("Must contain all four coordinates") if coordinates["nwlng"].nil?
raise("Must contain all four coordinates") if coordinates["selat"].nil?
raise("Must contain all four coordinates") if coordinates["selng"].nil?
- Create a ticketCreate a ticket
Similar blocks of code found in 2 locations. Consider refactoring. Open
$('#answer-0-comment-form').bind('ajax:success', function(e, data, status, response) {
$('#answer-0-comment-form #loading-spinner').addClass('hidden');
$('#answer-0-comment-form #reply-comment').removeClass('hidden');
$('#answer-0-comment-form #submit-comment').text('Submit');
$('#answer-0-comment-form #submit-comment-button').removeClass('disabled');
- Read upRead up
- Create a ticketCreate a ticket
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 64.
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
$('#answer-0-comment-form').bind('ajax:send', function(e) {
$('#answer-0-comment-form #loading-spinner').removeClass('hidden');
$('#answer-0-comment-form #reply-comment').addClass('hidden');
$('#answer-0-comment-form #submit-comment-button').addClass('disabled');
$('#answer-0-comment-form #submit-comment').text('Submitting');
- Read upRead up
- Create a ticketCreate a ticket
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 64.
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
Function diffString2
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function diffString2( o, n ) {
o = o.replace(/\s+$/, '');
n = n.replace(/\s+$/, '');
var out = diff(o == "" ? [] : o.split(/\s+/), n == "" ? [] : n.split(/\s+/) );
- Create a ticketCreate a ticket
Method publish_comment
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def publish_comment
if logged_in_as(['admin', 'moderator'])
@comment = Comment.find params[:id]
if @comment.status == 1
flash[:notice] = 'Comment already published.'
- Read upRead up
- Create a ticketCreate a ticket
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 create
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def create
if !current_user.admin?
flash[:warning] = 'Only admins may edit features.'
redirect_to "/features?_=#{Time.now.to_i}"
else
- Read upRead up
- Create a ticketCreate a ticket
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 alert_and_redirect_moderated
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def alert_and_redirect_moderated
if @node.author.status == User::Status::BANNED && !(logged_in_as(['admin', 'moderator']))
flash[:error] = I18n.t('application_controller.author_has_been_banned')
redirect_to '/'
elsif @node.status == 4 && (logged_in_as(['admin', 'moderator']))
- Read upRead up
- Create a ticketCreate a ticket
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"