Showing 24 of 34 total issues
File diff_match_patch.js
has 641 lines of code (exceeds 250 allowed). Consider refactoring. Open
(function() {
function diff_match_patch() {
this.Diff_Timeout = 1;
this.Diff_EditCost = 4;
this.Match_Threshold = 0.5;
Method complete_internal_references
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def complete_internal_references(resource, attribute_name)
resource.send(attribute_name).to_s.lines.map do |line|
line.gsub!(/\[(.*?)\]\((@(.+?)-(.+?))\)/) do
caption = $1
url = $2
- 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 validate_each
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def validate_each(record, attribute, value)
raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") unless value.kind_of? CarrierWave::Uploader::Base
value = (options[:tokenizer] || DEFAULT_TOKENIZER).call(value) if value.kind_of?(String)
- 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 indent_heading_level
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def indent_heading_level(markdown, heading_level, visual_heading_level = nil)
markdown.to_s.lines.map do |line|
line = line.rstrip # Remove all new line stuff (\n, \r)
if matches = line.match(/^([#]+)(.*)$/)
- 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
Consider simplifying this complex logical expression. Open
if (!(a[c].length1 <= b)) {
var d = a[c];
a.splice(c--, 1);
for (var e = d.start1, f = d.start2, g = ""; 0 !== d.diffs.length;) {
var h = new diff_match_patch.patch_obj,
Method complete_internal_references
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def complete_internal_references(resource, attribute_name)
resource.send(attribute_name).to_s.lines.map do |line|
line.gsub!(/\[(.*?)\]\((@(.+?)-(.+?))\)/) do
caption = $1
url = $2
Function diff_cleanupSemanticLossless
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
diff_match_patch.prototype.diff_cleanupSemanticLossless = function(a) {
function b(a, b) {
if (!a || !b) return 6;
var c = a.charAt(a.length - 1),
d = b.charAt(0),
Consider simplifying this complex logical expression. Open
else if (-1 == a[f][0] ? i = !0 : j = !0, e && (g && h && j && i || e.length < this.Diff_EditCost / 2 && 3 == g + h + j + i)) a.splice(c[d - 1], 0, [-1, e]), a[c[d - 1] + 1][0] = 1, d--, e = null, g && h ? (j = i = !0, d = 0) : (d--, f = 0 < d ? c[d - 1] : -1, j = i = !1), b = !0;
Function diff_lineMode_
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
diff_match_patch.prototype.diff_lineMode_ = function(a, b, c) {
var d = this.diff_linesToChars_(a, b);
a = d.chars1;
b = d.chars2;
d = d.lineArray;
Function diff_bisect_
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
diff_match_patch.prototype.diff_bisect_ = function(a, b, c) {
for (var d = a.length, e = b.length, f = Math.ceil((d + e) / 2), g = f, h = 2 * f, j = Array(h), i = Array(h), k = 0; k < h; k++) j[k] = -1, i[k] = -1;
j[g + 1] = 0;
i[g + 1] = 0;
for (var k = d - e, q = 0 != k % 2, r = 0, t = 0, p = 0, w = 0, v = 0; v < f && !((new Date).getTime() > c); v++) {
Function patch_make
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
diff_match_patch.prototype.patch_make = function(a, b, c) {
var d;
if ("string" == typeof a && "string" == typeof b && "undefined" == typeof c) d = a, b = this.diff_main(d, b, !0), 2 < b.length && (this.diff_cleanupSemantic(b), this.diff_cleanupEfficiency(b));
else if (a && "object" == typeof a && "undefined" == typeof b && "undefined" == typeof c) b = a, d = this.diff_text1(b);
else if ("string" == typeof a && b && "object" == typeof b && "undefined" == typeof c) d = a;
Function patch_fromText
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
diff_match_patch.prototype.patch_fromText = function(a) {
var b = [];
if (!a) return b;
a = a.split("\n");
for (var c = 0, d = /^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/; c < a.length;) {
Function match_bitap_
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
diff_match_patch.prototype.match_bitap_ = function(a, b, c) {
function d(a, d) {
var e = a / b.length,
g = Math.abs(c - d);
return !f.Match_Distance ? g ? 1 : e : e + g / f.Match_Distance
Method icon_for
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def icon_for(extension)
if ['zip', 'rar', '7z', '7zip', 'gzip'].include? extension
'file-archive-o'
elsif ['mp3', 'wav'].include? extension
'file-audio-o'
- 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
Function patch_apply
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
diff_match_patch.prototype.patch_apply = function(a, b) {
if (0 == a.length) return [b, []];
a = this.patch_deepCopy(a);
var c = this.patch_addPadding(a);
b = c + b + c;
Method real_input_new
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def real_input_new
template.content_tag :div, title: I18n.t('simple_form.inputs.upload.click_to_choose_a_file', attribute: raw_label_text), data: {placement: 'right'} do # We need another div around the whole thing, otherwise Bootstrap tooltip doesn't seem to work! See http://stackoverflow.com/questions/24497353/bootstrap-tooltip-isnt-shown-on-a-specific-element-but-it-seems-to-be-applied
template.content_tag :a, href: '#', class: ['fileinput-new', 'thumbnail'], data: {trigger: 'fileinput'} do
if file_available?
if ['jpg', 'jpeg', 'gif', 'png'].include? object.send(attribute_name).file.extension
- 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 remove_abandoned_pastables
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def remove_abandoned_pastables
[:images, :codes].each do |pastables|
referenced_pastables = []
resource.textareas_accepting_pastables.each do |textarea|
- 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 navigation_item
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def navigation_item(*args, &block)
options = args.extract_options!
if args.size == 2
title = args[0]
- 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 initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(id, parent_id, options, view, block)
Function diff_bisectSplit_
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
diff_match_patch.prototype.diff_bisectSplit_ = function(a, b, c, d, e) {