Skip to content

Commit 7ab2a75

Browse files
committed
lint
1 parent c415402 commit 7ab2a75

File tree

5 files changed

+898
-23
lines changed

5 files changed

+898
-23
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea/*
2+
.DS_Store
3+
node_modules/*

coverage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const coverage = function(path, repo, sha, callback) {
102102
if (e.$.filename.startsWith('signals\\')) {modules.signals.push(e); return false;}
103103
if (e.$.filename.startsWith('npy-matlab\\')) {modules['npy-matlab'].push(e); return false;}
104104
if (e.$.filename.startsWith('wheelAnalysis\\')) {modules.wheelAnalysis.push(e); return false;}
105-
else {return true};
105+
else {return true}
106106
});
107107
formatCoverage(modules[repo.toLowerCase()], rigboxPath, callback);
108108
});
@@ -123,4 +123,4 @@ md5 = function(path) {
123123
};
124124

125125
// Export Coverage
126-
module.exports = coverage;
126+
module.exports = coverage;

index.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function loadTestRecords(id) {
8787
let records = obj.filter(o => id.includes(o.commit));
8888
// If single arg return as object, otherwise keep as array
8989
return (!Array.isArray(id) && records.length === 1 ? records[0] : records)
90-
};
90+
}
9191

9292
/**
9393
* Compare coverage of two commits and post a failed status if coverage of head commit <= base commit.
@@ -106,7 +106,7 @@ function compareCoverage(data) {
106106
description = 'Failed to determine coverage as tests incomplete due to errors';
107107
} else if (records.length === 2 && has_coverage) {
108108
// Ensure first record is for head commit
109-
if (records[0].commit === ids.base) { records.reverse() };
109+
if (records[0].commit === ids.base) { records.reverse() }
110110
// Calculate coverage change
111111
let coverage = records[0].coverage - records[1].coverage;
112112
status = (coverage > 0 ? 'success' : 'failure');
@@ -119,7 +119,7 @@ function compareCoverage(data) {
119119
let job = queue.pile.filter(o => o.data.sha === ids[commit]);
120120
if (job.length > 0) { // Already on pile
121121
// Add coverage key to job data structure
122-
if (typeof job[0].data.coverage === 'undefined') { job[0].data.coverage = ids; };
122+
if (typeof job[0].data.coverage === 'undefined') { job[0].data.coverage = ids; }
123123
} else { // Add test to queue
124124
queue.add({
125125
skipPost: true,
@@ -133,7 +133,7 @@ function compareCoverage(data) {
133133
}
134134
}
135135
return;
136-
};
136+
}
137137
// Post a our coverage status
138138
request('POST /repos/:owner/:repo/statuses/:sha', {
139139
owner: 'cortex-lab',
@@ -148,7 +148,7 @@ function compareCoverage(data) {
148148
description: description,
149149
context: 'coverage/ZTEST'
150150
});
151-
};
151+
}
152152

153153
// Serve the test results for requested commit id
154154
srv.get('/github/:id', function (req, res) {
@@ -160,7 +160,7 @@ srv.get('/github/:id', function (req, res) {
160160
res.send(`Record for commit ${req.params.id} not found`);
161161
} else {
162162
res.statusCode = 200;
163-
preText = '<html><body><pre>';
163+
preText = '<html lang="en-GB"><body><pre>';
164164
postText = '</pre></body></html>';
165165
res.send(preText + data + postText);
166166

@@ -192,16 +192,16 @@ srv.get('/coverage/:repo/:branch', async (req, res) => {
192192
var report = {'schemaVersion': 1, 'label': 'coverage'};
193193
try { // Try to load coverage record
194194
record = await loadTestRecords(id);
195-
if (typeof record == 'undefined' || record['coverage'] == '') {throw 404}; // Test not found for commit
196-
if (record['status'] === 'error') {throw 500}; // Test found for commit but errored
195+
if (typeof record == 'undefined' || record['coverage'] == '') {throw 404} // Test not found for commit
196+
if (record['status'] === 'error') {throw 500} // Test found for commit but errored
197197
report['message'] = Math.round(record['coverage']*100)/100 + '%';
198198
report['color'] = (record['coverage'] > 75 ? 'brightgreen' : 'red');
199199
} catch (err) { // No coverage value
200200
report['message'] = (err === 404 ? 'pending' : 'unknown');
201201
report['color'] = 'orange';
202202
// Check test isn't already on the pile
203203
let onPile = false;
204-
for (let job of queue.pile) { if (job.id === id) { onPile = true; break; } };
204+
for (let job of queue.pile) { if (job.id === id) { onPile = true; break; } }
205205
if (!onPile) { // Add test to queue
206206
queue.add({
207207
skipPost : true,
@@ -214,7 +214,7 @@ srv.get('/coverage/:repo/:branch', async (req, res) => {
214214
} finally { // Send report
215215
res.setHeader('Content-Type', 'application/json');
216216
res.end(JSON.stringify(report));}
217-
} else { throw 404 }; // Specified repo or branch not found
217+
} else { throw 404 } // Specified repo or branch not found
218218
} catch (error) {
219219
let msg = (error === 404 ? `${req.params.repo}/${req.params.branch} not found` : error); // @fixme error thrown by request not 404
220220
console.error(msg)
@@ -238,15 +238,15 @@ srv.get('/status/:repo/:branch', async (req, res) => {
238238
var report = {'schemaVersion': 1, 'label': 'build'};
239239
try { // Try to load coverage record
240240
record = await loadTestRecords(id);
241-
if (typeof record == 'undefined' || record['status'] == '') {throw 404}; // Test not found for commit
241+
if (typeof record == 'undefined' || record['status'] == '') {throw 404} // Test not found for commit
242242
report['message'] = (record['status'] === 'success' ? 'passing' : 'failing');
243243
report['color'] = (record['status'] === 'success' ? 'brightgreen' : 'red');
244244
} catch (err) { // No coverage value
245245
report['message'] = (err === 404 ? 'pending' : 'unknown');
246246
report['color'] = 'orange';
247247
// Check test isn't already on the pile
248248
let onPile = false;
249-
for (let job of queue.pile) { if (job.id === id) { onPile = true; break; } };
249+
for (let job of queue.pile) { if (job.id === id) { onPile = true; break; } }
250250
if (!onPile) { // Add test to queue
251251
queue.add({
252252
skipPost: true,
@@ -259,7 +259,7 @@ srv.get('/status/:repo/:branch', async (req, res) => {
259259
} finally { // Send report
260260
res.setHeader('Content-Type', 'application/json');
261261
res.end(JSON.stringify(report));}
262-
} else { throw 404 }; // Specified repo or branch not found
262+
} else { throw 404 } // Specified repo or branch not found
263263
} catch (error) {
264264
let msg = (error === 404 ? `${req.params.repo}/${req.params.branch} not found` : error); // @fixme error thrown by request not 404
265265
console.error(msg)
@@ -277,7 +277,7 @@ queue.process(async (job, done) => {
277277
var path = process.env.RIGBOX_REPO_PATH;
278278
if (job.data['repo'] === 'alyx-matlab' || job.data['repo'] === 'signals') {
279279
path = path + '\\' + job.data['repo'];}
280-
if (job.data['repo'] === 'alyx') { sha = 'dev' }; // For Alyx checkout master
280+
if (job.data['repo'] === 'alyx') { sha = 'dev' } // For Alyx checkout master
281281
// Checkout commit
282282
checkout = cp.execFile('checkout.bat ', [sha, path], (error, stdout, stderr) => {
283283
if (error) { // Send error status
@@ -323,11 +323,11 @@ queue.process(async (job, done) => {
323323
*/
324324
queue.on('finish', job => { // On job end post result to API
325325
console.log(`Job ${job.id} complete`)
326-
// If job was part of coverage test and error'd, call compare function
326+
// If job was part of coverage test and error'd, call compare function
327327
// (otherwise this is done by the on complete callback after writing coverage to file)
328-
if (typeof job.data.coverage !== 'undefined' && job.data['status'] == 'error') {
329-
compareCoverage(job.data);
330-
};
328+
if (typeof job.data.coverage !== 'undefined' && job.data['status'] == 'error') {
329+
compareCoverage(job.data);
330+
}
331331
if (job.data.skipPost === true) { return; }
332332
request("POST /repos/:owner/:repo/statuses/:sha", {
333333
owner: job.data['owner'],
@@ -440,7 +440,7 @@ handler.on('pull_request', async function (event) {
440440
description: 'Tests running',
441441
context: 'continuous-integration/ZTEST'
442442
});
443-
};
443+
}
444444

445445
// Post a 'pending' status while we do our tests
446446
request('POST /repos/:owner/:repo/statuses/:sha', {
@@ -458,7 +458,7 @@ handler.on('pull_request', async function (event) {
458458
});
459459
// Check coverage exists
460460
let data = {
461-
repo: event.payload.repository.name,
461+
repo: event.payload.repository.name,
462462
coverage: {head: head_commit, base: base_commit}
463463
};
464464
compareCoverage(data);
@@ -480,4 +480,4 @@ openTunnel();
480480
process.on('unhandledRejection', (reason, p) => {
481481
console.log('Unhandled Rejection at: Promise', p, 'reason:', reason);
482482
console.log(reason.stack)
483-
});
483+
});

0 commit comments

Comments
 (0)