jashkenas/backbone

View on GitHub

Showing 16 of 22 total issues

File backbone.js has 1288 lines of code (exceeds 250 allowed). Consider refactoring.
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:
Severity: Major
Found in backbone.js - About 3 days to fix

    Function lazyload has 91 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        $.fn.lazyload = function(options) {
            var elements = this;
            var settings = {
                threshold       : 0,
                failure_limit   : 0,
    Severity: Major
    Found in docs/js/jquery.lazyload.js - About 3 hrs to fix

      Function set has 88 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          set: function(models, options) {
            if (models == null) return;
      
            options = _.extend({}, setOptions, options);
            if (options.parse && !this._isModel(models)) {
      Severity: Major
      Found in backbone.js - About 3 hrs to fix

        Function set has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            set: function(key, val, options) {
              if (key == null) return this;
        
              // Handle both `"key", value` and `{key: value}` -style arguments.
              var attrs;
        Severity: Major
        Found in backbone.js - About 2 hrs to fix

          Function default has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          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
          Severity: Minor
          Found in modules/debug-info.js - About 1 hr to fix

          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

              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?
          Severity: Minor
          Found in backbone.js - About 1 hr to fix

            Function localSync has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            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.
            
            
            Severity: Minor
            Found in examples/backbone.localStorage.js - About 1 hr to fix

              Function sync has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                Backbone.sync = function(method, model, options) {
                  var type = methodMap[method];
              
                  // Default options, unless specified.
                  _.defaults(options || (options = {}), {
              Severity: Minor
              Found in backbone.js - About 1 hr to fix

                Function offApi has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  var offApi = function(events, name, callback, options) {
                    if (!events) return;
                
                    var context = options.context, listeners = options.listeners;
                    var i = 0, names;
                Severity: Minor
                Found in backbone.js - About 1 hr to fix

                  Function exports has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  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);
                  Severity: Minor
                  Found in karma.conf-sauce.js - About 1 hr to fix

                    Function save has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    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;
                    Severity: Minor
                    Found in backbone.js - About 1 hr to fix

                      Function navigate has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          navigate: function(fragment, options) {
                            if (!History.started) return false;
                            if (!options || options === true) options = {trigger: !!options};
                      
                            // Normalize the fragment.
                      Severity: Minor
                      Found in backbone.js - About 1 hr to fix

                        Function exports has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        module.exports = function(config) {
                          config.set({
                            basePath: '',
                            frameworks: ['qunit'],
                        
                        
                        Severity: Minor
                        Found in karma.conf.js - About 1 hr to fix

                          Consider simplifying this complex logical expression.
                          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));
                              }
                          Severity: Major
                          Found in backbone.js - About 40 mins to fix

                            Function eventsApi has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                              var eventsApi = function(iteratee, events, name, callback, opts) {
                            Severity: Minor
                            Found in backbone.js - About 35 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                    default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args); return;
                              Severity: Major
                              Found in backbone.js - About 30 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language