11var readline = require ( 'readline' ) ;
22var spawn = require ( 'child_process' ) . spawn ;
3+ var fs = require ( 'fs' ) ;
34
45var DEFAULT_PATHS = [ './' ] ;
56var DEFAULT_STRINGS = [ 'BUG' , 'FIXME' , 'HACK' , 'TODO' , 'XXX' ] ;
@@ -35,6 +36,15 @@ FixMe.prototype.run = function(engineConfig) {
3536 this . find ( paths , strings ) ;
3637} ;
3738
39+ var isItsOwnConfig = function ( path , lineNumber ) {
40+ if ( path . indexOf ( ".codeclimate.yml" ) === - 1 ) { return false ; }
41+ var lines = fs . readFileSync ( path , "utf8" ) . split ( "\n" ) ;
42+ var line = lines [ lineNumber - 1 ] ;
43+ if ( ! line ) { return false ; }
44+ if ( line . match ( / ^ \s * # / ) ) { return false ; }
45+ return true ;
46+ } ;
47+
3848FixMe . prototype . find = function ( paths , strings , callback ) {
3949 var pattern = `(${ strings . join ( '|' ) } )` ;
4050 var grep = spawn ( 'grep' , [ ...GREP_OPTIONS , pattern , ...paths ] ) ;
@@ -50,7 +60,7 @@ FixMe.prototype.find = function(paths, strings, callback) {
5060 return ;
5161 }
5262
53- if ( path . indexOf ( '.codeclimate.yml' ) !== - 1 ) { return ; }
63+ if ( isItsOwnConfig ( path , lineNumber ) ) { return ; }
5464
5565 var issue = {
5666 'categories' : [ 'Bug Risk' ] ,
0 commit comments