@Nonnull public BugCollectionBugReporter run(Path... files) { DetectorFactoryCollection.resetInstance(new DetectorFactoryCollection()); try (FindBugs2 engine = new FindBugs2(); Project project = createProject(files)) { engine.setProject(project); final DetectorFactoryCollection detectorFactoryCollection = DetectorFactoryCollection.instance(); engine.setDetectorFactoryCollection(detectorFactoryCollection); BugCollectionBugReporter bugReporter = new BugCollectionBugReporter(project); bugReporter.setPriorityThreshold(Priorities.LOW_PRIORITY); bugReporter.setRankThreshold(BugRanker.VISIBLE_RANK_MAX); engine.setBugReporter(bugReporter); final UserPreferences preferences = UserPreferences.createDefaultUserPreferences(); preferences.getFilterSettings().clearAllCategories(); preferences.enableAllDetectors(true); engine.setUserPreferences(preferences); try { engine.execute(); } catch (final IOException | InterruptedException e) { throw new AssertionError("Analysis failed with exception", e); } if (!bugReporter.getQueuedErrors().isEmpty()) { bugReporter.reportQueuedErrors(); throw new AssertionError( "Analysis failed with exception. Check stderr for detail."); } return bugReporter; } }
engine.execute();
@Override public Object call() { try { engine.execute(); return null; } catch (InterruptedException | IOException e) { throw Throwables.propagate(e); } finally { engine.dispose(); } } }
@Override public SpotBugsResult runSpotbugs(SpotBugsSpec spec) throws IOException, InterruptedException { final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); try { final List<String> args = spec.getArguments(); String[] strArray = args.toArray(new String[0]); Thread.currentThread().setContextClassLoader(FindBugs2.class.getClassLoader()); FindBugs2 findBugs2 = new FindBugs2(); TextUICommandLine commandLine = new TextUICommandLine(); FindBugs.processCommandLine(commandLine, strArray, findBugs2); findBugs2.execute(); return createSpotbugsResult(findBugs2); } finally { Thread.currentThread().setContextClassLoader(contextClassLoader); } }
@Override public void run() { final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); try { final List<String> args = spec.getArguments(); String[] strArray = args.toArray(new String[0]); Thread.currentThread().setContextClassLoader(FindBugs2.class.getClassLoader()); FindBugs2 findBugs2 = new FindBugs2(); TextUICommandLine commandLine = new TextUICommandLine(); FindBugs.processCommandLine(commandLine, strArray, findBugs2); findBugs2.execute(); SpotBugsResult result = createSpotbugsResult(findBugs2); evaluateResult(result); } catch (IOException | InterruptedException e) { throw new GradleException("Error initializing SpotBugsRunner", e); } finally { Thread.currentThread().setContextClassLoader(contextClassLoader); } }
public FindBugsResult analyze() { final Project project = createProject(); final BugCollectionBugReporter bugReporter = createReporter(project); final FindBugs2 findBugs = createFindBugs(project, bugReporter); try { findBugs.execute(); } catch (IOException | InterruptedException e) { throw new AnalyzerException("Problem executing FindBugs.", e); } return createBugList(bugReporter); }
public FindBugsResult analyze() { final Project project = createProject(); final BugCollectionBugReporter bugReporter = createReporter(project); final FindBugs2 findBugs = createFindBugs(project, bugReporter); try { findBugs.execute(); } catch (IOException | InterruptedException e) { throw new AnalyzerException("Problem executing FindBugs.", e); } return createBugList(bugReporter); }
findbugs.addFilter(args[Tv.FOUR], false); findbugs.execute(); } catch (final IOException | InterruptedException ex) { throw new IllegalStateException(ex);
findbugs.addFilter(args[Tv.FOUR], false); findbugs.execute(); } catch (final IOException | InterruptedException ex) { throw new IllegalStateException(ex);