protected BugCollection getBugCollection() { return bugReporter.getBugCollection(); }
/** * <p> * Run SpotBugs under given condition, and return its result. * </p> * @param paths * Paths of target class files * @return a {@link BugCollection} which contains all detected bugs. */ // TODO let users specify SlashedClassName, then find its file path automatically @Nonnull public BugCollection performAnalysis(Path... paths) { if (runner == null) { throw new IllegalStateException("Please call this performAnalysis() method in test method"); } return runner.run(paths).getBugCollection(); } }
/** * <p> * Run SpotBugs under given condition, and return its result. * </p> * @param paths * Paths of target class files * @return a {@link BugCollection} which contains all detected bugs. */ // TODO let users specify SlashedClassName, then find its file path automatically @Nonnull public BugCollection performAnalysis(Path... paths) { if (runner == null) { throw new IllegalStateException("Please call this performAnalysis() method in test method"); } return runner.run(paths).getBugCollection(); } }
@After public void checkForUnexpectedBugs() { List<BugInstance> unexpectedBugs = new ArrayList<>(); for (BugInstance bug : bugReporter.getBugCollection()) { if (isUnexpectedBug(bug) && bug.getPriority() == Priorities.HIGH_PRIORITY) { unexpectedBugs.add(bug); System.out.println(bug.getMessageWithPriorityTypeAbbreviation()); System.out.println(" " + bug.getPrimarySourceLineAnnotation()); } } if (!unexpectedBugs.isEmpty()) { Assert.fail("Unexpected bugs (" + unexpectedBugs.size() + "):" + getBugsLocations(unexpectedBugs)); } }
/** * Test for expected warnings on ecj compiler (Eclipse) generated classes * Right now this test does nothing if Eclipse UI were not used to compile project. * The main purpose is for developers hacking in Eclipse to see if there are any unexpected * failures with Eclipse generated bytecode. It would be nice to make the test explicit by using * ecj command line compiler and *always* validate both bytecode kinds. */ @Test public void testAllRegressionFilesEcj() throws IOException, InterruptedException { setUpEngine("classesEclipse/"); engine.execute(); // If there are zero bugs, then something's wrong if (bugReporter.getBugCollection().getCollection().isEmpty()) { // TODO better to add ecj compiler and to compile classes with it on build, not with UI. System.err.println("No bugs were reported. Probably Eclipse was not used to compile the project"); } }
/** * Test for expected warnings on javac compiler generated classes */ @Test public void testAllRegressionFilesJavac() throws IOException, InterruptedException { setUpEngine("build/classes/java/main/"); engine.execute(); // If there are zero bugs, then something's wrong assertFalse("No bugs were reported. Something is wrong with the configuration", bugReporter.getBugCollection() .getCollection().isEmpty()); }
/** * <p> * Run SpotBugs under given condition, and return its result. * </p> * @param paths * Paths of target class files * @return a {@link BugCollection} which contains all detected bugs. */ // TODO let users specify SlashedClassName, then find its file path automatically @Nonnull public BugCollection performAnalysis(Path... paths) { if (runner == null) { throw new IllegalStateException("Please call this performAnalysis() method in test method"); } return runner.run(paths).getBugCollection(); } }
private FindBugsResult createBugList(BugCollectionBugReporter bugReporter) { final UsageCounter counter = new UsageCounter(); final List<BugInstance> bugs = bugReporter.getBugCollection().getCollection().stream() .filter(b -> counter.accept(collector.accept(b))) .sorted(BUG_COMPARATOR) .collect(toList()); collector.printUnusedWarning(counter); return new FindBugsResult(this, bugs, collector.unusedActions(counter)); } }
private FindBugsResult createBugList(BugCollectionBugReporter bugReporter) { final UsageCounter counter = new UsageCounter(); final List<BugInstance> bugs = bugReporter.getBugCollection().getCollection().stream() .filter(b -> counter.accept(collector.accept(b))) .sorted(BUG_COMPARATOR) .collect(toList()); collector.printUnusedWarning(counter); return new FindBugsResult(this, bugs, collector.unusedActions(counter)); } }