Showing 46 of 67 total issues
Function length
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
length: function(element, options) {
var CHECKS, blankOptions, check, fn, message, operator, tokenized_length, tokenizer;
tokenizer = options.js_tokenizer || "split('')";
tokenized_length = new Function('element', "return (element.val()." + tokenizer + " || '').length")(element);
CHECKS = {
Method display_value
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def display_value
case response_field.field_type
when "price"
"$#{value}"
when "date"
Method notification_preference_choices
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.notification_preference_choices
{
teams: {
added_to_team: [:added_to_organization_team, :added_to_vendor_team],
added_your_team_to_project: true
Consider simplifying this complex logical expression. Open
if (event_type.in?(Event.event_types.only(:your_bid_awarded, :bid_awarded).values) &&
data[:bid][:award_message]) ||
# Your bid is dismissed and you're allowed to see the dismissal message
(event_type == Event.event_types[:your_bid_dismissed] &&
Method active_page?
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def active_page?(action, class_to_add = "active")
pieces = action.split(/\#|\?/)
is_active_page = true
pieces.each_with_index do |piece, index|
- 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 save_responses
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def save_responses(responsable, response_fields)
response_fields.each do |response_field|
next unless params[:response_fields] && (response_field_params = params[:response_fields][response_field.id.to_s])
response = responsable.responses.where(response_field_id: response_field.id).first_or_initialize(user_id: current_user.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
Method has_searcher
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def has_searcher(args = {})
send(:include, PgSearch)
if args[:starting_query]
define_singleton_method :searcher_starting_query do
- 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_i18n_interpolation_data
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def calculate_i18n_interpolation_data
return_hash = {}
attrs = [
"user.display_name", "bid.vendor.name", "project.title", "vendor.name",
- 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 active_user_sidebar_section?
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def active_user_sidebar_section?(type, obj = nil)
is_active_section = case type
when :user
active_page?('home#dashboard') ||
active_page?('notifications#index') ||
- 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
if ($(this).data('notLocallyUnique')) {
return $(this).removeData('notLocallyUnique').data('changed', true);
}
Method initialize
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def initialize(user)
can :read, Project do |project|
project.posted_at
end
- 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 create
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def create
@user = user_from_params
if @user.save
sign_in @user
- 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 has_additional_text?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def has_additional_text?
# Bid is awarded and has an award message
if (event_type.in?(Event.event_types.only(:your_bid_awarded, :bid_awarded).values) &&
data[:bid][:award_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 add_params_to_query
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.add_params_to_query(query, params, args = {})
if params[:q] && !params[:q].blank?
query = query.full_search(params[:q])
end
- 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
return;
Avoid too many return
statements within this function. Open
return options.message;
Avoid too many return
statements within this function. Open
return options.messages[check];
Avoid too many return
statements within this function. Open
return options.messages.odd;
Avoid too many return
statements within this function. Open
return options.messages.even;
Method extra_user_links
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def extra_user_links(opts = {})
links = []
links << link_to(I18n.t('g.sign_in'), sign_in_path) unless opts[:without] == "sign_in"
links << link_to(I18n.t('g.sign_up'), sign_up_path) unless opts[:without] == "sign_up"
- 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"