Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ ratings:
paths:
- "**.js"
exclude_paths:
- "test"
- "node_modules"
- "node_modules/"
- "test/fixtures/"
213 changes: 0 additions & 213 deletions .eslintrc

This file was deleted.

25 changes: 25 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
"env": {
"node": true, // When in a backend context
"es6": true,
},
"rules": {
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
"comma-style": [2, "first", { exceptions: {ArrayExpression: true, ObjectExpression: true} }],
"complexity": [2, 6],
"curly": 2,
"eqeqeq": [2, "allow-null"],
"no-shadow-restricted-names": 2,
"no-undef": 2,
"no-use-before-define": 2,
"radix": 2,
"semi": 2,
"space-infix-ops": 2,
"strict": 0,
},
/**
* globals should be defined per file when possible. Use the directive here
* when there are project-level globals (such as jquery)
*/
"globals": {},
};
5 changes: 4 additions & 1 deletion bin/fixme
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ var FixMe = require('../lib/fix-me');
var config;

fs.readFile('/config.json', function(err, data) {
if (!err) config = JSON.parse(data);
if (!err) {
config = JSON.parse(data);
}

new FixMe().run(config)
});
10 changes: 6 additions & 4 deletions lib/fix-me.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ FixMe.prototype.run = function(engineConfig) {
strings = DEFAULT_STRINGS;
}

this.find(paths, strings)
}
this.find(paths, strings);
};

FixMe.prototype.find = function(paths, strings, callback) {
var pattern = `(${strings.join('|')})`;
Expand Down Expand Up @@ -61,7 +61,9 @@ FixMe.prototype.find = function(paths, strings, callback) {
this.output.write(JSON.stringify(issue) + '\0');
});

if (callback) grep.stdout.on('close', _ => callback());
}
if (callback) {
grep.stdout.on('close', _ => callback());
}
};

module.exports = FixMe;
34 changes: 9 additions & 25 deletions test/fix-me.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* global define, it, describe, context */

var expect = require('chai').expect;
var stream = require('stream');
var util = require('util');
var FixMe = require('../lib/fix-me.js');
var IssueBuffer = require('./support/issue_buffer');

describe("fixMe", function(){
describe("#run(engineConfig)", function() {
Expand All @@ -12,7 +13,7 @@ describe("fixMe", function(){
engine.find = function(_, strings) {
expect(strings).to.have.members(['BUG', 'FIXME', 'HACK', 'TODO', 'XXX']);
done();
}
};

engine.run();
});
Expand All @@ -23,7 +24,7 @@ describe("fixMe", function(){
engine.find = function(paths) {
expect(paths).to.have.members(['./']);
done();
}
};

engine.run();
});
Expand All @@ -36,9 +37,9 @@ describe("fixMe", function(){
};

engine.find = function(paths) {
expect(paths).to.have.members(['test/fixtures/code/src/code/test.js'])
expect(paths).to.have.members(['test/fixtures/code/src/code/test.js']);
done();
}
};

engine.run(config);
});
Expand All @@ -54,7 +55,7 @@ describe("fixMe", function(){
engine.find = function(_, strings) {
expect(strings).to.have.members(['SUP']);
done();
}
};

engine.run(engineConfig);
});
Expand All @@ -68,7 +69,7 @@ describe("fixMe", function(){
engine.find(['test/fixtures/file.js'], ['TODO', 'SUP'], function() {
var issues = buf.toIssues();

expect(issues.length).to.eq(2)
expect(issues.length).to.eq(2);

expect(issues[0].categories).to.have.members(['Bug Risk']);
expect(issues[0].check_name).to.eq('TODO');
Expand Down Expand Up @@ -142,20 +143,3 @@ describe("fixMe", function(){
});
});
});

function IssueBuffer() {
this._data = "";
stream.Writable.call(this);
}

util.inherits(IssueBuffer, stream.Writable);

IssueBuffer.prototype._write = function(chunk, encoding, done) {
this._data += chunk.toString();
done();
};

IssueBuffer.prototype.toIssues = function() {
if (this._data.length === 0) return [];
return this._data.slice(0, -1).split('\0').map((json) => JSON.parse(json));
}
24 changes: 24 additions & 0 deletions test/support/issue_buffer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
var stream = require('stream');
var util = require('util');

function IssueBuffer() {
this._data = "";
stream.Writable.call(this);
}

util.inherits(IssueBuffer, stream.Writable);

IssueBuffer.prototype._write = function(chunk, encoding, done) {
this._data += chunk.toString();
done();
};

IssueBuffer.prototype.toIssues = function() {
if (this._data.length === 0) {
return [];
}

return this._data.slice(0, -1).split('\0').map((json) => JSON.parse(json));
};

module.exports = IssueBuffer;