public static void main(String[] args) throws Exception { // Sanity-check the loaded BCEL classes if (!CheckBcel.check()) { System.exit(1); } // Create FindBugs2 engine try (FindBugs2 findBugs = new FindBugs2()) { // Parse command line and configure the engine TextUICommandLine commandLine = new TextUICommandLine(); FindBugs.processCommandLine(commandLine, args, findBugs); boolean justPrintConfiguration = commandLine.justPrintConfiguration(); if (justPrintConfiguration || commandLine.justPrintVersion()) { Version.printVersion(justPrintConfiguration); return; } // Away we go! FindBugs.runMain(findBugs, commandLine); } }
@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; } }
this.engine = new FindBugs2(); Project project = new Project(); project.setProjectName("spotbugsTestCases");
FindBugs2 engine = new FindBugs2(); engine.setNoClassOk(true); engine.setMergeSimilarWarnings(false);
FindBugs2 engine = new FindBugs2();
@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); } }
/** * Create the IFindBugsEngine that will be used to analyze the application. * * @param p * the Project * @param pcb * the PrintCallBack * @return the IFindBugsEngine */ private static IFindBugsEngine createEngine(@Nonnull Project p, BugReporter pcb) { FindBugs2 engine = new FindBugs2(); engine.setBugReporter(pcb); engine.setProject(p); engine.setDetectorFactoryCollection(DetectorFactoryCollection.instance()); // // Honor -effort option if one was given on the command line. // engine.setAnalysisFeatureSettings(Driver.getAnalysisSettingList()); return engine; }
private FindBugs2 createFindBugs(Project project, BugCollectionBugReporter bugReporter) { final FindBugs2 findBugs = new FindBugs2(); findBugs.setProject(project); findBugs.setBugReporter(bugReporter); findBugs.setDetectorFactoryCollection(DetectorFactoryCollection.instance()); findBugs.setUserPreferences(UserPreferences.createDefaultUserPreferences()); return findBugs; }
private FindBugs2 createFindBugs(Project project, BugCollectionBugReporter bugReporter) { final FindBugs2 findBugs = new FindBugs2(); findBugs.setProject(project); findBugs.setBugReporter(bugReporter); findBugs.setDetectorFactoryCollection(DetectorFactoryCollection.instance()); findBugs.setUserPreferences(UserPreferences.createDefaultUserPreferences()); return findBugs; }
ExecutorService executorService = Executors.newSingleThreadExecutor(); try { final FindBugs2 engine = new FindBugs2();
public static void main(String[] args) throws Exception { // Sanity-check the loaded BCEL classes if (!CheckBcel.check()) { System.exit(1); } // Create FindBugs2 engine FindBugs2 findBugs = new FindBugs2(); // Parse command line and configure the engine TextUICommandLine commandLine = new TextUICommandLine(); FindBugs.processCommandLine(commandLine, args, findBugs); boolean justPrintConfiguration = commandLine.justPrintConfiguration(); if (justPrintConfiguration || commandLine.justPrintVersion()) { Version.printVersion(justPrintConfiguration); return; } // Away we go! FindBugs.runMain(findBugs, commandLine); }
throw new IllegalStateException(ex); final FindBugs2 findbugs = new FindBugs2(); findbugs.setProject(project); final Collection<String> ignored = Collections2.transform(
throw new IllegalStateException(ex); final FindBugs2 findbugs = new FindBugs2(); findbugs.setProject(project); final Collection<String> ignored = Collections2.transform(