File jasmine.js
has 1624 lines of code (exceeds 250 allowed). Consider refactoring.
var isCommonJS = typeof window == "undefined" && typeof exports == "object";
* Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.
*
Function matcherFn_
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
return function() {
var matcherArgs = jasmine.util.argsToArray(arguments);
var result = matcherFunction.apply(this, arguments);
Function next_
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
jasmine.Queue.prototype.next_ = function() {
var self = this;
var goAgain = true;
while (goAgain) {
Function compareObjects_
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) {
if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) {
return true;
}
Function format
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
jasmine.PrettyPrinter.prototype.format = function(value) {
this.ppNestLevel_++;
try {
if (value === jasmine.undefined) {
this.emitScalar('undefined');
Function equals_
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
mismatchKeys = mismatchKeys || [];
mismatchValues = mismatchValues || [];
for (var i = 0; i < this.equalityTesters_.length; i++) {
Function next_
has 43 lines of code (exceeds 25 allowed). Consider refactoring.
jasmine.Queue.prototype.next_ = function() {
var self = this;
var goAgain = true;
while (goAgain) {
Function equals_
has 42 lines of code (exceeds 25 allowed). Consider refactoring.
jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
mismatchKeys = mismatchKeys || [];
mismatchValues = mismatchValues || [];
for (var i = 0; i < this.equalityTesters_.length; i++) {
Function compareRegExps_
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
jasmine.Env.prototype.compareRegExps_ = function(a, b, mismatchKeys, mismatchValues) {
if (a.source != b.source)
mismatchValues.push("expected pattern /" + b.source + "/ is not equal to the pattern /" + a.source + "/");
if (a.ignoreCase != b.ignoreCase)
Function runFunctionsWithinRange
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMillis) {
var scheduledFunc;
var funcsToRun = [];
for (var timeoutKey in this.scheduledFunctions) {
scheduledFunc = this.scheduledFunctions[timeoutKey];
Function format
has 38 lines of code (exceeds 25 allowed). Consider refactoring.
jasmine.PrettyPrinter.prototype.format = function(value) {
this.ppNestLevel_++;
try {
if (value === jasmine.undefined) {
this.emitScalar('undefined');
Function matcherFn_
has 36 lines of code (exceeds 25 allowed). Consider refactoring.
jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
return function() {
var matcherArgs = jasmine.util.argsToArray(arguments);
var result = matcherFunction.apply(this, arguments);
Function toThrow
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
jasmine.Matchers.prototype.toThrow = function(expected) {
var result = false;
var exception;
if (typeof this.actual != 'function') {
throw new Error('Actual is not a function');
Function jasmineMatches
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
jasmine.Matchers.ObjectContaining.prototype.jasmineMatches = function(other, mismatchKeys, mismatchValues) {
mismatchKeys = mismatchKeys || [];
mismatchValues = mismatchValues || [];
var env = jasmine.getEnv();
Function runFunctionsWithinRange
has 31 lines of code (exceeds 25 allowed). Consider refactoring.
jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMillis) {
var scheduledFunc;
var funcsToRun = [];
for (var timeoutKey in this.scheduledFunctions) {
scheduledFunc = this.scheduledFunctions[timeoutKey];
Function compareObjects_
has 30 lines of code (exceeds 25 allowed). Consider refactoring.
jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) {
if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) {
return true;
}
Function execute
has 28 lines of code (exceeds 25 allowed). Consider refactoring.
jasmine.WaitsForBlock.prototype.execute = function(onComplete) {
if (jasmine.VERBOSE) {
this.env.reporter.log('>> Jasmine waiting for ' + (this.message || 'something to happen'));
}
var latchFunctionResult;
Consider simplifying this complex logical expression.
if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
return ["Expected function " + not + "to throw", expected ? expected.message || expected : "an exception", ", but it threw", exception.message || exception].join(' ');
} else {
return "Expected function to throw an exception.";
}
Function addBeforesAndAftersToQueue
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() {
var runner = this.env.currentRunner();
var i;
for (var suite = this.suite; suite; suite = suite.parentSuite) {
Function addResult
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
jasmine.NestedResults.prototype.addResult = function(result) {
if (result.type != 'log') {
if (result.items_) {
this.rollupCounts(result);
} else {
Function iterateObject
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
for (var property in obj) {
if (!obj.hasOwnProperty(property)) continue;
if (property == '__Jasmine_been_here_before__') continue;
fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) !== jasmine.undefined &&
Avoid deeply nested control flow statements.
if (i > 0) message += ",";
Function WaitsForBlock
has 5 arguments (exceeds 4 allowed). Consider refactoring.
jasmine.WaitsForBlock = function(env, timeout, latchFunction, message, spec) {
Function formatException
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
jasmine.util.formatException = function(e) {
var lineNumber;
if (e.line) {
lineNumber = e.line;
}
Function summarizeResult_
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
var summaryMessages = [];
var messagesLength = result.messages.length;
for (var messageIndex = 0; messageIndex < messagesLength; messageIndex++) {
var resultMessage = result.messages[messageIndex];
Avoid too many return
statements within this function.
return a.jasmineMatches(b);
Avoid too many return
statements within this function.
return (a == b);
Avoid too many return
statements within this function.
return this.compareObjects_(a, b, mismatchKeys, mismatchValues);
Avoid too many return
statements within this function.
return (a === b);
Avoid too many return
statements within this function.
return other instanceof this.expectedClass;
Avoid too many return
statements within this function.
return b.jasmineMatches(a);
Avoid too many return
statements within this function.
return a.matches(b);
Avoid too many return
statements within this function.
return a.getTime() == b.getTime();
Avoid too many return
statements within this function.
return b.matches(a);
Avoid too many return
statements within this function.
return (a == b);
Avoid too many return
statements within this function.
return this.compareRegExps_(a, b, mismatchKeys, mismatchValues);
Function toString
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
jasmine.MessageResult.prototype.toString = function() {
var text = "";
for (var i = 0; i < this.values.length; i++) {
if (i > 0) text += " ";
if (jasmine.isString_(this.values[i])) {
Function contains_
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
jasmine.Env.prototype.contains_ = function(haystack, needle) {
if (jasmine.isArray_(haystack)) {
for (var i = 0; i < haystack.length; i++) {
if (this.equals_(haystack[i], needle)) return true;
}
Similar blocks of code found in 2 locations. Consider refactoring.
jasmine.getGlobal().setInterval = function(funcToCall, millis) {
if (jasmine.Clock.installed.setInterval.apply) {
return jasmine.Clock.installed.setInterval.apply(this, arguments);
} else {
return jasmine.Clock.installed.setInterval(funcToCall, millis);
Similar blocks of code found in 2 locations. Consider refactoring.
jasmine.getGlobal().setTimeout = function(funcToCall, millis) {
if (jasmine.Clock.installed.setTimeout.apply) {
return jasmine.Clock.installed.setTimeout.apply(this, arguments);
} else {
return jasmine.Clock.installed.setTimeout(funcToCall, millis);
Similar blocks of code found in 2 locations. Consider refactoring.
jasmine.getGlobal().clearInterval = function(timeoutKey) {
if (jasmine.Clock.installed.clearTimeout.apply) {
return jasmine.Clock.installed.clearInterval.apply(this, arguments);
} else {
return jasmine.Clock.installed.clearInterval(timeoutKey);
Similar blocks of code found in 2 locations. Consider refactoring.
jasmine.getGlobal().clearTimeout = function(timeoutKey) {
if (jasmine.Clock.installed.clearTimeout.apply) {
return jasmine.Clock.installed.clearTimeout.apply(this, arguments);
} else {
return jasmine.Clock.installed.clearTimeout(timeoutKey);
Similar blocks of code found in 2 locations. Consider refactoring.
jasmine.Queue.prototype.add = function(block, ensure) {
if (ensure === jasmine.undefined) {
ensure = false;
}
Similar blocks of code found in 2 locations. Consider refactoring.
jasmine.Queue.prototype.addBefore = function(block, ensure) {
if (ensure === jasmine.undefined) {
ensure = false;
}
Similar blocks of code found in 2 locations. Consider refactoring.
jasmine.Env.prototype.afterEach = function(afterEachFunction) {
if (this.currentSuite) {
this.currentSuite.afterEach(afterEachFunction);
} else {
this.currentRunner_.afterEach(afterEachFunction);
examples/testing/jasmine/lib/jasmine-1.3.1/jasmine.js on lines 833..839 Similar blocks of code found in 2 locations. Consider refactoring.
jasmine.Env.prototype.beforeEach = function(beforeEachFunction) {
if (this.currentSuite) {
this.currentSuite.beforeEach(beforeEachFunction);
} else {
this.currentRunner_.beforeEach(beforeEachFunction);
examples/testing/jasmine/lib/jasmine-1.3.1/jasmine.js on lines 845..852 Similar blocks of code found in 2 locations. Consider refactoring.
for (i = 0; i < suite.after_.length; i++) {
this.queue.add(new jasmine.Block(this.env, suite.after_[i], this), true);
}
Similar blocks of code found in 2 locations. Consider refactoring.
for (i = 0; i < runner.after_.length; i++) {
this.queue.add(new jasmine.Block(this.env, runner.after_[i], this), true);
}
Similar blocks of code found in 2 locations. Consider refactoring.
for (i = 0; i < suite.before_.length; i++) {
this.queue.addBefore(new jasmine.Block(this.env, suite.before_[i], this));
}
Similar blocks of code found in 2 locations. Consider refactoring.
for (i = 0; i < runner.before_.length; i++) {
this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this));
}
Similar blocks of code found in 2 locations. Consider refactoring.
jasmine.Spec.prototype.runs = function (func) {
var block = new jasmine.Block(this.env, func, this);
this.addToQueue(block);
return this;
};
Similar blocks of code found in 2 locations. Consider refactoring.
jasmine.Spec.prototype.waits = function(timeout) {
var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this);
this.addToQueue(waitsFunc);
return this;
};
Similar blocks of code found in 2 locations. Consider refactoring.
mismatchValues.push("'" + property + "' was '" + (other[property] ? jasmine.util.htmlEscape(other[property].toString()) : other[property]) + "' in expected, but was '" + (this.sample[property] ? jasmine.util.htmlEscape(this.sample[property].toString()) : this.sample[property]) + "' in actual.");
examples/testing/jasmine/lib/jasmine-1.3.1/jasmine.js on lines 925..925 Similar blocks of code found in 2 locations. Consider refactoring.
mismatchValues.push("'" + property + "' was '" + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + "' in expected, but was '" + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + "' in actual.");
Similar blocks of code found in 2 locations. Consider refactoring.
this.message = function() {
return [
"Expected spy " + this.actual.identity + " to have been called.",
"Expected spy " + this.actual.identity + " not to have been called."
];
Similar blocks of code found in 2 locations. Consider refactoring.
this.message = function() {
return [
"Expected spy " + this.actual.identity + " to not have been called.",
"Expected spy " + this.actual.identity + " to have been called."
];
Similar blocks of code found in 2 locations. Consider refactoring.
jasmine.Runner.prototype.afterEach = function(afterEachFunction) {
afterEachFunction.typeName = 'afterEach';
this.after_.splice(0,0,afterEachFunction);
};
Similar blocks of code found in 2 locations. Consider refactoring.
jasmine.Runner.prototype.beforeEach = function(beforeEachFunction) {
beforeEachFunction.typeName = 'beforeEach';
this.before_.splice(0,0,beforeEachFunction);
};
Similar blocks of code found in 2 locations. Consider refactoring.
self.setInterval = function(funcToCall, millis) {
self.timeoutsMade++;
self.scheduleFunction(self.timeoutsMade, funcToCall, millis, true);
return self.timeoutsMade;
};
Similar blocks of code found in 2 locations. Consider refactoring.
self.setTimeout = function(funcToCall, millis) {
self.timeoutsMade++;
self.scheduleFunction(self.timeoutsMade, funcToCall, millis, false);
return self.timeoutsMade;
};
Similar blocks of code found in 2 locations. Consider refactoring.
jasmine.Suite.prototype.afterEach = function(afterEachFunction) {
afterEachFunction.typeName = 'afterEach';
this.after_.unshift(afterEachFunction);
};
Similar blocks of code found in 2 locations. Consider refactoring.
jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) {
beforeEachFunction.typeName = 'beforeEach';
this.before_.unshift(beforeEachFunction);
};
Similar blocks of code found in 2 locations. Consider refactoring.
jasmine.Matchers.prototype.toEqual = function(expected) {
return this.env.equals_(this.actual, expected);
};
Similar blocks of code found in 2 locations. Consider refactoring.
jasmine.Matchers.prototype.toContain = function(expected) {
return this.env.contains_(this.actual, expected);
};
Identical blocks of code found in 4 locations. Consider refactoring.
if (!jasmine.isSpy(this.actual)) {
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
}
Identical blocks of code found in 4 locations. Consider refactoring.
if (!jasmine.isSpy(this.actual)) {
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
}
Identical blocks of code found in 4 locations. Consider refactoring.
if (!jasmine.isSpy(this.actual)) {
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
}
Identical blocks of code found in 4 locations. Consider refactoring.
if (!jasmine.isSpy(this.actual)) {
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
}
Similar blocks of code found in 2 locations. Consider refactoring.
for (var property in b) {
if (!hasKey(a, property) && hasKey(b, property)) {
mismatchKeys.push("expected has key '" + property + "', but missing from actual.");
}
}
examples/testing/jasmine/lib/jasmine-1.3.1/jasmine.js on lines 917..921 Similar blocks of code found in 2 locations. Consider refactoring.
jasmine.Matchers.prototype.toNotEqual = function(expected) {
return !this.env.equals_(this.actual, expected);
};
Similar blocks of code found in 2 locations. Consider refactoring.
jasmine.Matchers.prototype.toNotContain = function(expected) {
return !this.env.contains_(this.actual, expected);
};
Similar blocks of code found in 2 locations. Consider refactoring.
for (property in a) {
if (!hasKey(b, property) && hasKey(a, property)) {
mismatchKeys.push("expected missing key '" + property + "', but present in actual.");
}
}
examples/testing/jasmine/lib/jasmine-1.3.1/jasmine.js on lines 912..916 Similar blocks of code found in 4 locations. Consider refactoring.
if (a.sticky != b.sticky)
mismatchValues.push("expected modifier y was" + (b.sticky ? " " : " not ") + "set and does not equal the origin modifier");
examples/testing/jasmine/lib/jasmine-1.3.1/jasmine.js on lines 885..886 examples/testing/jasmine/lib/jasmine-1.3.1/jasmine.js on lines 888..889 examples/testing/jasmine/lib/jasmine-1.3.1/jasmine.js on lines 891..892 Similar blocks of code found in 4 locations. Consider refactoring.
if (a.global != b.global)
mismatchValues.push("expected modifier g was" + (b.global ? " " : " not ") + "set and does not equal the origin modifier");
examples/testing/jasmine/lib/jasmine-1.3.1/jasmine.js on lines 885..886 examples/testing/jasmine/lib/jasmine-1.3.1/jasmine.js on lines 891..892 examples/testing/jasmine/lib/jasmine-1.3.1/jasmine.js on lines 894..895 Similar blocks of code found in 4 locations. Consider refactoring.
if (a.ignoreCase != b.ignoreCase)
mismatchValues.push("expected modifier i was" + (b.ignoreCase ? " " : " not ") + "set and does not equal the origin modifier");
examples/testing/jasmine/lib/jasmine-1.3.1/jasmine.js on lines 888..889 examples/testing/jasmine/lib/jasmine-1.3.1/jasmine.js on lines 891..892 examples/testing/jasmine/lib/jasmine-1.3.1/jasmine.js on lines 894..895 Similar blocks of code found in 4 locations. Consider refactoring.
if (a.multiline != b.multiline)
mismatchValues.push("expected modifier m was" + (b.multiline ? " " : " not ") + "set and does not equal the origin modifier");
examples/testing/jasmine/lib/jasmine-1.3.1/jasmine.js on lines 885..886 examples/testing/jasmine/lib/jasmine-1.3.1/jasmine.js on lines 888..889 examples/testing/jasmine/lib/jasmine-1.3.1/jasmine.js on lines 894..895 Similar blocks of code found in 2 locations. Consider refactoring.
if (e.line) {
lineNumber = e.line;
}
else if (e.lineNumber) {
lineNumber = e.lineNumber;
examples/testing/jasmine/lib/jasmine-1.3.1/jasmine.js on lines 678..683 Similar blocks of code found in 2 locations. Consider refactoring.
if (e.sourceURL) {
file = e.sourceURL;
}
else if (e.fileName) {
file = e.fileName;
examples/testing/jasmine/lib/jasmine-1.3.1/jasmine.js on lines 669..674 There are no issues that match your filters.