Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 282f3e3

Browse files
committed
Add cpplint plugin.
Signed-off-by: Eric Wang <skygragon@gmail.com>
1 parent d948cf5 commit 282f3e3

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

company.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
var Plugin = require('../plugin');
22

3-
// config: None
3+
// [prerequisite]
4+
//
5+
// [config]
6+
//
47
var plugin = new Plugin(100, 'company', '2017.07.25',
58
'Plugin to query by company for free user.');
69

cpplint.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
var cp = require('child_process');
2+
3+
var log = require('../log');
4+
var Plugin = require('../plugin');
5+
6+
// [prerequisite]
7+
//
8+
// Need install cpplint:
9+
// https://raw.githubusercontent.com/google/styleguide/gh-pages/cpplint/cpplint.py
10+
//
11+
// [config]
12+
//
13+
// You can disable/enable some checks in "flags" section.
14+
//
15+
// "PLUGINS": {
16+
// "cpplint": {
17+
// "bin": "<path of cpplint script>",
18+
// "flags": [
19+
// "-whitespace/indent",
20+
// <other flags>
21+
// ]
22+
// }
23+
// }
24+
var plugin = new Plugin(100, 'cpplint', '2017.07.25',
25+
'Plugin to do static code check on c++ code.');
26+
27+
var DEFAULT_FLAGS = [
28+
'-legal/copyright',
29+
'-build/include_what_you_use'
30+
];
31+
32+
plugin.testProblem = function(problem, cb) {
33+
var flags = DEFAULT_FLAGS.concat(plugin.config.flags || []);
34+
35+
var cmd = [
36+
plugin.config.bin,
37+
'--filter=' + flags.join(','),
38+
problem.file
39+
].join(' ');
40+
41+
log.info('\nRunning cpplint ...');
42+
log.debug(cmd);
43+
log.info();
44+
45+
cp.exec(cmd, function(e, stdout, stderr) {
46+
if (e) {
47+
stderr.split('\n').forEach(function(line) {
48+
if (line.length > 0) log.error(line);
49+
});
50+
} else {
51+
plugin.next.testProblem(problem, cb);
52+
}
53+
});
54+
};
55+
56+
module.exports = plugin;

0 commit comments

Comments
 (0)