Showing 44 of 68 total issues
Function template
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
_.template = function(text, data, settings) {
var render;
settings = _.defaults({}, settings, _.templateSettings);
// Combine delimiters into one regular expression via alternation.
Function inputHistory
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
return $.fn.inputHistory = function(options) {
var history, _this = this;
options || (options = {});
options.data || (options.data = 'inputHistory');
Function sync
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
Backbone.sync = function(method, model, options) {
var type = methodMap[method];
// Default options, unless specified.
_.defaults(options || (options = {}), {
Method check_external_avatar
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
def check_external_avatar
# avatar url is not required
return if self.avatar_url.blank?
uri = URI(avatar_url)
- 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 getBuilder
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function getBuilder(filename, filedata, mime, boundary) {
var dashdash = '--',
crlf = '\r\n',
builder = '';
Function start
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
start: function(options) {
if (History.started) throw new Error("Backbone.history has already been started");
History.started = true;
// Figure out the initial configuration. Do we need an iframe?
Function save
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
save: function(key, val, options) {
var attrs, method, xhr, attributes = this.attributes;
// Handle both `"key", value` and `{key: value}` -style arguments.
if (key == null || typeof key === 'object') {
Function rect
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
Controller.prototype.rect = function() {
var $inputor, Sel, at_rect, bottom, format, html, offset, start_range, x, y;
$inputor = this.$inputor;
if (document.selection) {
Sel = document.selection.createRange();
Function injectElementWithStyles
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
injectElementWithStyles = function( rule, callback, nodes, testnames ) {
var style, ret, node, docOverflow,
div = document.createElement('div'),
body = document.body,
Function onload
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
xhr.onload = function() {
var serverResponse = null;
if (xhr.responseText) {
try {
Function on_keydown
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
Controller.prototype.on_keydown = function(e) {
if (!this.view.visible()) {
return;
}
switch (e.keyCode) {
Method check_external_avatar
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def check_external_avatar
# avatar url is not required
return if self.avatar_url.blank?
uri = URI(avatar_url)
Function catch_query
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
Controller.prototype.catch_query = function() {
var caret_pos, content, end, query, start, subtext,
_this = this;
content = this.$inputor.val();
caret_pos = this.$inputor.caretPos();
Function isEventSupported
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
isEventSupported = (function() {
var TAGNAMES = {
'select': 'input', 'change': 'input',
'submit': 'form', 'reset': 'form',
Function bind
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
Function.prototype.bind = function bind(that) {
var target = this;
if (typeof target != "function") {
Avoid deeply nested control flow statements. Open
Open
while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
field_list.push(field_match[1]);
}
else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) {
Avoid deeply nested control flow statements. Open
Open
if (!arg.hasOwnProperty(match[2][k])) {
throw new Error(sprintf('[_.sprintf] property "%s" does not exist', match[2][k]));
}
Avoid deeply nested control flow statements. Open
Open
if ((callback && callback !== ev.callback && callback !== ev.callback._callback) ||
(context && context !== ev.context)) {
retain.push(ev);
}
Consider simplifying this complex logical expression. Open
Open
if (options.data == null && model && (method === 'create' || method === 'update' || method === 'patch')) {
params.contentType = 'application/json';
params.data = JSON.stringify(options.attrs || model.toJSON(options));
}
Avoid too many return
statements within this function. Open
Open
return -1;