1
- var glob = require ( 'glob' ) ;
2
- var spawn = require ( 'child_process' ) . spawn ;
3
1
var fs = require ( 'fs' ) ;
2
+ var glob = require ( 'glob' ) ;
4
3
var path = require ( 'path' ) ;
5
4
var readline = require ( 'readline' ) ;
5
+ var spawn = require ( 'child_process' ) . spawn ;
6
6
7
- module . exports = FixMe ;
8
-
9
- function FixMe ( ) { }
7
+ function FixMe ( ) { }
10
8
11
- FixMe . prototype . runEngine = function ( ) {
12
- var analysisFiles = [ ] ,
13
- config = {
14
- include_paths : [ "./" ] ,
15
- strings : [ "FIXME" , "TODO" , "HACK" , "XXX" , "BUG" ]
16
- } ,
17
- self = this ;
9
+ FixMe . prototype . runEngine = function ( ) {
10
+ var analysisFiles = [ ] ;
11
+ var config = {
12
+ include_paths : [ './' ] ,
13
+ strings : [ 'FIXME' , 'TODO' , 'HACK' , 'XXX' , 'BUG' ]
14
+ } ;
18
15
19
16
if ( fs . existsSync ( '/config.json' ) ) {
20
17
var userConfig = JSON . parse ( fs . readFileSync ( '/config.json' ) ) ;
@@ -28,37 +25,38 @@ FixMe.prototype.runEngine = function(){
28
25
}
29
26
}
30
27
31
- self . find ( config . include_paths , config . strings ) ;
28
+ this . find ( config . include_paths , config . strings ) ;
32
29
}
33
30
34
- FixMe . prototype . find = function ( files , strings ) {
31
+ FixMe . prototype . find = function ( files , strings ) {
35
32
var fixmeStrings = '(' + strings . join ( '|' ) + ')' ;
36
33
var grep = spawn ( 'grep' , [ '-nHwoEr' , fixmeStrings ] . concat ( files ) ) ;
37
- var output = "" ;
38
- var self = this ;
34
+ var output = '' ;
39
35
40
36
readline . createInterface ( { input : grep . stdout } ) . on ( 'line' , function ( line ) {
41
- var cols = line . split ( ":" ) ;
37
+ var cols = line . split ( ':' ) ;
42
38
var fileName = cols [ 0 ] . replace ( / ^ \/ c o d e \/ / , '' ) ;
43
39
var lineNum = parseInt ( cols [ 1 ] ) ;
44
40
var matchedString = cols [ 2 ] ;
45
41
46
42
if ( matchedString !== undefined ) {
47
43
var issue = JSON . stringify ( {
48
- " type" : " issue" ,
49
- " check_name" : matchedString ,
50
- " description" : matchedString + " found" ,
51
- " categories" : [ " Bug Risk" ] ,
52
- " location" :{
53
- " path" : fileName ,
54
- " lines" : {
55
- " begin" : lineNum ,
56
- " end" : lineNum
44
+ ' type' : ' issue' ,
45
+ ' check_name' : matchedString ,
46
+ ' description' : matchedString + ' found' ,
47
+ ' categories' : [ ' Bug Risk' ] ,
48
+ ' location' :{
49
+ ' path' : fileName ,
50
+ ' lines' : {
51
+ ' begin' : lineNum ,
52
+ ' end' : lineNum
57
53
}
58
54
}
59
55
} ) ;
60
56
61
- console . log ( issue + '\0' ) ;
57
+ console . log ( issue + '\0' ) ;
62
58
}
63
59
} ) ;
64
60
}
61
+
62
+ module . exports = FixMe ;
0 commit comments