/** * Get set of all BugPatterns this detector reports. An empty set means that * we don't know what kind of bug patterns might be reported. */ public Set<BugPattern> getReportedBugPatterns() { Set<BugPattern> result = new TreeSet<>(); StringTokenizer tok = new StringTokenizer(reports, ","); while (tok.hasMoreTokens()) { String type = tok.nextToken(); BugPattern bugPattern = DetectorFactoryCollection.instance().lookupBugPattern(type); if (bugPattern != null) { result.add(bugPattern); } } return result; }
public @Nonnull String getShortMessageWithoutCode(String key) { BugPattern bugPattern = DetectorFactoryCollection.instance().lookupBugPattern(key); if (bugPattern == null) { return L10N.getLocalString("err.missing_pattern", "Error: missing bug pattern for key") + " " + key; } return bugPattern.getShortDescription(); }
/** * Get the BugPattern. */ public @Nonnull BugPattern getBugPattern() { BugPattern result = DetectorFactoryCollection.instance().lookupBugPattern(getType()); if (result != null) { return result; } AnalysisContext.logError("Unable to find description of bug pattern " + getType()); result = DetectorFactoryCollection.instance().lookupBugPattern("UNKNOWN"); if (result != null) { return result; } return BugPattern.REALLY_UNKNOWN; }
/** * Get an HTML document describing the bug pattern for given key in detail. * * @param key * which HTML details for retrieve */ public @Nonnull String getDetailHTML(String key) { BugPattern bugPattern = DetectorFactoryCollection.instance().lookupBugPattern(key); if (bugPattern == null) { return L10N.getLocalString("err.missing_pattern", "Error: missing bug pattern for key") + " " + key; } return bugPattern.getDetailHTML(); }
/** * Get a message string. This is a format pattern for describing an entire * bug instance in a single line. * * @param key * which message to retrieve * * */ @Deprecated public @Nonnull String getMessage(String key) { BugPattern bugPattern = DetectorFactoryCollection.instance().lookupBugPattern(key); if (bugPattern == null) { return L10N.getLocalString("err.missing_pattern", "Error: missing bug pattern for key") + " " + key; } return bugPattern.getAbbrev() + ": " + bugPattern.getLongDescription(); }
/** * Get a short message string. This is a concrete string (not a format * pattern) which briefly describes the type of bug, without mentioning * particular a particular class/method/field. * * @param key * which short message to retrieve */ public @Nonnull String getShortMessage(String key) { BugPattern bugPattern = DetectorFactoryCollection.instance().lookupBugPattern(key); if (bugPattern == null) { return L10N.getLocalString("err.missing_pattern", "Error: missing bug pattern for key") + " " + key; } return bugPattern.getAbbrev() + ": " + bugPattern.getShortDescription(); }
/** * Constructor. * * @param type * the bug type * @param priority * the bug priority */ public BugInstance(String type, int priority) { this.type = type.intern(); this.priority = priority; lastVersion = -1; annotationList = new ArrayList<>(4); cachedHashCode = INVALID_HASH_CODE; BugPattern p = DetectorFactoryCollection.instance().lookupBugPattern(type); if (p == null) { if ( missingBugTypes.add(type)) { String msg = "Can't find definition of bug type " + type; AnalysisContext.logError(msg, new NoSuchBugPattern(type)); } } else { this.priority += p.getPriorityAdjustment(); } if (adjustExperimental && isExperimental()) { this.priority = Priorities.EXP_PRIORITY; } boundPriority(); }
public boolean isDisabledByDefault(String bugPatternOrCode) { @CheckForNull BugPattern pattern = lookupBugPattern(bugPatternOrCode); if (pattern != null) { for(DetectorFactory fac : factoryList) { if (fac.isDefaultEnabled() && fac.getReportedBugPatterns().contains(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; }
BugPattern pattern = i18n.lookupBugPattern(adjustmentTarget); if (pattern == null) { throw new IllegalArgumentException("Unknown detector: " + adjustmentTarget);
private void addBugPatterns(Set<String> bugTypeSet) { Element root = document.getRootElement(); for (String bugType : bugTypeSet) { BugPattern bugPattern = DetectorFactoryCollection.instance().lookupBugPattern(bugType); if (bugPattern == null) { continue; } Element details = root.addElement("BugPattern"); details.addAttribute("type", bugType).addAttribute("abbrev", bugPattern.getAbbrev()) .addAttribute("category", bugPattern.getCategory()); details.addElement("ShortDescription").addText(bugPattern.getShortDescription()); details.addElement("Details").addCDATA(bugPattern.getDetailText()); } }
BugPattern bugPattern = DetectorFactoryCollection.instance().lookupBugPattern(bugType); if (bugPattern == null) { continue;
/** * Get set of all BugPatterns this detector reports. An empty set means that * we don't know what kind of bug patterns might be reported. */ public Set<BugPattern> getReportedBugPatterns() { Set<BugPattern> result = new TreeSet<BugPattern>(); StringTokenizer tok = new StringTokenizer(reports, ","); while (tok.hasMoreTokens()) { String type = tok.nextToken(); BugPattern bugPattern = DetectorFactoryCollection.instance().lookupBugPattern(type); if (bugPattern != null) { result.add(bugPattern); } } return result; }
public @Nonnull String getShortMessageWithoutCode(String key) { BugPattern bugPattern = DetectorFactoryCollection.instance().lookupBugPattern(key); if (bugPattern == null) { return L10N.getLocalString("err.missing_pattern", "Error: missing bug pattern for key") + " " + key; } return bugPattern.getShortDescription(); }
/** * Get the BugPattern. */ public @Nonnull BugPattern getBugPattern() { BugPattern result = DetectorFactoryCollection.instance().lookupBugPattern(getType()); if (result != null) { return result; } AnalysisContext.logError("Unable to find description of bug pattern " + getType()); result = DetectorFactoryCollection.instance().lookupBugPattern("UNKNOWN"); if (result != null) { return result; } return BugPattern.REALLY_UNKNOWN; }
/** * Get an HTML document describing the bug pattern for given key in detail. * * @param key * which HTML details for retrieve */ public @Nonnull String getDetailHTML(String key) { BugPattern bugPattern = DetectorFactoryCollection.instance().lookupBugPattern(key); if (bugPattern == null) { return L10N.getLocalString("err.missing_pattern", "Error: missing bug pattern for key") + " " + key; } return bugPattern.getDetailHTML(); }
/** * Get a message string. This is a format pattern for describing an entire * bug instance in a single line. * * @param key * which message to retrieve * * */ @Deprecated public @Nonnull String getMessage(String key) { BugPattern bugPattern = DetectorFactoryCollection.instance().lookupBugPattern(key); if (bugPattern == null) { return L10N.getLocalString("err.missing_pattern", "Error: missing bug pattern for key") + " " + key; } return bugPattern.getAbbrev() + ": " + bugPattern.getLongDescription(); }
/** * Get a short message string. This is a concrete string (not a format * pattern) which briefly describes the type of bug, without mentioning * particular a particular class/method/field. * * @param key * which short message to retrieve */ public @Nonnull String getShortMessage(String key) { BugPattern bugPattern = DetectorFactoryCollection.instance().lookupBugPattern(key); if (bugPattern == null) { return L10N.getLocalString("err.missing_pattern", "Error: missing bug pattern for key") + " " + key; } return bugPattern.getAbbrev() + ": " + bugPattern.getShortDescription(); }
/** * Constructor. * * @param type * the bug type * @param priority * the bug priority */ public BugInstance(String type, int priority) { this.type = type.intern(); this.priority = priority; lastVersion = -1; xmlProps = new AtomicReference<XmlProps>(); annotationList = new ArrayList<BugAnnotation>(4); cachedHashCode = INVALID_HASH_CODE; BugPattern p = DetectorFactoryCollection.instance().lookupBugPattern(type); if (p == null) { if ( missingBugTypes.add(type)) { String msg = "Can't find definition of bug type " + type; AnalysisContext.logError(msg, new NoSuchBugPattern(type)); } } else { this.priority += p.getPriorityAdjustment(); } if (adjustExperimental && isExperimental()) { this.priority = Priorities.EXP_PRIORITY; } boundPriority(); }
public boolean isDisabledByDefault(String bugPatternOrCode) { @CheckForNull BugPattern pattern = lookupBugPattern(bugPatternOrCode); if (pattern != null) { for(DetectorFactory fac : factoryList) { if (fac.isDefaultEnabled() && fac.getReportedBugPatterns().contains(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; }
private void addBugPatterns(Set<String> bugTypeSet) { Element root = document.getRootElement(); for (String bugType : bugTypeSet) { BugPattern bugPattern = DetectorFactoryCollection.instance().lookupBugPattern(bugType); if (bugPattern == null) { continue; } Element details = root.addElement("BugPattern"); details.addAttribute("type", bugType).addAttribute("abbrev", bugPattern.getAbbrev()) .addAttribute("category", bugPattern.getCategory()); details.addElement("ShortDescription").addText(bugPattern.getShortDescription()); details.addElement("Details").addCDATA(bugPattern.getDetailText()); } }