Skip to content

Commit 65dcb93

Browse files
author
Arkadiy Tetelman
committed
Don't pass in all filters to cpplint
1 parent 83d5998 commit 65dcb93

File tree

6 files changed

+22
-85
lines changed

6 files changed

+22
-85
lines changed

lib/filters.js

Lines changed: 2 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -2,92 +2,14 @@
22

33
var extend = require('./extend.js');
44

5-
/**
6-
* Each possible error, all enabled by default (other than build/include_alpha)
7-
* @type {Object}
8-
*/
9-
var defaults = {
10-
'build': {
11-
'class': true,
12-
'c++11': true,
13-
'deprecated': true,
14-
'endif_comment': true,
15-
'explicit_make_pair': true,
16-
'forward_decl': true,
17-
'header_guard': true,
18-
'include': true,
19-
// for whatever reason, by default, cpplint has this turned off by default
20-
'include_alpha': false,
21-
'include_order': true,
22-
'include_what_you_use': true,
23-
'namespaces': true,
24-
'printf_format': true,
25-
'storage_class': true
26-
},
27-
'legal': {
28-
'copyright': true
29-
},
30-
'readability': {
31-
'alt_tokens': true,
32-
'braces': true,
33-
'casting': true,
34-
'check': true,
35-
'constructors': true,
36-
'fn_size': true,
37-
'function': true,
38-
'multiline_comment': true,
39-
'multiline_string': true,
40-
'nolint': true,
41-
'nul': true,
42-
'streams': true,
43-
'todo': true,
44-
'utf8': true
45-
},
46-
'runtime': {
47-
'arrays': true,
48-
'casting': true,
49-
'explicit': true,
50-
'int': true,
51-
'init': true,
52-
'invalid_increment': true,
53-
'member_string_references': true,
54-
'memset': true,
55-
'operator': true,
56-
'printf': true,
57-
'printf_format': true,
58-
'references': true,
59-
'string': true,
60-
'threadsafe_fn': true,
61-
'vlog': true
62-
},
63-
'whitespace': {
64-
'blank_line': true,
65-
'braces': true,
66-
'comma': true,
67-
'comments': true,
68-
'empty_conditional_body': true,
69-
'empty_loop_body': true,
70-
'end_of_line': true,
71-
'ending_newline': true,
72-
'indent': true,
73-
'line_length': true,
74-
'newline': true,
75-
'operators': true,
76-
'parens': true,
77-
'semicolon': true,
78-
'tab': true,
79-
'todo': true
80-
}
81-
};
82-
835
/**
846
* Parse a command-line list of excludes and convert into an object
857
*
868
* @param {String} str
879
* @return {Object}
8810
*/
8911
function parse(str) {
90-
var result = extend({}, defaults),
12+
var result = {},
9113
excludes = str.split(',');
9214

9315
excludes.forEach(function (option) {
@@ -103,9 +25,8 @@ function parse(str) {
10325
return;
10426
}
10527

106-
// non-supported categories
10728
if (!result.hasOwnProperty(category)) {
108-
return;
29+
result[category] = {};
10930
}
11031

11132
result[category][subcategory] = false;
@@ -116,6 +37,5 @@ function parse(str) {
11637
}
11738

11839
module.exports = {
119-
'defaults': defaults,
12040
'parse': parse
12141
};

lib/parse-options.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ var MIN_VERBOSITY = 0;
2323
var defaults = {};
2424
defaults.verbosity = 1;
2525
defaults.counting = 'total';
26-
defaults.filters = require('./filters.js').defaults;
2726

2827
/**
2928
* @async

tasks/cpplint.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module.exports = function (grunt) {
3333
return false;
3434
}
3535

36-
options.filters = extend(filters.defaults, gruntFilters, true);
36+
options.filters = gruntFilters;
3737

3838
options.extensions = conf('extensions');
3939

test/cli.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ var path = require('path');
1010

1111
var execFile = require('child_process').execFile;
1212

13+
var exec = require('child_process').exec;
14+
1315
var suite = vows.describe('cli');
1416

1517
suite.addBatch({
@@ -46,6 +48,20 @@ suite.addBatch({
4648
var lines = stdout.split('\n');
4749
assert.lengthOf(lines, 7);
4850
}
51+
},
52+
53+
'filters': {
54+
topic: function () {
55+
exec(path.join(__dirname, '..', 'bin', 'cpplint') + ' --filters legal-copyright,' +
56+
'build-namespaces,whitespace-braces ' + path.join(__dirname, 'fixtures', 'node-cpp-hello.cpp'),
57+
this.callback);
58+
},
59+
60+
'should exclude the filters': function (err, stdout, stderr) {
61+
var lines = stdout.split('\n');
62+
assert.lengthOf(lines, 2);
63+
assert.match(lines[0], //);
64+
}
4965
}
5066
});
5167

test/lint-error.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ suite.addBatch({
228228
assert.equal(lintError.linenumber, '1');
229229
},
230230
'should have correct reason': function (err, lintError) {
231-
console.log(lintError);
232231
assert.equal(lintError.reason, '<future> is an unapproved C++11 header.');
233232
},
234233
'should have correct category': function (err, lintError) {

test/parse-options.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ suite.addBatch({
3737
assert.equal(result.verbosity, 1);
3838

3939
assert.equal(result.counting, 'total');
40+
},
41+
'should not pass in filters': function (err, result) {
42+
assert.equal(result.filters, undefined);
4043
}
4144
},
4245

0 commit comments

Comments
 (0)