AppStateESS/homestead

View on GitHub
javascript/jquery.selectboxes.js

Summary

Maintainability
D
2 days
Test Coverage

File jquery.selectboxes.js has 342 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 *
 * Copyright (c) 2006-2009 Sam Collett (http://www.texotela.co.uk)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
Severity: Minor
Found in javascript/jquery.selectboxes.js - About 4 hrs to fix

Function removeOption has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

$.fn.removeOption = function()
{
    var a = arguments;
    if(a.length == 0) return this;
    var ta = typeof(a[0]);
Severity: Major
Found in javascript/jquery.selectboxes.js - About 2 hrs to fix

Function addOption has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

$.fn.addOption = function()
{
    var add = function(el, v, t, sO)
    {
        var option = document.createElement("option");
Severity: Major
Found in javascript/jquery.selectboxes.js - About 2 hrs to fix

Function selectOptions has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

$.fn.selectOptions = function(value, clear)
{
    var v = value;
    var vT = typeof(value);
    // handle arrays
Severity: Minor
Found in javascript/jquery.selectboxes.js - About 1 hr to fix

Function sortOptions has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

$.fn.sortOptions = function(ascending)
{
    // get selected values first
    var sel = $(this).selectedValues();
    var a = typeof(ascending) == "undefined" ? true : !!ascending;
Severity: Minor
Found in javascript/jquery.selectboxes.js - About 1 hr to fix

Function containsOption has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

$.fn.containsOption = function(value, fn)
{
    var found = false;
    var v = value;
    var vT = typeof(v);
Severity: Minor
Found in javascript/jquery.selectboxes.js - About 1 hr to fix

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

$.fn.ajaxAddOption = function(url, params, select, fn, args)
{
    if(typeof(url) != "string") return this;
    if(typeof(params) != "object") params = {};
    if(typeof(select) != "boolean") select = true;
Severity: Minor
Found in javascript/jquery.selectboxes.js - About 1 hr to fix

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

$.fn.ajaxAddOption = function(url, params, select, fn, args)
Severity: Minor
Found in javascript/jquery.selectboxes.js - About 35 mins to fix

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

$.fn.selectedTexts = function()
{
    var t = [];
    this.selectedOptions().each(
        function()
Severity: Major
Found in javascript/jquery.selectboxes.js and 1 other location - About 2 hrs to fix
javascript/jquery.selectboxes.js on lines 479..489

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

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

$.fn.selectedValues = function()
{
    var v = [];
    this.selectedOptions().each(
        function()
Severity: Major
Found in javascript/jquery.selectboxes.js and 1 other location - About 2 hrs to fix
javascript/jquery.selectboxes.js on lines 500..510

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

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