public Results analyze ( RuleSet ruleSet ) { long startTime = System . currentTimeMillis ( ) ; DirectoryResults reportResults = new DirectoryResults ( ) ; int numThreads = Runtime . getRuntime ( ) . availableProcessors ( ) - 1 ; numThreads = numThreads > 0 ? numThreads : 1 ; ExecutorService pool = Executors . newFixedThreadPool ( numThreads ) ; for ( FileSet fileSet : fileSets ) { processFileSet ( fileSet , ruleSet , pool ) ; } pool . shutdown ( ) ; try { boolean completed = pool . awaitTermination ( POOL_TIMEOUT_SECONDS , TimeUnit . SECONDS ) ; if ( ! completed ) { throw new IllegalStateException ( "Thread Pool terminated before comp<FileResults>letion" ) ; } } catch ( InterruptedException e ) { throw new IllegalStateException ( "Thread Pool interrupted before completion" ) ; } addDirectoryResults ( reportResults ) ; LOG . info ( "Analysis time=" + ( System . currentTimeMillis ( ) - startTime ) + "ms" ) ; return reportResults ; }
Analyze all source code using the specified RuleSet and return the report results .