Factlink/factlink-core

View on GitHub
public/javascripts/testing/sinon-1.2.0.js

Summary

Maintainability
F
2 wks
Test Coverage

File sinon-1.2.0.js has 2078 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Sinon.JS 1.2.0, 2011/09/27
 *
 * @author Christian Johansen (christian@cjohansen.no)
 *
Severity: Major
Found in public/javascripts/testing/sinon-1.2.0.js - About 5 days to fix

Function sinon has a Cognitive Complexity of 105 (exceeds 5 allowed). Consider refactoring.
Open

var sinon = (function () {
    var div = typeof document != "undefined" && document.createElement("div");

    function isNode(obj) {
        var success = false;
Severity: Minor
Found in public/javascripts/testing/sinon-1.2.0.js - About 2 days 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 FakeXMLHttpRequest has a Cognitive Complexity of 75 (exceeds 5 allowed). Consider refactoring.
Open

sinon.FakeXMLHttpRequest = (function () {
    /*jsl:ignore*/
    var unsafeHeaders = {
        "Accept-Charset": true,
        "Accept-Encoding": true,
Severity: Minor
Found in public/javascripts/testing/sinon-1.2.0.js - About 1 day 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 fakeServer has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
Open

sinon.fakeServer = (function () {
    var push = [].push;
    function F() {}

    function create(proto) {
Severity: Minor
Found in public/javascripts/testing/sinon-1.2.0.js - About 1 day 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 clock has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
Open

sinon.clock = (function () {
    var id = 0;

    function addTimer(args, recurring) {
        if (args.length === 0) {
Severity: Minor
Found in public/javascripts/testing/sinon-1.2.0.js - About 1 day 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 FakeXMLHttpRequest has 238 lines of code (exceeds 25 allowed). Consider refactoring.
Open

sinon.FakeXMLHttpRequest = (function () {
    /*jsl:ignore*/
    var unsafeHeaders = {
        "Accept-Charset": true,
        "Accept-Encoding": true,
Severity: Major
Found in public/javascripts/testing/sinon-1.2.0.js - About 1 day to fix

Function expectation has 189 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    sinon.expectation = (function () {
        var slice = Array.prototype.slice;
        var _invoke = sinon.spy.invoke;

        function callCountInWords(callCount) {
Severity: Major
Found in public/javascripts/testing/sinon-1.2.0.js - About 7 hrs to fix

Function clock has 171 lines of code (exceeds 25 allowed). Consider refactoring.
Open

sinon.clock = (function () {
    var id = 0;

    function addTimer(args, recurring) {
        if (args.length === 0) {
Severity: Major
Found in public/javascripts/testing/sinon-1.2.0.js - About 6 hrs to fix

Function sinon has 170 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var sinon = (function () {
    var div = typeof document != "undefined" && document.createElement("div");

    function isNode(obj) {
        var success = false;
Severity: Major
Found in public/javascripts/testing/sinon-1.2.0.js - About 6 hrs to fix

Function fakeServer has 131 lines of code (exceeds 25 allowed). Consider refactoring.
Open

sinon.fakeServer = (function () {
    var push = [].push;
    function F() {}

    function create(proto) {
Severity: Major
Found in public/javascripts/testing/sinon-1.2.0.js - About 5 hrs to fix

Function useFakeTimers has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

sinon.useFakeTimers = (function (global) {
    var methods = ["Date", "setTimeout", "setInterval", "clearTimeout", "clearInterval"];

    function restore() {
        var method;
Severity: Minor
Found in public/javascripts/testing/sinon-1.2.0.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 Date has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        Date: (function () {
            var NativeDate = Date;

            function ClockDate(year, month, date, hour, minute, second, ms) {
                // Defensive and verbose to avoid potential harm in passing
Severity: Minor
Found in public/javascripts/testing/sinon-1.2.0.js - About 1 hr to fix

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

        deepEqual: function deepEqual(a, b) {
            if (typeof a != "object" || typeof b != "object") {
                return a === b;
            }

Severity: Minor
Found in public/javascripts/testing/sinon-1.2.0.js - About 1 hr to fix

Function useFakeTimers has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

sinon.useFakeTimers = (function (global) {
    var methods = ["Date", "setTimeout", "setInterval", "clearTimeout", "clearInterval"];

    function restore() {
        var method;
Severity: Minor
Found in public/javascripts/testing/sinon-1.2.0.js - About 1 hr to fix

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

        wrapMethod: function wrapMethod(object, property, method) {
            if (!object) {
                throw new TypeError("Should wrap property of object");
            }

Severity: Minor
Found in public/javascripts/testing/sinon-1.2.0.js - About 1 hr to fix

Function verifyCallAllowed has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

            verifyCallAllowed: function verifyCallAllowed(thisValue, args) {
                if (receivedMaxCalls(this)) {
                    this.failed = true;
                    sinon.expectation.fail(this.method + " already called " + times(this.maxCalls));
                }
Severity: Minor
Found in public/javascripts/testing/sinon-1.2.0.js - About 1 hr to fix

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

        setResponseBody: function setResponseBody(body) {
            if (this.readyState == FakeXMLHttpRequest.DONE) {
                throw new Error("Request done");
            }

Severity: Minor
Found in public/javascripts/testing/sinon-1.2.0.js - About 1 hr to fix

Function testCase has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function testCase(tests, prefix) {
        /*jsl:ignore*/
        if (!tests || typeof tests != "object") {
            throw new TypeError("sinon.testCase needs an object with test functions");
        }
Severity: Minor
Found in public/javascripts/testing/sinon-1.2.0.js - About 1 hr to fix

Function ClockDate has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

            function ClockDate(year, month, date, hour, minute, second, ms) {
Severity: Major
Found in public/javascripts/testing/sinon-1.2.0.js - About 50 mins to fix

Function create has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

            create: function create(spy, thisValue, args, returnValue, exception, id) {
Severity: Minor
Found in public/javascripts/testing/sinon-1.2.0.js - About 45 mins to fix

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

        open: function open(method, url, async, username, password) {
Severity: Minor
Found in public/javascripts/testing/sinon-1.2.0.js - About 35 mins to fix

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

        function delegateToCalls(api, method, matchAny, actual, notCalled) {
Severity: Minor
Found in public/javascripts/testing/sinon-1.2.0.js - About 35 mins to fix

Avoid too many return statements within this function.
Open

                return true;
Severity: Major
Found in public/javascripts/testing/sinon-1.2.0.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

                        return false;
Severity: Major
Found in public/javascripts/testing/sinon-1.2.0.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return true;
Severity: Major
Found in public/javascripts/testing/sinon-1.2.0.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

                return true;
Severity: Major
Found in public/javascripts/testing/sinon-1.2.0.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

                    return false;
Severity: Major
Found in public/javascripts/testing/sinon-1.2.0.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

                return false;
Severity: Major
Found in public/javascripts/testing/sinon-1.2.0.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

                    return false;
Severity: Major
Found in public/javascripts/testing/sinon-1.2.0.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

                        return false;
Severity: Major
Found in public/javascripts/testing/sinon-1.2.0.js - About 30 mins to fix

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

            atMost: function atMost(num) {
                if (typeof num != "number") {
                    throw new TypeError("'" + num + "' is not number");
                }

Severity: Major
Found in public/javascripts/testing/sinon-1.2.0.js and 1 other location - About 2 hrs to fix
public/javascripts/testing/sinon-1.2.0.js on lines 1109..1122

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

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

            atLeast: function atLeast(num) {
                if (typeof num != "number") {
                    throw new TypeError("'" + num + "' is not number");
                }

Severity: Major
Found in public/javascripts/testing/sinon-1.2.0.js and 1 other location - About 2 hrs to fix
public/javascripts/testing/sinon-1.2.0.js on lines 1124..1137

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

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

            calledWith: function calledWith() {
                for (var i = 0, l = arguments.length; i < l; i += 1) {
                    if (!sinon.deepEqual(arguments[i], this.args[i])) {
                        return false;
                    }
Severity: Major
Found in public/javascripts/testing/sinon-1.2.0.js and 1 other location - About 2 hrs to fix
public/javascripts/testing/sinon-1.2.0.js on lines 609..616

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

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

            notCalledWith: function notCalledWith() {
                for (var i = 0, l = arguments.length; i < l; i += 1) {
                    if (!sinon.deepEqual(arguments[i], this.args[i])) {
                        return true;
                    }
Severity: Major
Found in public/javascripts/testing/sinon-1.2.0.js and 1 other location - About 2 hrs to fix
public/javascripts/testing/sinon-1.2.0.js on lines 594..602

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

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.clock.setTimeout = function (fn, timeout) {
                    server.longestTimeout = Math.max(timeout, server.longestTimeout || 0);

                    return clockSetTimeout.apply(this, arguments);
                };
Severity: Major
Found in public/javascripts/testing/sinon-1.2.0.js and 1 other location - About 1 hr to fix
public/javascripts/testing/sinon-1.2.0.js on lines 2418..2422

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

                this.clock.setInterval = function (fn, timeout) {
                    server.longestTimeout = Math.max(timeout, server.longestTimeout || 0);

                    return clockSetInterval.apply(this, arguments);
                };
Severity: Major
Found in public/javascripts/testing/sinon-1.2.0.js and 1 other location - About 1 hr to fix
public/javascripts/testing/sinon-1.2.0.js on lines 2412..2416

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

                if (this.expectsExactArgCount &&
                    args.length != this.expectedArguments.length) {
                    sinon.expectation.fail(this.method + " received too many arguments (" + args.join() +
                        "), expected " + this.expectedArguments.join());
                }
Severity: Major
Found in public/javascripts/testing/sinon-1.2.0.js and 2 other locations - About 1 hr to fix
public/javascripts/testing/sinon-1.2.0.js on lines 1188..1191
public/javascripts/testing/sinon-1.2.0.js on lines 1200..1203

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

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

                    if (!sinon.deepEqual(this.expectedArguments[i], args[i])) {
                        sinon.expectation.fail(this.method + " received wrong arguments (" + args.join() +
                            "), expected " + this.expectedArguments.join());
                    }
Severity: Major
Found in public/javascripts/testing/sinon-1.2.0.js and 2 other locations - About 1 hr to fix
public/javascripts/testing/sinon-1.2.0.js on lines 1188..1191
public/javascripts/testing/sinon-1.2.0.js on lines 1193..1197

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

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

                if (args.length < this.expectedArguments.length) {
                    sinon.expectation.fail(this.method + " received too few arguments (" + args.join() +
                        "), expected " + this.expectedArguments.join());
                }
Severity: Major
Found in public/javascripts/testing/sinon-1.2.0.js and 2 other locations - About 1 hr to fix
public/javascripts/testing/sinon-1.2.0.js on lines 1193..1197
public/javascripts/testing/sinon-1.2.0.js on lines 1200..1203

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

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