ivaynberg/select2

View on GitHub
src/js/select2/core.js

Summary

Maintainability
D
2 days
Test Coverage

File core.js has 435 lines of code (exceeds 250 allowed). Consider refactoring.
Open

define([
  'jquery',
  './options',
  './utils',
  './keys'
Severity: Minor
Found in src/js/select2/core.js - About 6 hrs to fix

    Function _registerEvents has 63 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      Select2.prototype._registerEvents = function () {
        var self = this;
    
        this.on('open', function () {
          self.$container[0].classList.add('select2-container--open');
    Severity: Major
    Found in src/js/select2/core.js - About 2 hrs to fix

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

        var Select2 = function ($element, options) {
          if (Utils.GetData($element[0], 'select2') != null) {
            Utils.GetData($element[0], 'select2').destroy();
          }
      
      
      Severity: Minor
      Found in src/js/select2/core.js - About 1 hr to fix

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

          Select2.prototype._resolveWidth = function ($element, method) {
            var WIDTH = /^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;
        
            if (method == 'resolve') {
              var styleWidth = this._resolveWidth($element, 'style');
        Severity: Minor
        Found in src/js/select2/core.js - About 1 hr to fix

          Avoid too many return statements within this function.
          Open

                  return null;
          Severity: Major
          Found in src/js/select2/core.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                      return matches[1];
            Severity: Major
            Found in src/js/select2/core.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                    return null;
              Severity: Major
              Found in src/js/select2/core.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      return computedStyle.width;
                Severity: Major
                Found in src/js/select2/core.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return method;
                  Severity: Major
                  Found in src/js/select2/core.js - About 30 mins to fix

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

                      Select2.prototype._registerDropdownEvents = function () {
                        var self = this;
                    
                        this.dropdown.on('*', function (name, params) {
                          self.trigger(name, params);
                    Severity: Major
                    Found in src/js/select2/core.js and 2 other locations - About 1 hr to fix
                    src/js/select2/core.js on lines 211..217
                    src/js/select2/core.js on lines 248..254

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

                    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 3 locations. Consider refactoring.
                    Open

                      Select2.prototype._registerResultsEvents = function () {
                        var self = this;
                    
                        this.results.on('*', function (name, params) {
                          self.trigger(name, params);
                    Severity: Major
                    Found in src/js/select2/core.js and 2 other locations - About 1 hr to fix
                    src/js/select2/core.js on lines 211..217
                    src/js/select2/core.js on lines 240..246

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

                    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 3 locations. Consider refactoring.
                    Open

                      Select2.prototype._registerDataEvents = function () {
                        var self = this;
                    
                        this.dataAdapter.on('*', function (name, params) {
                          self.trigger(name, params);
                    Severity: Major
                    Found in src/js/select2/core.js and 2 other locations - About 1 hr to fix
                    src/js/select2/core.js on lines 240..246
                    src/js/select2/core.js on lines 248..254

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

                    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

                        if (this.options.get('debug') && window.console && console.warn) {
                          console.warn(
                            'Select2: The `select2("val")` method has been deprecated and will be' +
                            ' removed in later Select2 versions. Use $element.val() instead.'
                          );
                    Severity: Minor
                    Found in src/js/select2/core.js and 1 other location - About 45 mins to fix
                    src/js/select2/selection/allowClear.js on lines 14..19

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

                    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

                          this.dataAdapter.query(params, function (data) {
                            self.trigger('results:append', {
                              data: data,
                              query: params
                            });
                    Severity: Minor
                    Found in src/js/select2/core.js and 1 other location - About 30 mins to fix
                    src/js/select2/core.js on lines 284..289

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

                    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

                          this.dataAdapter.query(params, function (data) {
                            self.trigger('results:all', {
                              data: data,
                              query: params
                            });
                    Severity: Minor
                    Found in src/js/select2/core.js and 1 other location - About 30 mins to fix
                    src/js/select2/core.js on lines 293..298

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

                    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