"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/java/edu/umd/cs/findbugs/DetectorFactoryCollection.java" between
findbugs-3.0.0-source.zip and findbugs-3.0.1-source.zip

About: FindBugs uses static analysis to look for bugs in Java code. Source.

DetectorFactoryCollection.java  (findbugs-3.0.0-source):DetectorFactoryCollection.java  (findbugs-3.0.1-source)
skipping to change at line 253 skipping to change at line 253
} }
/** /**
* Return an Iterable over the DetectorFactory objects for all registered * Return an Iterable over the DetectorFactory objects for all registered
* Detectors. * Detectors.
*/ */
public Iterable<DetectorFactory> getFactories() { public Iterable<DetectorFactory> getFactories() {
return factoryList; return factoryList;
} }
public boolean isDisabledByDefault(String bugPatternOrCode) {
@CheckForNull BugPattern pattern = lookupBugPattern(bugPatternOrCode);
if (pattern != null) {
for(DetectorFactory fac : factoryList) {
if (fac.isDefaultEnabled() && fac.getReportedBugPatterns().cont
ains(pattern)) {
return false;
}
}
return true;
}
@CheckForNull BugCode code = lookupBugCode(bugPatternOrCode);
if (code != null) {
for(DetectorFactory fac : factoryList) {
if (fac.isDefaultEnabled()) {
for(BugPattern p : fac.getReportedBugPatterns()) {
if (p.getBugCode().equals(code)) {
return false;
}
}
}
}
return true;
}
return false;
}
/** /**
* Look up a DetectorFactory by its short name. * Look up a DetectorFactory by its short name.
* *
* @param name * @param name
* the short name * the short name
* @return the DetectorFactory, or null if there is no factory with that * @return the DetectorFactory, or null if there is no factory with that
* short name * short name
*/ */
public DetectorFactory getFactory(String name) { public DetectorFactory getFactory(String name) {
return factoriesByName.get(name); return factoriesByName.get(name);
skipping to change at line 320 skipping to change at line 347
*/ */
private static String inferFindBugsHome() { private static String inferFindBugsHome() {
Pattern[] findbugsJarNames = { Pattern.compile("findbugs\\.jar$"), }; Pattern[] findbugsJarNames = { Pattern.compile("findbugs\\.jar$"), };
for (Pattern jarNamePattern : findbugsJarNames) { for (Pattern jarNamePattern : findbugsJarNames) {
String findbugsJarCodeBase = ClassPathUtil.findCodeBaseInClassPath(j arNamePattern, String findbugsJarCodeBase = ClassPathUtil.findCodeBaseInClassPath(j arNamePattern,
SystemProperties.getProperty("java.class.path")); SystemProperties.getProperty("java.class.path"));
if (findbugsJarCodeBase != null) { if (findbugsJarCodeBase != null) {
File findbugsJar = new File(findbugsJarCodeBase); File findbugsJar = new File(findbugsJarCodeBase);
File libDir = findbugsJar.getParentFile(); File libDir = findbugsJar.getParentFile();
if (libDir.getName().equals("lib")) { if ("lib".equals(libDir.getName())) {
String fbHome = libDir.getParent(); String fbHome = libDir.getParent();
FindBugs.setHome(fbHome); FindBugs.setHome(fbHome);
return fbHome; return fbHome;
} }
} }
} }
String classFilePath = FindBugs.class.getName().replaceAll("\\.", "/") + ".class"; String classFilePath = FindBugs.class.getName().replaceAll("\\.", "/") + ".class";
URL resource = FindBugs.class.getClassLoader().getResource(classFilePath ); URL resource = FindBugs.class.getClassLoader().getResource(classFilePath );
if (resource != null && resource.getProtocol().equals("file")) { if (resource != null && "file".equals(resource.getProtocol())) {
try { try {
String classfile = URLDecoder.decode(resource.getPath(), Charset .defaultCharset().name()); String classfile = URLDecoder.decode(resource.getPath(), Charset .defaultCharset().name());
Matcher m = Pattern.compile("(.*)/.*?/edu/umd.*").matcher(classf ile); Matcher m = Pattern.compile("(.*)/.*?/edu/umd.*").matcher(classf ile);
if (m.matches()) { if (m.matches()) {
String home = m.group(1); String home = m.group(1);
if (new File(home + "/etc/findbugs.xml").exists()) { if (new File(home + "/etc/findbugs.xml").exists()) {
FindBugs.setHome(home); FindBugs.setHome(home);
return home; return home;
} }
} }
skipping to change at line 540 skipping to change at line 567
} }
/** /**
* Look up bug pattern. * Look up bug pattern.
* *
* @param bugType * @param bugType
* the bug type for the bug pattern * the bug type for the bug pattern
* @return the BugPattern, or null if it can't be found * @return the BugPattern, or null if it can't be found
*/ */
public @CheckForNull BugPattern lookupBugPattern(String bugType) { public @CheckForNull BugPattern lookupBugPattern(String bugType) {
if (bugType == null) {
return null;
}
return bugPatternMap.get(bugType); return bugPatternMap.get(bugType);
} }
public void registerBugCode(BugCode bugCode) { public void registerBugCode(BugCode bugCode) {
bugCodeMap.put(bugCode.getAbbrev(), bugCode); bugCodeMap.put(bugCode.getAbbrev(), bugCode);
} }
protected void unRegisterBugCode(BugCode bugCode) { protected void unRegisterBugCode(BugCode bugCode) {
bugCodeMap.remove(bugCode.getAbbrev()); bugCodeMap.remove(bugCode.getAbbrev());
} }
 End of changes. 4 change blocks. 
2 lines changed or deleted 33 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS