1
1
var glob = require ( 'glob' ) ;
2
- var exec = require ( 'child_process' ) . exec ;
2
+ var exec = require ( 'child_process' ) . execSync ;
3
3
var fs = require ( 'fs' ) ;
4
4
5
5
module . exports = FixMe ;
6
6
function FixMe ( ) { }
7
7
8
8
// Strings to scan for in source
9
- var fixmeStrings = "'FIXME|TODO|HACK|XXX|BUG'" ;
9
+ var fixmeStrings = "'( FIXME|TODO|HACK|XXX|BUG)|?: '" ;
10
10
11
11
// Prints properly structured Issue data to STDOUT according to
12
12
// Code Climate Engine specification.
@@ -32,29 +32,29 @@ var printIssue = function(fileName, lineNum, matchedString){
32
32
33
33
var findFixmes = function ( file ) {
34
34
// Prepare the grep string for execution (uses BusyBox grep)
35
- var grepString = "grep -inwHoE " + fixmeStrings + " " + file ;
35
+ var grepString = "grep -inHwoE " + fixmeStrings + " " + file ;
36
36
37
37
// Execute grep with the FIXME patterns
38
- exec ( grepString , function ( error , stdout , stderr ) {
38
+ var results = exec ( grepString ) ;
39
39
40
- // Parses grep output
41
- var lines = stdout . split ( "\n" ) ;
42
- lines . forEach ( function ( line , index , array ) {
40
+ // Parses grep output
41
+ var lines = results . toString ( ) . split ( "\n" ) ;
42
+
43
+ lines . forEach ( function ( line , index , array ) {
44
+ // grep spits out an extra line that we can ignore
45
+ if ( index < ( array . length - 1 ) ) {
46
+
47
+ var cols = line . split ( ":" ) ;
43
48
44
- // grep spits out an extra line that we can ignore
45
- if ( index < ( array . length - 1 ) ) {
46
-
47
- var cols = line . split ( ":" ) ;
49
+ // Remove remnants of container paths for external display
50
+ var fileName = cols [ 0 ] . split ( "/code/" ) [ 1 ] ;
51
+ var lineNum = cols [ 1 ] ;
52
+ var matchedString = cols [ 2 ] ;
48
53
49
- // Remove remnants of container paths for external display
50
- var fileName = cols [ 0 ] . split ( "/code/" ) [ 1 ] ;
51
- var lineNum = cols [ 1 ] ;
52
- var matchedString = cols [ 2 ] ;
53
-
54
- printIssue ( fileName , lineNum , matchedString ) ;
55
- }
56
- } )
54
+ printIssue ( fileName , lineNum , matchedString ) ;
55
+ }
57
56
} )
57
+
58
58
}
59
59
60
60
// Uses glob to traverse code directory and find files to analyze,
@@ -65,7 +65,9 @@ var fileWalk = function(excludePaths){
65
65
66
66
allFiles . forEach ( function ( file , i , a ) {
67
67
if ( excludePaths . indexOf ( file . split ( "/code/" ) [ 1 ] ) < 0 ) {
68
- analysisFiles . push ( file ) ;
68
+ if ( ! fs . lstatSync ( file ) . isDirectory ( ) ) {
69
+ analysisFiles . push ( file ) ;
70
+ }
69
71
}
70
72
} ) ;
71
73
0 commit comments