Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgodbolt committed Oct 12, 2016
1 parent 2e3c598 commit 6fc5c16
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 23 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -422,17 +422,17 @@ 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) {
responseText += d;
});
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();
}

Expand Down
7 changes: 3 additions & 4 deletions lib/asm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -48,7 +48,7 @@ var stubText = null;

function identity(x) {
return x;
};
}

function initialise(gccProps_, compilerProps_) {
gccProps = gccProps_;
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion lib/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"devDependencies": {
"supervisor": "*",
"bower": "*",
"requirejs": "*"
"requirejs": "*",
"jshint": "*"
},
"scripts": {
"test": "make test"
Expand Down
8 changes: 4 additions & 4 deletions static/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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));
}
Expand Down
4 changes: 2 additions & 2 deletions static/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion static/rison.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down

0 comments on commit 6fc5c16

Please sign in to comment.