kandanapp/kandan

View on GitHub
app/assets/javascripts/lib/underscore.string.js

Summary

Maintainability
F
3 days
Test Coverage

File underscore.string.js has 464 lines of code (exceeds 250 allowed). Consider refactoring.
Open

//  Underscore.string
//  (c) 2010 Esa-Matti Suuronen <esa-matti aet suuronen dot org>
//  Underscore.string is freely distributable under the terms of the MIT license.
//  Documentation: https://github.com/epeli/underscore.string
//  Some code is borrowed from MooTools and Alexandru Marasteanu.
Severity: Minor
Found in app/assets/javascripts/lib/underscore.string.js - About 7 hrs to fix

    Function sprintf has 106 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      var sprintf = (function() {
        function get_type(variable) {
          return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase();
        }
    
    
    Severity: Major
    Found in app/assets/javascripts/lib/underscore.string.js - About 4 hrs to fix

      Function format has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          str_format.format = function(parse_tree, argv) {
            var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length;
            for (i = 0; i < tree_length; i++) {
              node_type = get_type(parse_tree[i]);
              if (node_type === 'string') {
      Severity: Minor
      Found in app/assets/javascripts/lib/underscore.string.js - About 1 hr to fix

        Function parse has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            str_format.parse = function(fmt) {
              var _fmt = fmt, match = [], parse_tree = [], arg_names = 0;
              while (_fmt) {
                if ((match = /^[^\x25]+/.exec(_fmt)) !== null) {
                  parse_tree.push(match[0]);
        Severity: Minor
        Found in app/assets/javascripts/lib/underscore.string.js - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                        if (!arg.hasOwnProperty(match[2][k])) {
                          throw new Error(sprintf('[_.sprintf] property "%s" does not exist', match[2][k]));
                        }
          Severity: Major
          Found in app/assets/javascripts/lib/underscore.string.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            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) {
            Severity: Major
            Found in app/assets/javascripts/lib/underscore.string.js - About 45 mins to fix

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

                  strRightBack: function(str, sep){
                    if (str == null) return '';
                    str = String(str); sep = sep != null ? String(sep) : sep;
                    var pos = !sep ? -1 : str.lastIndexOf(sep);
                    return ~pos ? str.slice(pos+sep.length, str.length) : str;
              Severity: Major
              Found in app/assets/javascripts/lib/underscore.string.js and 1 other location - About 3 hrs to fix
              app/assets/javascripts/lib/underscore.string.js on lines 450..455

              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 112.

              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

                  strRight: function(str, sep){
                    if (str == null) return '';
                    str = String(str); sep = sep != null ? String(sep) : sep;
                    var pos = !sep ? -1 : str.indexOf(sep);
                    return ~pos ? str.slice(pos+sep.length, str.length) : str;
              Severity: Major
              Found in app/assets/javascripts/lib/underscore.string.js and 1 other location - About 3 hrs to fix
              app/assets/javascripts/lib/underscore.string.js on lines 457..462

              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 112.

              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

                  underscored: function(str){
                    return _s.trim(str).replace(/([a-z\d])([A-Z]+)/g, '$1_$2').replace(/[-\s]+/g, '_').toLowerCase();
                  },
              Severity: Minor
              Found in app/assets/javascripts/lib/underscore.string.js and 1 other location - About 35 mins to fix
              app/assets/javascripts/lib/underscore.string.js on lines 318..320

              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 47.

              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

                  dasherize: function(str){
                    return _s.trim(str).replace(/([A-Z])/g, '-$1').replace(/[-_\s]+/g, '-').toLowerCase();
                  },
              Severity: Minor
              Found in app/assets/javascripts/lib/underscore.string.js and 1 other location - About 35 mins to fix
              app/assets/javascripts/lib/underscore.string.js on lines 314..316

              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 47.

              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

              There are no issues that match your filters.

              Category
              Status