Move node dev deps forward, add .jshintrc to support latest grunt-contrib-jshint and Code Climate score

This commit is contained in:
Davis W. Frank
2013-10-25 12:23:57 -07:00
parent 797984f173
commit 9e149d1e0f
10 changed files with 69 additions and 59 deletions

9
.jshintrc Normal file
View File

@@ -0,0 +1,9 @@
{
"bitwise": true,
"curly": true,
"freeze": true,
"immed": true,
"newcap": true,
"trailing": true,
"loopfunc": true
}

View File

@@ -5,13 +5,7 @@ module.exports = {
'lib/jasmine-core/jasmine.js'
],
options: {
/* While it's possible that we could be considering unwanted prototype methods, mostly
* we're doing this because the objects are being used as maps.
*/
forin: false,
/* We're fine with functions defined inside loops (setTimeout functions, etc) */
loopfunc: true
jshintrc: '.jshintrc'
},
all: ['src/**/*.js']
};

View File

@@ -4,10 +4,10 @@
"version": "2.0.0-rc3",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-jshint": "~0.2.0",
"grunt-contrib-concat": "~0.1.3",
"grunt-contrib-compass": "~0.1.3",
"grunt-contrib-compress": "~0.4.1",
"shelljs": "~0.1.2"
"grunt-contrib-jshint": "~0.7.0",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-compass": "~0.6.0",
"grunt-contrib-compress": "~0.5.2",
"shelljs": "~0.1.4"
}
}

View File

@@ -47,8 +47,8 @@ getJasmineRequireObj().pp = function(j$) {
PrettyPrinter.prototype.iterateObject = function(obj, fn) {
for (var property in obj) {
if (!obj.hasOwnProperty(property)) continue;
if (property == '__Jasmine_been_here_before__') continue;
if (!obj.hasOwnProperty(property)) { continue; }
if (property == '__Jasmine_been_here_before__') { continue; }
fn(property, obj.__lookupGetter__ ? (!j$.util.isUndefined(obj.__lookupGetter__(property)) &&
obj.__lookupGetter__(property) !== null) : false);
}

View File

@@ -5,11 +5,11 @@ getJasmineRequireObj().ReportDispatcher = function() {
for (var i = 0; i < dispatchedMethods.length; i++) {
var method = dispatchedMethods[i];
this[method] = function(m) {
this[method] = (function(m) {
return function() {
dispatch(m, arguments);
};
}(method);
}(method));
}
var reporters = [];

View File

@@ -67,8 +67,8 @@ getJasmineRequireObj().Spec = function(j$) {
}
var befores = this.beforeFns() || [],
afters = this.afterFns() || [],
thisOne = (this.fn.length) ? timeoutable(this.fn) : this.fn;
afters = this.afterFns() || [],
thisOne = (this.fn.length) ? timeoutable(this.fn) : this.fn;
var allFns = befores.concat(thisOne).concat(afters);
this.queueRunner({
@@ -78,18 +78,18 @@ getJasmineRequireObj().Spec = function(j$) {
});
function onException(e) {
if (Spec.isPendingSpecException(e)) {
self.pend();
return;
}
if (Spec.isPendingSpecException(e)) {
self.pend();
return;
}
self.addExpectationResult(false, {
matcherName: "",
passed: false,
expected: "",
actual: "",
error: e
});
self.addExpectationResult(false, {
matcherName: "",
passed: false,
expected: "",
actual: "",
error: e
});
}
function complete() {

View File

@@ -51,18 +51,18 @@ getJasmineRequireObj().base = function(j$) {
j$.createSpy = function(name, originalFn) {
var spyStrategy = new j$.SpyStrategy({
name: name,
fn: originalFn,
getSpy: function() { return spy; }
}),
callTracker = new j$.CallTracker(),
spy = function() {
callTracker.track({
object: this,
args: Array.prototype.slice.apply(arguments)
});
return spyStrategy.exec.apply(this, arguments);
};
name: name,
fn: originalFn,
getSpy: function() { return spy; }
}),
callTracker = new j$.CallTracker(),
spy = function() {
callTracker.track({
object: this,
args: Array.prototype.slice.apply(arguments)
});
return spyStrategy.exec.apply(this, arguments);
};
for (var prop in originalFn) {
if (prop === 'and' || prop === 'calls') {
@@ -83,7 +83,7 @@ getJasmineRequireObj().base = function(j$) {
return false;
}
return putativeSpy.and instanceof j$.SpyStrategy &&
putativeSpy.calls instanceof j$.CallTracker;
putativeSpy.calls instanceof j$.CallTracker;
};
j$.createSpyObj = function(baseName, methodNames) {

View File

@@ -37,7 +37,9 @@ getJasmineRequireObj().matchersUtil = function(j$) {
if (expected.length > 0) {
for (var i = 0; i < expected.length; i++) {
if (i > 0) message += ",";
if (i > 0) {
message += ",";
}
message += " " + j$.pp(expected[i]);
}
}
@@ -85,11 +87,11 @@ getJasmineRequireObj().matchersUtil = function(j$) {
// Identical objects are equal. `0 === -0`, but they aren't identical.
// See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
if (a === b) return a !== 0 || 1 / a == 1 / b;
if (a === b) { return a !== 0 || 1 / a == 1 / b; }
// A strict comparison is necessary because `null == undefined`.
if (a === null || b === null) return a === b;
if (a === null || b === null) { return a === b; }
var className = Object.prototype.toString.call(a);
if (className != Object.prototype.toString.call(b)) return false;
if (className != Object.prototype.toString.call(b)) { return false; }
switch (className) {
// Strings, numbers, dates, and booleans are compared by value.
case '[object String]':
@@ -113,14 +115,14 @@ getJasmineRequireObj().matchersUtil = function(j$) {
a.multiline == b.multiline &&
a.ignoreCase == b.ignoreCase;
}
if (typeof a != 'object' || typeof b != 'object') return false;
if (typeof a != 'object' || typeof b != 'object') { return false; }
// Assume equality for cyclic structures. The algorithm for detecting cyclic
// structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
var length = aStack.length;
while (length--) {
// Linear search. Performance is inversely proportional to the number of
// unique nested structures.
if (aStack[length] == a) return bStack[length] == b;
if (aStack[length] == a) { return bStack[length] == b; }
}
// Add the first object to the stack of traversed objects.
aStack.push(a);
@@ -134,7 +136,7 @@ getJasmineRequireObj().matchersUtil = function(j$) {
if (result) {
// Deep compare the contents, ignoring non-numeric properties.
while (size--) {
if (!(result = eq(a[size], b[size], aStack, bStack, customTesters))) break;
if (!(result = eq(a[size], b[size], aStack, bStack, customTesters))) { break; }
}
}
} else {
@@ -151,13 +153,13 @@ getJasmineRequireObj().matchersUtil = function(j$) {
// Count the expected number of properties.
size++;
// Deep compare each member.
if (!(result = has(b, key) && eq(a[key], b[key], aStack, bStack, customTesters))) break;
if (!(result = has(b, key) && eq(a[key], b[key], aStack, bStack, customTesters))) { break; }
}
}
// Ensure that both objects contain the same number of properties.
if (result) {
for (key in b) {
if (has(b, key) && !(size--)) break;
if (has(b, key) && !(size--)) { break; }
}
result = !size;
}

View File

@@ -3,14 +3,16 @@ getJasmineRequireObj().util = function() {
var util = {};
util.inherit = function(childClass, parentClass) {
var subclass = function() {
var Subclass = function() {
};
subclass.prototype = parentClass.prototype;
childClass.prototype = new subclass();
Subclass.prototype = parentClass.prototype;
childClass.prototype = new Subclass();
};
util.htmlEscape = function(str) {
if (!str) return str;
if (!str) {
return str;
}
return str.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;');
@@ -18,7 +20,9 @@ getJasmineRequireObj().util = function() {
util.argsToArray = function(args) {
var arrayOfArgs = [];
for (var i = 0; i < args.length; i++) arrayOfArgs.push(args[i]);
for (var i = 0; i < args.length; i++) {
arrayOfArgs.push(args[i]);
}
return arrayOfArgs;
};

View File

@@ -1,8 +1,8 @@
jasmineRequire.HtmlReporter = function(j$) {
var noopTimer = {
start: function(){},
elapsed: function(){ return 0; }
start: function() {},
elapsed: function() { return 0; }
};
function HtmlReporter(options) {
@@ -73,7 +73,8 @@ jasmineRequire.HtmlReporter = function(j$) {
symbols.appendChild(createDom("li", {
className: result.status,
id: "spec_" + result.id,
title: result.fullName}
title: result.fullName
}
));
if (result.status == "failed") {