11class StaticAnalysis {
2- constructor ( dataProvider , process ) {
2+ constructor ( dataProvider , process , ignoredAccounts = [ ] ) {
33 this . dataProvider = dataProvider ;
44 this . process = process ;
5+ this . ignoredAccounts = ignoredAccounts ;
56 }
67
78 isCommitHash ( ref ) {
@@ -25,11 +26,15 @@ class StaticAnalysis {
2526
2627 scanFile ( filePath ) {
2728 const content = this . dataProvider . readFile ( filePath ) ;
28- const regex = / u s e s : \s * [ \w - ] + \/ [ \w - ] + @ ( [ \w - . ] + ) / g;
29+ const regex = / u s e s : \s * ( [ \w - ] + \/ [ \w - ] + ) @ ( [ \w - . ] + ) / g;
2930 let match ;
3031 let warnings = [ ] ;
3132 while ( ( match = regex . exec ( content ) ) !== null ) {
32- const ref = match [ 1 ] ;
33+ const ref = match [ 2 ] ;
34+ const account = match [ 1 ] . split ( '/' ) [ 0 ] ;
35+ if ( this . ignoredAccounts . includes ( account ) ) {
36+ continue ;
37+ }
3338 if ( ! this . isCommitHash ( ref ) ) {
3439 warnings . push ( `Warning: In file ${ filePath } , '${ match [ 0 ] } ' does not use a commit hash.` ) ;
3540 }
@@ -90,7 +95,8 @@ class DataProvider {
9095const fs = require ( 'fs' ) ;
9196const path = require ( 'path' ) ;
9297const process = require ( 'process' ) ;
98+ const ignoredAccounts = ( process . env . IGNORED_ACCOUNTS || '' ) . split ( ',' ) ;
9399
94100const dataProvider = new DataProvider ( fs , path ) ;
95- const staticAnalysis = new StaticAnalysis ( dataProvider , process ) ;
101+ const staticAnalysis = new StaticAnalysis ( dataProvider , process , ignoredAccounts ) ;
96102staticAnalysis . run ( ) ;
0 commit comments