Showing 16 of 22 total issues
File backbone.js
has 1288 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
// Backbone.js 1.6.0
// (c) 2010-2024 Jeremy Ashkenas and DocumentCloud
// Backbone may be freely distributed under the MIT license.
// For all details and documentation:
Function lazyload
has 91 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
$.fn.lazyload = function(options) {
var elements = this;
var settings = {
threshold : 0,
failure_limit : 0,
Function set
has 88 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
set: function(models, options) {
if (models == null) return;
options = _.extend({}, setOptions, options);
if (options.parse && !this._isModel(models)) {
Function set
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
set: function(key, val, options) {
if (key == null) return this;
// Handle both `"key", value` and `{key: value}` -style arguments.
var attrs;
Function default
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Open
export default function() {
// Introspect Backbone.
var $ = Backbone.$, _b = Backbone._debug(), _ = _b._, root = _b.root;
// Use the `partialRight` function as a Lodash indicator. It was never in
// Underscore, has been in Lodash at least since version 1.3.1, and is
- 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 start
has 44 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 localSync
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
Backbone.LocalStorage.sync = window.Store.sync = Backbone.localSync = function(method, model, options) {
var store = model.localStorage || model.collection.localStorage;
var resp, errorMessage, syncDfd = $.Deferred && $.Deferred(); //If $ is having Deferred - use it.
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 = {}), {
Function offApi
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var offApi = function(events, name, callback, options) {
if (!events) return;
var context = options.context, listeners = options.listeners;
var i = 0, names;
Function exports
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports = function(config) {
if ( !process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY ) {
// eslint-disable-next-line no-console
console.log('Sauce environments not set --- Skipping');
return process.exit(0);
Function save
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
save: function(key, val, options) {
// Handle both `"key", value` and `{key: value}` -style arguments.
var attrs;
if (key == null || typeof key === 'object') {
attrs = key;
Function navigate
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
navigate: function(fragment, options) {
if (!History.started) return false;
if (!options || options === true) options = {trigger: !!options};
// Normalize the fragment.
Function exports
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['qunit'],
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));
}
Function eventsApi
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
var eventsApi = function(iteratee, events, name, callback, opts) {
Avoid too many return
statements within this function. Open
Open
default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args); return;