/** * Constructor. Creates an empty object given an existing ProjectStats. * * @param projectStats * the ProjectStats * @param comparator * to use for sorting bug instances */ public SortedBugCollection(ProjectStats projectStats, Comparator<BugInstance> comparator) { this(projectStats, comparator, new Project()); }
/** * Return an exact copy of this Project. */ public Project duplicate() { Project dup = new Project(); dup.currentWorkingDirectoryList.addAll(this.currentWorkingDirectoryList); dup.projectName = this.projectName; dup.analysisTargets.addAll(this.analysisTargets); dup.srcDirList.addAll(this.srcDirList); dup.auxClasspathEntryList.addAll(this.auxClasspathEntryList); dup.timestampForAnalyzedClasses = timestampForAnalyzedClasses; dup.guiCallback = guiCallback; return dup; }
@SuppressFBWarnings("DM_EXIT") public static void main(String[] args) throws Exception { if (args.length != 2) { System.err.println("Usage: " + AddMessages.class.getName() + " <input collection> <output collection>"); System.exit(1); } // Load plugins, in order to get message files DetectorFactoryCollection.instance(); String inputFile = args[0]; String outputFile = args[1]; Project project = new Project(); SortedBugCollection inputCollection = new SortedBugCollection(project); inputCollection.readXML(inputFile); Document document = inputCollection.toDocument(); AddMessages addMessages = new AddMessages(inputCollection, document); addMessages.execute(); XMLWriter writer = new XMLWriter(new BufferedOutputStream(new FileOutputStream(outputFile)), OutputFormat.createPrettyPrint()); writer.write(document); writer.close(); } }
@CheckReturnValue private Project createProject(Path[] files) { final Project project = new Project(); project.setProjectName(getClass().getSimpleName()); if (PLUGIN_JAR != null) { try { String pluginId = Plugin.addCustomPlugin(PLUGIN_JAR.toURI()).getPluginId(); project.setPluginStatusTrinary(pluginId, Boolean.TRUE); } catch (PluginException e) { throw new AssertionError("Failed to load plugin", e); } } for (Path file : files) { project.addFile(file.toAbsolutePath().toString()); } for (Path auxClasspathEntry : auxClasspathEntries) { project.addAuxClasspathEntry(auxClasspathEntry.toAbsolutePath().toString()); } return project; }
public static Project readXML(File f) throws IOException, SAXException { @SuppressWarnings("resource") // will be closed by caller Project project = new Project(); try (InputStream in = new BufferedInputStream(new FileInputStream(f))) { String tag = Util.getXMLType(in); SAXBugCollectionHandler handler; if ("Project".equals(tag)) { handler = new SAXBugCollectionHandler(project, f); } else if ("BugCollection".equals(tag)) { SortedBugCollection bugs = new SortedBugCollection(project); handler = new SAXBugCollectionHandler(bugs, f); } else { throw new IOException("Can't load a project from a " + tag + " file"); } XMLReader xr = XMLReaderFactory.createXMLReader(); xr.setContentHandler(handler); xr.setErrorHandler(handler); try (Reader reader = Util.getReader(in)) { xr.parse(new InputSource(reader)); } } catch (IOException | SAXException e) { project.close(); throw e; } // Presumably, project is now up-to-date project.setModified(false); return project; }
/** * @param baseline * @throws IOException * @throws DocumentException */ public static void addToExcludedInstanceHashes(Set<String> instanceHashesToExclude, String baseline) throws IOException, DocumentException { Project project = new Project(); BugCollection origCollection; origCollection = new SortedBugCollection(project); origCollection.readXML(baseline); for (BugInstance b : origCollection.getCollection()) { instanceHashesToExclude.add(b.getInstanceHash()); } }
public static void xslt(String stylesheet, boolean applySuppression, String[] args, int argCount) throws Exception { Project proj = new Project(); HTMLBugReporter reporter = new HTMLBugReporter(proj, stylesheet); BugCollection bugCollection = reporter.getBugCollection(); bugCollection.setApplySuppressions(applySuppression); if (argCount < args.length) { bugCollection.readXML(args[argCount++]); } else { bugCollection.readXML(System.in); } if (argCount < args.length) { reporter.setOutputStream(UTF8.printStream(new FileOutputStream(args[argCount++]), true)); } reporter.finish(); Exception e = reporter.getFatalException(); if (e != null) { throw e; } }
public PrintingCommandLine() { project = new Project(); addSwitch("-longBugCodes", "use long bug codes when generating text"); addSwitch("-rank", "list rank when generating text"); addOption("-maxRank", "max rank", "only list bugs of this rank or less"); addOption("-summarizeMaxRank", "max rank", "summary bugs with of this rank or less"); addSwitch("-history", "report first and last versions for each bug"); addSwitch("-applySuppression", "exclude any bugs that match suppression filters"); addSwitchWithOptionalExtraPart("-html", "stylesheet", "Generate HTML output (default stylesheet is default.xsl)"); addOption("-pluginList", "jar1[" + File.pathSeparator + "jar2...]", "specify list of plugin Jar files to load"); addSwitch("-exitcode", "set exit code of process"); }
/** * Constructor. Adds shared options/switches. */ public FindBugsCommandLine() { super(); project = new Project(); startOptionGroup("General FindBugs options:"); addOption("-project", "project", "analyze given project"); addOption("-home", "home directory", "specify SpotBugs home directory"); addOption("-pluginList", "jar1[" + File.pathSeparator + "jar2...]", "specify list of plugin Jar files to load"); addSwitchWithOptionalExtraPart("-effort", "min|less|default|more|max", "set analysis effort level"); addSwitch("-adjustExperimental", "lower priority of experimental Bug Patterns"); addSwitch("-workHard", "ensure analysis effort is at least 'default'"); addSwitch("-conserveSpace", "same as -effort:min (for backward compatibility)"); }
Project project = new Project(); project.setProjectName("spotbugsTestCases"); this.engine.setProject(project);
Project project = new Project(); project.setProjectName("automate-test-project"); for (String file : classFiles) {
Project project = new Project(); project.addFile(tmpdir.getAbsolutePath());
/** * Constructor. Creates an empty object given an existing ProjectStats. * * @param projectStats * the ProjectStats * @param comparator * to use for sorting bug instances */ public SortedBugCollection(ProjectStats projectStats, Comparator<BugInstance> comparator) { this(projectStats, comparator, new Project()); }
public synchronized @Nonnull Project getProject() { if (curProject == null) { curProject = new Project(); } return curProject; }
@Override public void run() { final SourceDirectoryWizard dialog = new SourceDirectoryWizard(new javax.swing.JFrame(), true, new Project(), null); dialog.setVisible(true); } });
private Project createProject() { final Project project = new Project(); PluginLoader.addPluginsTo(project); for (final AnalyzerConfig.Path clazz : config.getClassPaths()) { project.addFile(clazz.getPath()); } project.addSourceDirs(config.getSourcePaths().stream().map(AnalyzerConfig.Path::getPath).collect(toList())); final String pathSeparator = System.getProperty("path.separator"); final String classPath = System.getProperty("java.class.path"); for (final String entry : classPath.split(pathSeparator)) { project.addAuxClasspathEntry(entry); } return project; }
/** * @param baseline * @throws IOException * @throws DocumentException */ public static void addToExcludedInstanceHashes(Set<String> instanceHashesToExclude, String baseline) throws IOException, DocumentException { Project project = new Project(); BugCollection origCollection; origCollection = new SortedBugCollection(project); origCollection.readXML(baseline); for (BugInstance b : origCollection.getCollection()) { instanceHashesToExclude.add(b.getInstanceHash()); } }
static SortedBugCollection createPreconfiguredBugCollection(List<String> workingDirList, List<String> srcDirList, IGuiCallback guiCallback) { Project project = new Project(); for (String cwd : workingDirList) { project.addWorkingDir(cwd); } for (String srcDir : srcDirList) { project.addSourceDir(srcDir); } project.setGuiCallback(guiCallback); return new SortedBugCollection(project); }
/** * Constructor. Adds shared options/switches. */ public FindBugsCommandLine() { super(); project = new Project(); startOptionGroup("General FindBugs options:"); addOption("-project", "project", "analyze given project"); addOption("-home", "home directory", "specify FindBugs home directory"); addOption("-pluginList", "jar1[" + File.pathSeparator + "jar2...]", "specify list of plugin Jar files to load"); addSwitchWithOptionalExtraPart("-effort", "min|less|default|more|max", "set analysis effort level"); addSwitch("-adjustExperimental", "lower priority of experimental Bug Patterns"); addSwitch("-workHard", "ensure analysis effort is at least 'default'"); addSwitch("-conserveSpace", "same as -effort:min (for backward compatibility)"); }
public PrintingCommandLine() { project = new Project(); addSwitch("-longBugCodes", "use long bug codes when generating text"); addSwitch("-rank", "list rank when generating text"); addOption("-maxRank", "max rank", "only list bugs of this rank or less"); addOption("-summarizeMaxRank", "max rank", "summary bugs with of this rank or less"); addSwitch("-designations", "report user designations for each bug"); addSwitch("-history", "report first and last versions for each bug"); addSwitch("-applySuppression", "exclude any bugs that match suppression filters"); addSwitch("-annotationUpload", "generate annotations in upload format"); addSwitchWithOptionalExtraPart("-html", "stylesheet", "Generate HTML output (default stylesheet is default.xsl)"); addOption("-pluginList", "jar1[" + File.pathSeparator + "jar2...]", "specify list of plugin Jar files to load"); addSwitch("-exitcode", "set exit code of process"); }