Skip to content

Commit c812d24

Browse files
committed
Some jslint fixes
1 parent d507696 commit c812d24

35 files changed

+155
-179
lines changed

database-jones/test/JonesTestDriver.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ driver.addCommandLineOption("", "--set <var>=<value>", "set a connection propert
5353
var pair = nextArg.split('=');
5454
if(pair.length === 2) {
5555
val = pair[1];
56-
if(val === 'true') val = true;
57-
else if(val === 'false') val = false;
56+
if(val === 'true') { val = true; }
57+
else if(val === 'false') { val = false; }
5858
cmdLineProperties[pair[0]] = val;
5959
return 1;
6060
}

database-jones/test/composition/ProjectionErrorTest.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ t3.run = function() {
100100
var session;
101101
var expectedErrorMessage = 'shoppingCart must not be a relationship';
102102
var customerProjection = new mynode.Projection(lib.Customer);
103-
var shoppingCartProjection = new mynode.Projection(lib.ShoppingCart);
104103
customerProjection.addField('shoppingCart');
105104
lib.mapShop();
106105

@@ -124,7 +123,6 @@ t4.run = function() {
124123
var session;
125124
var expectedErrorMessage = 'shoppingCart must not be a relationship';
126125
var customerProjection = new mynode.Projection(lib.Customer);
127-
var shoppingCartProjection = new mynode.Projection(lib.ShoppingCart);
128126
customerProjection.addField('shoppingCart');
129127
lib.mapShop();
130128

database-jones/test/driver.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ switch(adapter) {
6161
driver.addSuitesFromDirectory(a_module.config.suites_dir);
6262
break;
6363
case "mysql": /* MySQL uses the extra argument to set engine */
64-
if(extra) properties.mysql_storage_engine = extra;
64+
if(extra) { properties.mysql_storage_engine = extra; }
6565
break;
6666
default:
6767
break;

database-jones/test/freeform/ExcludeFieldsTest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var util = require("util");
2323
var udebug = unified_debug.getLogger("ExcludeFieldsTest.js");
2424

2525
function Semistruct(id, name, number, a, c) {
26-
if (typeof id !== 'undefined') {
26+
if (id !== undefined) {
2727
this.id = id;
2828
this.name = name;
2929
this.number = number;

database-jones/test/freeform/FreeformTest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var util = require("util");
2323
var udebug = unified_debug.getLogger("FreeformTest.js");
2424

2525
function Freeform(id, name, number, a) {
26-
if (typeof id !== 'undefined') {
26+
if (id !== undefined) {
2727
this.id = id;
2828
this.name = name;
2929
this.number = number;

database-jones/test/freeform/IncludeFieldTest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var util = require("util");
2323
var udebug = unified_debug.getLogger("IncludeFieldTest.js");
2424

2525
function Semistruct(id, name, number, a, c) {
26-
if (typeof id !== 'undefined') {
26+
if (id !== undefined) {
2727
this.id = id;
2828
this.name = name;
2929
this.number = number;

database-jones/test/freeform/SemistructTest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var util = require("util");
2323
var udebug = unified_debug.getLogger("SemistructTest.js");
2424

2525
function Semistruct(id, name, number, a) {
26-
if (typeof id !== 'undefined') {
26+
if (id !== undefined) {
2727
this.id = id;
2828
this.name = name;
2929
this.number = number;

database-jones/test/numerictypes/QueryBtreeIndexScanLimitTest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ testQueries.run = function() {
9090
testCase.mappings = from;
9191

9292
function onOpenSession(session) {
93-
var i = 0, j = 0, completedTestCount = 0, testCount = queryTests.length;
93+
var j = 0, completedTestCount = 0, testCount = queryTests.length;
9494

9595
function onExecute(err, results, queryTest) {
9696
if (queryTest.expectedError) {

database-jones/test/numerictypes/QueryKeywordTest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ global.verify_integraltypes_keyword = function(err, instance, id, testCase, doma
5151
testCase.appendErrorMessage(err);
5252
return;
5353
}
54-
if (typeof(instance) !== 'object') {
55-
testCase.appendErrorMessage('Result for id ' + id + ' is not an object; actual type: ' + typeof(instance));
54+
if (typeof instance !== 'object') {
55+
testCase.appendErrorMessage('Result for id ' + id + ' is not an object; actual type: ' + typeof instance );
5656
}
5757
if (instance === null) {
5858
testCase.appendErrorMessage('Result for id ' + id + ' is null.');

database-jones/test/numerictypes/QueryPrimaryIndexScanLimitTest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ testQueries.run = function() {
8383
testCase.mappings = from;
8484

8585
function onOpenSession(session) {
86-
var i = 0, j = 0, completedTestCount = 0, testCount = queryTests.length;
86+
var j = 0, completedTestCount = 0, testCount = queryTests.length;
8787

8888
function onExecute(err, results, queryTest) {
8989
if (queryTest.expectedError) {

database-jones/test/numerictypes/lib.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ var udebug = unified_debug.getLogger("integraltypes/lib.js");
2525

2626
/** The integraltypes domain object */
2727
global.integraltypes = function(id, ttinyint, tsmallint, tmediumint, tint, tbigint) {
28-
if (typeof(id) !== 'undefined') this.id = id;
29-
if (typeof(ttinyint) !== 'undefined') this.ttinyint = ttinyint;
30-
if (typeof(tsmallint) !== 'undefined') this.tsmallint = tsmallint;
31-
if (typeof(tmediumint) !== 'undefined') this.tmediumint = tmediumint;
32-
if (typeof(tint) !== 'undefined') this.tint = tint;
33-
if (typeof(tbigint) !== 'undefined') this.tbigint = tbigint;
28+
if (id !== undefined) { this.id = id; }
29+
if (ttinyint !== undefined) { this.ttinyint = ttinyint; }
30+
if (tsmallint !== undefined) { this.tsmallint = tsmallint; }
31+
if (tmediumint !== undefined) { this.tmediumint = tmediumint; }
32+
if (tint !== undefined) { this.tint = tint; }
33+
if (tbigint !== undefined) { this.tbigint = tbigint; }
3434
};
3535

3636
/** The integraltypes key */
@@ -56,8 +56,8 @@ global.verify_integraltypes = function(err, instance, id, testCase, domainObject
5656
testCase.appendErrorMessage(err);
5757
return;
5858
}
59-
if (typeof(instance) !== 'object') {
60-
testCase.appendErrorMessage('Result for id ' + id + ' is not an object; actual type: ' + typeof(instance));
59+
if (typeof instance !== 'object') {
60+
testCase.appendErrorMessage('Result for id ' + id + ' is not an object; actual type: ' + typeof instance);
6161
}
6262
if (instance === null) {
6363
testCase.appendErrorMessage('Result for id ' + id + ' is null.');
@@ -75,7 +75,7 @@ global.verify_integraltypes = function(err, instance, id, testCase, domainObject
7575
testCase.errorIfNotEqual('fail to verify tsmallint', id, instance.tsmallint);
7676
testCase.errorIfNotEqual('fail to verify tmediumint', id, instance.tmediumint);
7777
testCase.errorIfNotEqual('fail to verify tint', id, instance.tint);
78-
testCase.errorIfNotEqual('fail to verify tbigint of type ' + typeof(instance.tbigint), id + '', instance.tbigint);
78+
testCase.errorIfNotEqual('fail to verify tbigint of type ' + typeof instance.tbigint, id, instance.tbigint);
7979
};
8080

8181
global.fail_verify_integraltypes_array = function(err, instances, ids, testCase, domainObject) {
@@ -101,8 +101,8 @@ global.fail_verify_integraltypes = function(err, instance, id, testCase, domainO
101101
testCase.fail(err);
102102
return;
103103
}
104-
if (typeof(instance) !== 'object') {
105-
testCase.fail(new Error('Result for id ' + id + ' is not an object; actual type: ' + typeof(instance)));
104+
if (typeof instance !== 'object') {
105+
testCase.fail(new Error('Result for id ' + id + ' is not an object; actual type: ' + typeof instance));
106106
return;
107107
}
108108
if (instance === null) {

database-jones/test/spi/BasicVarcharTest.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020

2121
"use strict";
2222

23-
try {
24-
require("./suite_config.js");
25-
} catch(e) {}
26-
2723
var spi_lib = require("./lib.js");
2824
var assert = require("assert");
2925
var dbtablehandler = require(mynode.common.DBTableHandler);

database-jones/test/spi/DBConnectionPoolTest.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@
2121
"use strict";
2222

2323
var fs = require("fs");
24-
25-
try {
26-
require("./suite_config.js");
27-
} catch(e) {}
28-
2924
var spi_lib = require("./lib.js");
3025

3126
/*****

database-jones/test/spi/DBDictionaryTest.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@
2222

2323
var spi_lib = require("./lib.js");
2424

25-
try {
26-
require("./suite_config.js");
27-
} catch(e) {}
28-
2925
var t1 = new harness.ConcurrentTest("listTables");
3026
var t2 = new harness.ConcurrentTest("getTable");
3127

database-jones/test/spi/InsertAndDeleteIntTest.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020

2121
"use strict";
2222

23-
try {
24-
require("./suite_config.js");
25-
} catch(e) {}
26-
2723
var path = require("path"),
2824
spi_lib = require("./lib.js"),
2925
dbt = require(mynode.common.DBTableHandler),

database-jones/test/spi/InsertDuplicateTest.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020

2121
"use strict";
2222

23-
try {
24-
require("./suite_config.js");
25-
} catch(e) {}
26-
2723
var spi_lib = require("./lib.js");
2824
var dbtablehandler = require(mynode.common.DBTableHandler);
2925
var udebug = unified_debug.getLogger("InsertDuplicateTest.js");

database-jones/test/spi/UniqueKeyTest.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020

2121
"use strict";
2222

23-
try {
24-
require("./suite_config.js");
25-
} catch(e) {}
26-
2723
var assert = require("assert");
2824
var util = require("util");
2925
var spi_lib = require("./lib.js");

database-jones/test/spi/suite_config.js

Whitespace-only changes.

database-jones/test/t_basic/BatchTest.js

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -67,38 +67,40 @@ verifyInsert = function(err, session, start_value, number, testCase) {
6767
// after the batch insert, verify that the insert occurred
6868
var j, found_j;
6969
var completed = 0;
70-
for (j = start_value; j < start_value + number; ++j) {
71-
session.find(global.t_basic, j, function(err, found, testCase, callback_j, session) {
72-
var tx = session.currentTransaction();
73-
if (err && !testCase.expectError) {
74-
testCase.appendErrorMessage(
75-
'BatchTest.verifyInsert find callback for ', j,' failed: ', JSON.stringify(err));
76-
return;
77-
}
78-
found_j = 'undefined';
79-
if (found !== null) {
80-
found_j = found.id;
81-
if (found_j !== callback_j) {
82-
testCase.errorIfNotEqual(
83-
'BatchTest.verifyInsert find callback failed', found_j, found.id);
84-
}
70+
function onFound(err, found, testCase, callback_j, session) {
71+
var tx = session.currentTransaction();
72+
if (err && !testCase.expectError) {
73+
testCase.appendErrorMessage(
74+
'BatchTest.verifyInsert find callback for ', j,' failed: ', JSON.stringify(err));
75+
return;
76+
}
77+
found_j = 'undefined';
78+
if (found !== null) {
79+
found_j = found.id;
80+
if (found_j !== callback_j) {
81+
testCase.errorIfNotEqual(
82+
'BatchTest.verifyInsert find callback failed', found_j, found.id);
8583
}
86-
udebug.log('BatchTest.verifyInsert find callback for ', found_j);
87-
if (++completed === number) {
88-
// end of test case; all callbacks completed
89-
if (tx.isActive()) {
90-
tx.commit(function(err, session, testCase) {
91-
if (err) {
92-
testCase.fail(err);
93-
return;
94-
}
95-
testCase.failOnError();
96-
}, session, testCase);
97-
} else {
84+
}
85+
udebug.log('BatchTest.verifyInsert find callback for ', found_j);
86+
if (++completed === number) {
87+
// end of test case; all callbacks completed
88+
if (tx.isActive()) {
89+
tx.commit(function(err, session, testCase) {
90+
if (err) {
91+
testCase.fail(err);
92+
return;
93+
}
9894
testCase.failOnError();
99-
}
95+
}, session, testCase);
96+
} else {
97+
testCase.failOnError();
10098
}
101-
}, testCase, j, session);
99+
}
100+
}
101+
102+
for (j = start_value; j < start_value + number; ++j) {
103+
session.find(global.t_basic, j, onFound, testCase, j, session);
102104
}
103105
};
104106

database-jones/test/t_basic/ColumnConverterTest.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121

2222
/** The t_basic domain object */
2323
global.converter = function(id, name, status, magic) {
24-
if (typeof id !== 'undefined') this.id = id;
25-
if (typeof name !== 'undefined') this.name = name;
26-
if (typeof status !== 'undefined') this.status = status;
27-
if (typeof magic !== 'undefined') this.magic = magic;
24+
if (id !== undefined) { this.id = id; }
25+
if (name !== undefined) { this.name = name; }
26+
if (status !== undefined) { this.status = status; }
27+
if (magic !== undefined) {this.magic = magic; }
2828
};
2929
global.converter.prototype.getStatus = function() {
3030
return this.status;

database-jones/test/t_basic/DifferentColumnNameTest.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ var udebug = unified_debug.getLogger("t_basic/DifferentColumnName.js");
2323

2424
// Map a domain class with field names different from column names
2525
var Different = function(id, name, age, magic) {
26-
this.getId = function() {return this.fid;};
27-
if (typeof(id) !== 'undefined') this.fid = id;
28-
if (typeof(name) !== 'undefined') this.fname = name;
29-
if (typeof(age) !== 'undefined') this.fage = age;
30-
if (typeof(magic) !== 'undefined') this.fmagic = magic;
26+
this.getId = function() { return this.fid; };
27+
if (id !== undefined) { this.fid = id; }
28+
if (name !== undefined) { this.fname = name; }
29+
if (age !== undefined) { this.fage = age; }
30+
if (magic !== undefined) { this.fmagic = magic; }
3131
};
3232

3333
/** Verify the instance or fail the test case */
@@ -36,8 +36,8 @@ var fail_verify_Different = function(err, instance, id, testCase, domainObject)
3636
testCase.fail(err);
3737
return;
3838
}
39-
if (typeof(instance) !== 'object') {
40-
testCase.fail(new Error('Result for id ' + id + ' is not an object: ' + typeof(instance)));
39+
if (typeof instance !== 'object') {
40+
testCase.fail(new Error('Result for id ' + id + ' is not an object: ' + typeof instance));
4141
}
4242
if (instance === null) {
4343
testCase.fail(new Error('Result for id ' + id + ' is null.'));

database-jones/test/t_basic/GetMappingTest.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,8 @@ t4.run = function() {
9696
};
9797

9898
t4.testGetMapping = function(session, testCase) {
99-
var unmappedDomainClass = function() {
100-
};
101-
session.getMapping(unmappedDomainClass, function(err, result) {
99+
function UnmappedDomainClass() { return; }
100+
session.getMapping(UnmappedDomainClass, function(err, result) {
102101
if (err) {
103102
testCase.pass();
104103
return;
@@ -113,8 +112,6 @@ t5.run = function() {
113112
};
114113

115114
t5.testGetMapping = function(session, testCase) {
116-
var unmappedDomainClass = function() {
117-
};
118115
try {
119116
session.getMapping(1, function(err, result) {
120117
if (!err) {
@@ -134,8 +131,6 @@ t6.run = function() {
134131
};
135132

136133
t6.testGetMapping = function(session, testCase) {
137-
var unmappedDomainClass = function() {
138-
};
139134
try {
140135
session.getMapping(true, function(err, result) {
141136
if (!err) {

0 commit comments

Comments
 (0)