Skip to content

Commit 41b7a09

Browse files
committed
Merge pull request #21 from codeclimate/pb-config
Allow configurability of the FIXME strings
2 parents 47e17e4 + 1d46c20 commit 41b7a09

File tree

4 files changed

+28
-22
lines changed

4 files changed

+28
-22
lines changed

Diff for: README.md

+17
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,23 @@ These strings are things you should fix now, not later.
1717
2. Run `codeclimate engines:enable fixme`. This command both installs the engine and enables it in your `.codeclimate.yml` file.
1818
3. You're ready to analyze! Browse into your project's folder and run `codeclimate analyze`.
1919

20+
### Configuration
21+
22+
You can specify what strings to match by adding a `strings` key in your
23+
`.codeclimate.yml`:
24+
25+
```yaml
26+
engines:
27+
fixme:
28+
enabled: true
29+
strings:
30+
- FIXME
31+
- CUSTOM
32+
```
33+
34+
**NOTE**: values specified here *override* the defaults, they are not
35+
*additional* strings to match.
36+
2037
### Need help?
2138
2239
For help with `codeclimate-fixme`, please open an issue on this repository.

Diff for: lib/file-builder.js

-9
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@ function withIncludes(include_paths) {
66
return buildFiles(include_paths);
77
}
88

9-
// Returns file paths based on the exclude_paths values in config file
10-
function withExcludes(exclude_paths) {
11-
var allFiles = glob.sync("/code/**/**", {});
12-
var excludedFiles = buildFiles(exclude_paths);
13-
14-
return diff(allFiles, excludedFiles);
15-
}
16-
179
// Returns all the file paths in the main directory that match the given pattern
1810
function buildFiles(paths) {
1911
var files = [];
@@ -35,7 +27,6 @@ function filterFiles(paths) {
3527

3628
module.exports = {
3729
withIncludes: withIncludes,
38-
withExcludes: withExcludes,
3930
filterFiles: filterFiles
4031
};
4132

Diff for: lib/fix-me.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,30 @@ function FixMe() { }
1111

1212
FixMe.prototype.runEngine = function(){
1313
var analysisFiles = [],
14+
config = {
15+
include_paths: ["./"],
16+
strings: ["FIXME", "TODO", "HACK", "XXX", "BUG"]
17+
},
1418
self = this;
1519

1620
if (fs.existsSync('/config.json')) {
17-
var engineConfig = JSON.parse(fs.readFileSync('/config.json'));
21+
var overrides = JSON.parse(fs.readFileSync('/config.json'));
1822

19-
if (engineConfig.hasOwnProperty('include_paths')) {
20-
analysisFiles = fileBuilder.withIncludes(engineConfig.include_paths);
21-
} else if (engineConfig.hasOwnProperty('exclude_paths')) {
22-
analysisFiles = fileBuilder.withExcludes(engineConfig.exclude_paths);
23+
for (var prop in overrides) {
24+
config[prop] = overrides[prop];
2325
}
2426
}
2527

28+
analysisFiles = fileBuilder.withIncludes(config.include_paths);
2629
analysisFiles = fileBuilder.filterFiles(analysisFiles);
2730

2831
analysisFiles.forEach(function(f, i, a){
29-
self.find(f);
32+
self.find(f, config.strings);
3033
});
3134
}
3235

33-
FixMe.prototype.find = function(file){
34-
var fixmeStrings = "'(FIXME|TODO|HACK|XXX|BUG)'",
36+
FixMe.prototype.find = function(file, strings){
37+
var fixmeStrings = "'(" + strings.join("|") + ")'",
3538
self = this;
3639

3740
// Prepare the grep string for execution (uses BusyBox grep)

Diff for: test/file-builder.js

-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ describe("fileBuilder", function(){
77
// expect();
88
});
99
});
10-
describe("#withExcludes(paths)", function(){
11-
xit("returns correct files", function(){
12-
// expect();
13-
});
14-
});
1510
describe("#filterFiles(paths)", function(){
1611
xit("returns filters out directory paths", function(){
1712
// expect();

0 commit comments

Comments
 (0)