sferik/rails_admin

View on GitHub
src/rails_admin/filtering-multiselect.js

Summary

Maintainability
F
4 days
Test Coverage

File filtering-multiselect.js has 332 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import jQuery from "jquery";
import "jquery-ui/ui/widget.js";
import I18n from "./i18n";

(function ($) {
Severity: Minor
Found in src/rails_admin/filtering-multiselect.js - About 4 hrs to fix

    Function _build has 90 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        _build: function () {
          var i;
    
          this.wrapper = this.element.siblings(
            '.ra-multiselect[data-input-for="' + this.element.attr("id") + '"]'
    Severity: Major
    Found in src/rails_admin/filtering-multiselect.js - About 3 hrs to fix

      Function _bindEvents has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          _bindEvents: function () {
            var widget = this;
      
            /* Add all to selection */
            this.addAll.click(function (e) {
      Severity: Minor
      Found in src/rails_admin/filtering-multiselect.js - About 1 hr to fix

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

            _query: function (query, success) {
              var i,
                matches = [];
        
              if (query === "") {
        Severity: Minor
        Found in src/rails_admin/filtering-multiselect.js - About 1 hr to fix

          Function _move has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              _move: function (direction, options) {
                var widget = this;
                if (direction == "up") {
                  options.each(function (i, option) {
                    var prev = $(option).prev();
          Severity: Minor
          Found in src/rails_admin/filtering-multiselect.js - About 1 hr to fix

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

                    options.each(function (i, option) {
                      var prev = $(option).prev();
                      if (prev.length > 0) {
                        var el = widget.element.find(
                          'option[value="' + option.value + '"]'
            Severity: Major
            Found in src/rails_admin/filtering-multiselect.js and 1 other location - About 4 hrs to fix
            src/rails_admin/filtering-multiselect.js on lines 357..369

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

            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

                    options.reverse().each(function (i, option) {
                      var next = $(option).next();
                      if (next.length > 0) {
                        var el = widget.element.find(
                          'option[value="' + option.value + '"]'
            Severity: Major
            Found in src/rails_admin/filtering-multiselect.js and 1 other location - About 4 hrs to fix
            src/rails_admin/filtering-multiselect.js on lines 342..354

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

            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.addAll.click(function (e) {
                    widget._select($("option:not(:disabled)", widget.collection));
                    e.preventDefault();
                    widget.selection.trigger("change");
                  });
            Severity: Major
            Found in src/rails_admin/filtering-multiselect.js and 1 other location - About 1 hr to fix
            src/rails_admin/filtering-multiselect.js on lines 168..172

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

            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.removeAll.click(function (e) {
                      widget._deSelect($("option", widget.selection));
                      e.preventDefault();
                      widget.selection.trigger("change");
                    });
            Severity: Major
            Found in src/rails_admin/filtering-multiselect.js and 1 other location - About 1 hr to fix
            src/rails_admin/filtering-multiselect.js on lines 152..156

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

            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.add.click(function (e) {
                    widget._select($(":selected", widget.collection));
            
                    e.preventDefault();
                    widget.selection.trigger("change");
            Severity: Major
            Found in src/rails_admin/filtering-multiselect.js and 1 other location - About 1 hr to fix
            src/rails_admin/filtering-multiselect.js on lines 175..179

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

            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.remove.click(function (e) {
                      widget._deSelect($(":selected", widget.selection));
                      e.preventDefault();
                      widget.selection.trigger("change");
                    });
            Severity: Major
            Found in src/rails_admin/filtering-multiselect.js and 1 other location - About 1 hr to fix
            src/rails_admin/filtering-multiselect.js on lines 159..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 68.

            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

                    } else {
                      $(option)
                        .clone()
                        .appendTo(widget.collection)
                        .prop("selected", false)
            Severity: Major
            Found in src/rails_admin/filtering-multiselect.js and 1 other location - About 1 hr to fix
            src/rails_admin/filtering-multiselect.js on lines 252..258

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

            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 (option.selected) {
                      $(option)
                        .clone()
                        .appendTo(widget.selection)
                        .prop("selected", false)
            Severity: Major
            Found in src/rails_admin/filtering-multiselect.js and 1 other location - About 1 hr to fix
            src/rails_admin/filtering-multiselect.js on lines 258..264

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

            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.up.click(function (e) {
                      widget._move("up", $(":selected", widget.selection));
                      e.preventDefault();
                    });
            Severity: Minor
            Found in src/rails_admin/filtering-multiselect.js and 1 other location - About 50 mins to fix
            src/rails_admin/filtering-multiselect.js on lines 191..194

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

            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.down.click(function (e) {
                      widget._move("down", $(":selected", widget.selection));
                      e.preventDefault();
                    });
            Severity: Minor
            Found in src/rails_admin/filtering-multiselect.js and 1 other location - About 50 mins to fix
            src/rails_admin/filtering-multiselect.js on lines 185..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 51.

            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

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

                        if (
                          this._cache.hasOwnProperty(i) &&
                          query.test(this._cache[i]["value"])
                        ) {
                          var option = this._cache[i];
            Severity: Minor
            Found in src/rails_admin/filtering-multiselect.js and 1 other location - About 40 mins to fix
            src/rails_admin/filtering-multiselect.js on lines 285..288

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

            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

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

                        if (this._cache.hasOwnProperty(i)) {
                          var option = this._cache[i];
                          matches.push({ id: option.id, label: option.value });
                        }
            Severity: Minor
            Found in src/rails_admin/filtering-multiselect.js and 1 other location - About 40 mins to fix
            src/rails_admin/filtering-multiselect.js on lines 308..314

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

            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