@ SuppressFBWarnings ( "DM_EXIT" ) public static void runMain ( IFindBugsEngine findBugs , TextUICommandLine commandLine ) throws IOException { boolean verbose = ! commandLine . quiet ( ) ; try { findBugs . execute ( ) ; } catch ( InterruptedException e ) { assert false ; // should not occur checkExitCodeFail ( commandLine , e ) ; throw new RuntimeException ( e ) ; } catch ( RuntimeException | IOException e ) { checkExitCodeFail ( commandLine , e ) ; throw e ; } int bugCount = findBugs . getBugCount ( ) ; int missingClassCount = findBugs . getMissingClassCount ( ) ; int errorCount = findBugs . getErrorCount ( ) ; if ( verbose || commandLine . setExitCode ( ) ) { LOG . log ( FINE , "Warnings generated: {0}" , bugCount ) ; LOG . log ( FINE , "Missing classes: {0}" , missingClassCount ) ; LOG . log ( FINE , "Analysis errors: {0}" , errorCount ) ; } if ( commandLine . setExitCode ( ) ) { int exitCode = 0 ; LOG . info ( "Calculating exit code..." ) ; if ( errorCount > 0 ) { exitCode |= ExitCodes . ERROR_FLAG ; LOG . log ( FINE , "Setting 'errors encountered' flag ({0})" , ExitCodes . ERROR_FLAG ) ; } if ( missingClassCount > 0 ) { exitCode |= ExitCodes . MISSING_CLASS_FLAG ; LOG . log ( FINE , "Setting 'missing class' flag ({0})" , ExitCodes . MISSING_CLASS_FLAG ) ; } if ( bugCount > 0 ) { exitCode |= ExitCodes . BUGS_FOUND_FLAG ; LOG . log ( FINE , "Setting 'bugs found' flag ({0})" , ExitCodes . BUGS_FOUND_FLAG ) ; } LOG . log ( FINE , "Exit code set to: {0}" , exitCode ) ; System . exit ( exitCode ) ; } }
Given a fully - configured IFindBugsEngine and the TextUICommandLine used to configure it execute the analysis .