// Command-line parameters
String m_dbName; // db name
File m_fbp; // FindBugsProject file
+ File m_fbDir; // Directory where FindBugs is installed
String m_host; // db host
int m_port; // db port
String m_user; // db user
m_bundle = CfbBundle.getInst(m_locale);
m_dbName = "CFB";
- m_fbp = null;
+ m_fbp = null;
+ m_fbDir = null;
m_host = "localhost";
m_port = 5432;
m_pass = "";
return m_bundle.get(key);
}
+ String getenv(String varName) {
+ // This is a separate function so that we can override it at unit test time
+ return System.getenv(varName);
+ }
+
+ String getProperty(String propName) {
+ // This is a separate function so that we can override it at unit test time
+ return System.getProperty(propName);
+ }
+
+ void initArgs() {
+ String findBugsDir = getenv("FINDBUGS_HOME");
+ if (null != findBugsDir) {
+ m_fbDir = new File(findBugsDir);
+ }
+ findBugsDir = getProperty("findbugs.home");
+ if (null != findBugsDir) {
+ m_fbDir = new File(findBugsDir);
+ }
+ }
+
void doMain(PrintWriter pw, String[] args) throws SQLException, IOException {
+ initArgs(); // read environment and system properties
if ( ! parseArgs(pw, args) ) {
return;
}
return;
}
- File findBugsDir = new File(".");
+ File findBugsDir = (null != m_fbDir) ? m_fbDir : new File(".");
File workDir = new File(".");
Analyzer analyzer = new Analyzer(findBugsDir);
- Analysis analysis = analyzer.analyze(workDir, m_fbp);
+ Analysis analysis = analyzer.analyze(pw, workDir, m_fbp);
+ if (null != analysis) {
+ // TODO
+ }
}
public static void main(String[] args) {
try (PrintWriter pw = new PrintWriter(System.out)){
cfb.doMain(pw, args);
+ pw.flush();
} catch (SQLException | IOException exc) {
exc.printStackTrace();
}