aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Godbolt <matt@godbolt.org>2016-10-12 13:26:16 -0500
committerMatt Godbolt <matt@godbolt.org>2016-10-12 13:26:16 -0500
commit6fc5c166daa7008668061b8c72cdfe9c80d03721 (patch)
tree5f6dcdd5ffb17657d9e100f2df517264217d2a29
parent2e3c59838040dbde42f73737179883ba11f13d33 (diff)
downloadcompiler-explorer-6fc5c166daa7008668061b8c72cdfe9c80d03721.tar.gz
compiler-explorer-6fc5c166daa7008668061b8c72cdfe9c80d03721.zip
Lint fixes
-rw-r--r--Makefile7
-rwxr-xr-xapp.js10
-rw-r--r--lib/asm.js7
-rw-r--r--lib/compile.js6
-rw-r--r--lib/diff.js3
-rw-r--r--package.json3
-rw-r--r--static/compiler.js8
-rw-r--r--static/editor.js4
-rw-r--r--static/rison.js2
9 files changed, 27 insertions, 23 deletions
diff --git a/Makefile b/Makefile
index c79a899a6..93e34cf93 100644
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,7 @@ endif
endif
.PHONY: clean run test run-amazon c-preload optional-d-support prereqs node_modules bower_modules
-.PHONY: dist
+.PHONY: dist lint
prereqs: optional-d-support node_modules c-preload bower_modules
ifeq "" "$(shell which gdc)"
@@ -39,12 +39,15 @@ $(BOWER_MODULES): bower.json $(NODE_MODULES)
$(NODE) ./node_modules/bower/bin/bower install
@touch $@
+lint: $(NODE_MODULES)
+ $(NODE) ./node_modules/.bin/jshint app.js $(shell find lib static -name '*.js' -not -path 'static/ext/*')
+
LANG:=C++
node_modules: $(NODE_MODULES)
bower_modules: $(BOWER_MODULES)
-test:
+test: $(NODE_MODULES) lint
(cd test; $(NODE) test.js)
$(MAKE) -C c-preload test
@echo Tests pass
diff --git a/app.js b/app.js
index f9b5102db..5a20fbcdd 100755
--- a/app.js
+++ b/app.js
@@ -169,7 +169,7 @@ function ClientOptionsHandler(fileSources) {
environment: env
};
text = JSON.stringify(options);
- }
+ };
this.handler = function getClientOptions(req, res) {
res.set('Content-Type', 'application/json');
res.set('Cache-Control', 'public, max-age=' + staticMaxAgeMs);
@@ -422,8 +422,8 @@ function shortUrlHandler(req, res, next) {
var bits = req.url.split("/");
if (bits.length !== 2 || req.method !== "GET") return next();
var key = process.env.GOOGLE_API_KEY;
- var googleApiUrl = 'https://www.googleapis.com/urlshortener/v1/url?shortUrl=http://goo.gl/'
- + encodeURIComponent(bits[1]) + '&key=' + key;
+ var googleApiUrl = 'https://www.googleapis.com/urlshortener/v1/url?shortUrl=http://goo.gl/' +
+ encodeURIComponent(bits[1]) + '&key=' + key;
https.get(googleApiUrl, function (response) {
var responseText = '';
response.on('data', function (d) {
@@ -431,8 +431,8 @@ function shortUrlHandler(req, res, next) {
});
response.on('end', function () {
if (response.statusCode != 200) {
- console.log("Failed to resolve short URL " + bits[1] + " - got response "
- + response.statusCode + " : " + responseText);
+ console.log("Failed to resolve short URL " + bits[1] + " - got response " +
+ response.statusCode + " : " + responseText);
return next();
}
diff --git a/lib/asm.js b/lib/asm.js
index b054427ac..f5d3b454f 100644
--- a/lib/asm.js
+++ b/lib/asm.js
@@ -82,19 +82,18 @@
// Now follow the chains of used labels, marking any weak references they refer
// to as also used. We iteratively do this until either no new labels are found,
// or we hit a limit (only here to prevent a pathological case from hanging).
+ function markUsed(label) { labelsUsed[label] = true; }
var MaxLabelIterations = 10;
for (var iter = 0; iter < MaxLabelIterations; ++iter) {
var toAdd = [];
- _.each(labelsUsed, function (t, label) {
+ _.each(labelsUsed, function (t, label) { // jshint ignore:line
_.each(weakUsages[label], function (nowused) {
if (labelsUsed[nowused]) return;
toAdd.push(nowused);
});
});
if (!toAdd) break;
- _.each(toAdd, function (label) {
- labelsUsed[label] = true;
- });
+ _.each(toAdd, markUsed);
}
return labelsUsed;
}
diff --git a/lib/compile.js b/lib/compile.js
index b93207526..09fccc450 100644
--- a/lib/compile.js
+++ b/lib/compile.js
@@ -28,7 +28,7 @@ var child_process = require('child_process'),
httpProxy = require('http-proxy'),
LRU = require('lru-cache'),
fs = require('fs-extra'),
- Promise = require('promise'),
+ Promise = require('promise'), // jshint ignore:line
Queue = require('promise-queue'),
asm = require('./asm');
@@ -48,7 +48,7 @@ var stubText = null;
function identity(x) {
return x;
-};
+}
function initialise(gccProps_, compilerProps_) {
gccProps = gccProps_;
@@ -403,7 +403,7 @@ function CompileHandler() {
if (source === undefined) {
return next(new Error("Bad request"));
}
- var options = req.body.options.split(' ').filter(identity);
+ options = req.body.options.split(' ').filter(identity);
var filters = req.body.filters;
compileObj.compile(source, compiler, options, filters).then(
function (result) {
diff --git a/lib/diff.js b/lib/diff.js
index bf31673c4..f78e32343 100644
--- a/lib/diff.js
+++ b/lib/diff.js
@@ -2,7 +2,8 @@ var fs = require('fs'),
child_process = require('child_process'),
temp = require('temp'),
path = require('path'),
- Promise = require('promise');
+ Promise = require('promise') // jshint ignore:line
+ ;
function cleanAndGetIndexes(text) {
var addRules = {
diff --git a/package.json b/package.json
index 02f451653..8f6cf5180 100644
--- a/package.json
+++ b/package.json
@@ -35,7 +35,8 @@
"devDependencies": {
"supervisor": "*",
"bower": "*",
- "requirejs": "*"
+ "requirejs": "*",
+ "jshint": "*"
},
"scripts": {
"test": "make test"
diff --git a/static/compiler.js b/static/compiler.js
index 86c0f7bdf..455b45103 100644
--- a/static/compiler.js
+++ b/static/compiler.js
@@ -117,8 +117,8 @@ define(function (require) {
}, this);
this.container.layoutManager.createDragSource(this.domRoot.find(".status").parent(), outputConfig);
this.domRoot.find(".status").parent().click(_.bind(function () {
- var insertPoint = hub.findParentRowOrColumn(this.container)
- || this.container.layoutManager.root.contentItems[0];
+ var insertPoint = hub.findParentRowOrColumn(this.container) ||
+ this.container.layoutManager.root.contentItems[0];
insertPoint.addChild(outputConfig());
}, this));
@@ -133,8 +133,8 @@ define(function (require) {
this.container.layoutManager.createDragSource(
this.domRoot.find('.btn.add-compiler'), cloneComponent);
this.domRoot.find('.btn.add-compiler').click(_.bind(function () {
- var insertPoint = hub.findParentRowOrColumn(this.container)
- || this.container.layoutManager.root.contentItems[0];
+ var insertPoint = hub.findParentRowOrColumn(this.container) ||
+ this.container.layoutManager.root.contentItems[0];
insertPoint.addChild(cloneComponent());
}, this));
}
diff --git a/static/editor.js b/static/editor.js
index 9d569acd0..0b72ba401 100644
--- a/static/editor.js
+++ b/static/editor.js
@@ -164,8 +164,8 @@ define(function (require) {
this.container.layoutManager.createDragSource(
this.domRoot.find('.btn.add-compiler'), compilerConfig);
this.domRoot.find('.btn.add-compiler').click(_.bind(function () {
- var insertPoint = hub.findParentRowOrColumn(this.container)
- || this.container.layoutManager.root.contentItems[0];
+ var insertPoint = hub.findParentRowOrColumn(this.container) ||
+ this.container.layoutManager.root.contentItems[0];
insertPoint.addChild(compilerConfig);
}, this));
}
diff --git a/static/rison.js b/static/rison.js
index 205f64635..76390b061 100644
--- a/static/rison.js
+++ b/static/rison.js
@@ -1,5 +1,5 @@
// Taken from https://github.com/Nanonid/rison at 917679fb6cafa15e2a186cd5a47163792899b321
-
+/* jshint ignore:start */
// Uses CommonJS, AMD or browser globals to create a module.
// Based on: https://github.com/umdjs/umd/blob/master/commonjsStrict.js
(function (root, factory) {