Showing 146 of 242 total issues
Avoid deeply nested control flow statements. Open
if (set.offsetSign === '-') {
set.offsetMinutes *= -1;
}
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
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.shift) {
// Shift and unit, ie "next month", "last week", etc.
num *= (tmp = loc.modifiersByName[set.shift]) ? tmp.value : 0;
}
Consider simplifying this complex logical expression. Open
if (obj.start && obj.end) {
return obj.start >= this.start && obj.start <= this.end &&
obj.end >= this.start && obj.end <= this.end;
} else {
return obj >= this.start && obj <= this.end;
Function createDate
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function createDate(contextDate, f, localeCode, prefer, forceUTC) {
Function addFormat
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
addFormat: function(src, allowsTime, match, variant, iso) {
Function compareDate
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function compareDate(d, find, localeCode, buffer, forceUTC) {
Function extend
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function extend(klass, methods, instance, polyfill, override) {
Function getExtendedDate
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function getExtendedDate(contextDate, f, localeCode, prefer, forceUTC) {
Function truncateString
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function truncateString(str, length, from, ellipsis, split) {
Function runTagReplacements
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function runTagReplacements(str, reg, strip, replacementFn, fullString) {
Function entryAtIndex
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function entryAtIndex(obj, length, index, overshoot, isString) {
Function setDelay
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function setDelay(fn, ms, after, scope, args) {
Method languages
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.languages(query = nil)
options = []
AVAILABLE_LANGUAGES.merge(OTHER_LANGUAGES).each do |locale, language|
next if query && !language.downcase.match(query.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 access_denied
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def access_denied
message = I18n.t('general.exceptions.access_denied')
if request.format.try('json?') || request.xhr?
render status: 403, json: { error: message } and return
- 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 search
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.search(term, known_things)
begin
JSON.parse(
HTTParty.get(
"https://www.wikidata.org/w/api.php?action=wbsearchentities&search=" +
- 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 build_result
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def build_result
result_params = params[:task] ? params[:task].delete(:result_attributes) : nil
result_params = result_params || {}
unless resource.result_id.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
Method next
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def next
story = Story.find(params[:story_id])
task = story.next_task_for_user(current_user)
product_id = story.product_id.blank? ? 'no-name' : story.product_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 exception_action
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def exception_action(exception)
@exception_catched = true
if Rails.env == 'production'
notify_airbrake(exception)
- 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"