jashkenas/backbone

View on GitHub

Showing 22 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

    Similar blocks of code found in 2 locations. 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: Major
    Found in modules/debug-info.js and 1 other location - About 1 day to fix
    debug-info.js on lines 7..34

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 336.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      function debugInfo() {
        // 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: Major
    Found in debug-info.js and 1 other location - About 1 day to fix
    modules/debug-info.js on lines 4..31

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 336.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        $.belowthefold = function(element, settings) {
            var fold;
    
            if (settings.container === undefined || settings.container === window) {
                fold = $window.height() + $window.scrollTop();
    Severity: Major
    Found in docs/js/jquery.lazyload.js and 1 other location - About 5 hrs to fix
    docs/js/jquery.lazyload.js on lines 154..164

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 137.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        $.rightoffold = function(element, settings) {
            var fold;
    
            if (settings.container === undefined || settings.container === window) {
                fold = $window.width() + $window.scrollLeft();
    Severity: Major
    Found in docs/js/jquery.lazyload.js and 1 other location - About 5 hrs to fix
    docs/js/jquery.lazyload.js on lines 142..152

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 137.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        $.leftofbegin = function(element, settings) {
            var fold;
    
            if (settings.container === undefined || settings.container === window) {
                fold = $window.scrollLeft();
    Severity: Major
    Found in docs/js/jquery.lazyload.js and 1 other location - About 4 hrs to fix
    docs/js/jquery.lazyload.js on lines 166..176

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 131.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        $.abovethetop = function(element, settings) {
            var fold;
    
            if (settings.container === undefined || settings.container === window) {
                fold = $window.scrollTop();
    Severity: Major
    Found in docs/js/jquery.lazyload.js and 1 other location - About 4 hrs to fix
    docs/js/jquery.lazyload.js on lines 178..188

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 131.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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
                            Severity
                            Category
                            Status
                            Source
                            Language