Showing 146 of 242 total issues
Function defineOnGlobal
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
function defineOnGlobal(klass, name, instance, original, prop, existed, polyfill) {
Function arrayFind
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function arrayFind(arr, f, startIndex, loop, returnIndex, context) {
Avoid deeply nested control flow statements. Open
if (set.shift && !set.unit) {
set.unit = loc.units[5];
}
Function extendSimilar
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function extendSimilar(klass, set, fn, instance, polyfill, override) {
Function abbreviateNumber
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function abbreviateNumber(num, roundTo, str, mid, limit, bytes) {
Avoid deeply nested control flow statements. Open
if (set.offsetSign === '-') {
set.offsetMinutes *= -1;
}
Function updateDate
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function updateDate(d, params, reset, advance, prefer, weekdayForward) {
Avoid deeply nested control flow statements. Open
unless (@result.new_record? rescue true)
results.item(:show, @result.name, result_path(@result)) do |result|
if can? :destroy, @result
result.item :destroy, I18n.t('general.destroy'), result_path(@result), method: :delete, confirm: I18n.t('general.questions.are_you_sure')
end
Avoid deeply nested control flow statements. Open
if can? :destroy, @task
task.item :destroy, I18n.t('general.destroy'), task_path(@task), method: :delete, confirm: I18n.t('general.questions.are_you_sure')
end
Avoid deeply nested control flow statements. Open
unless (@task.new_record? rescue true)
Avoid deeply nested control flow statements. Open
if (isDefined(set.weekday)) {
// Units can be with non-relative dates, set here. ie "the day after monday"
setDate(d, [{ weekday: set.weekday }, true]);
delete set.weekday;
}
Method create_with_topic
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.create_with_topic(user_id, attributes)
topic = ArgumentTopic.find_or_create_by_name attributes[:topic_name]
if topic.valid?
argumentable_id = if attributes[:argumentable_name].present?
- 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 (set.shift && !set.unit) set.unit = loc.units[7];
Method translate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def translate(locale, key, options = {})
default = extract_non_symbol_default!(options) if options[:default]
options.merge!(:default => default) if default
I18n.fallbacks[locale].each do |fallback|
- 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(status == google.maps.GeocoderStatus.OK && results && results.length) {
GmUtility.setPosition(gmapContext, results[0].geometry.location, function(context) {
updateInputValues(inputBinding, context);
context.settings.onchanged.apply(gmapContext.domContainer,
[GmUtility.locationFromLatLng(context.location), context.radius, false]);
Avoid deeply nested control flow statements. Open
if (set.shift) {
// Shift and unit, ie "next month", "last week", etc.
num *= (tmp = loc.modifiersByName[set.shift]) ? tmp.value : 0;
}
Avoid deeply nested control flow statements. Open
unless (@task.new_record? rescue true)
Method set_project_defaults
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def set_project_defaults(attributes)
attributes[:user_id] ||= @me.id if @me && !attributes[:user_id]
attributes[:product_id] ||= @product.id if @product && !attributes[:product_id]
attributes[:area_ids] ||= [Area.last.id] if Area.any? && !attributes[:area_ids]
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 deeply nested control flow statements. Open
if @comment.try(:id) && can?(:edit, @comment)
comments.item(:edit, I18n.t('general.edit'), edit_comment_path(@comment))
end
Avoid deeply nested control flow statements. Open
comments.item(:new, I18n.t('general.new'), new_story_comment_path(@story)) if @comment