@Test public void match() throws Exception { SourceMatcher sm = new SourceMatcher(fileName); assertFalse(sm.match(bug)); bug.addClass("bla", null); assertFalse(sm.match(bug)); ClassAnnotation primaryClass = bug.getPrimaryClass(); primaryClass.setSourceLines(SourceLineAnnotation.createUnknown("bla", "")); assertFalse(sm.match(bug)); primaryClass.setSourceLines(SourceLineAnnotation.createUnknown("bla", fileName)); assertTrue(sm.match(bug)); sm = new SourceMatcher("~bla.*"); assertTrue(sm.match(bug)); sm = new SourceMatcher("~blup.*"); assertFalse(sm.match(bug)); sm = new SourceMatcher("~.*\\.groovy"); assertTrue(sm.match(bug)); sm = new SourceMatcher("~.*\\.java"); assertFalse(sm.match(bug)); }
@Override public boolean match(BugInstance bugInstance) { ClassAnnotation primaryClassAnnotation = bugInstance.getPrimaryClass(); if (primaryClassAnnotation == null) { return false; } boolean result = false; String bugFileName = primaryClassAnnotation.getSourceFileName(); if (bugFileName != null && !bugFileName.isEmpty()) { result = fileName.match(bugFileName); if (!result && bugInstance.getPrimarySourceLineAnnotation().isSourceFileKnown()) { bugFileName = bugInstance.getPrimarySourceLineAnnotation().getRealSourcePath(); result = fileName.match(bugFileName); } } LOG.debug("Matching {} with {}, result = {}", bugFileName, fileName, result); return result; }
SourceMatcher implements Matcher { @Override public boolean match(BugInstance bugInstance) { ClassAnnotation primaryClassAnnotation = bugInstance.getPrimaryClass(); if (primaryClassAnnotation == null) { return false; } boolean result = false; String bugFileName = primaryClassAnnotation.getSourceFileName(); if (bugFileName != null && !bugFileName.isEmpty()) { result = fileName.match(bugFileName); if (!result && bugInstance.getPrimarySourceLineAnnotation().isSourceFileKnown()) { bugFileName = bugInstance.getPrimarySourceLineAnnotation().getRealSourcePath(); result = fileName.match(bugFileName); } } LOG.debug("Matching {} with {}, result = {}", bugFileName, fileName, result); return result; } }
SourceMatcher implements Matcher { @Override public boolean match(BugInstance bugInstance) { ClassAnnotation primaryClassAnnotation = bugInstance.getPrimaryClass(); if (primaryClassAnnotation == null) { return false; } boolean result = false; String bugFileName = primaryClassAnnotation.getSourceFileName(); if (bugFileName != null && !bugFileName.isEmpty()) { result = fileName.match(bugFileName); if (!result && bugInstance.getPrimarySourceLineAnnotation().isSourceFileKnown()) { bugFileName = bugInstance.getPrimarySourceLineAnnotation().getRealSourcePath(); result = fileName.match(bugFileName); } } LOG.debug("Matching {} with {}, result = {}", bugFileName, fileName, result); return result; } SourceMatcher(String fileName); }
SourceMatcher implements Matcher { @Override public boolean match(BugInstance bugInstance) { ClassAnnotation primaryClassAnnotation = bugInstance.getPrimaryClass(); if (primaryClassAnnotation == null) { return false; } boolean result = false; String bugFileName = primaryClassAnnotation.getSourceFileName(); if (bugFileName != null && !bugFileName.isEmpty()) { result = fileName.match(bugFileName); if (!result && bugInstance.getPrimarySourceLineAnnotation().isSourceFileKnown()) { bugFileName = bugInstance.getPrimarySourceLineAnnotation().getRealSourcePath(); result = fileName.match(bugFileName); } } LOG.debug("Matching {} with {}, result = {}", bugFileName, fileName, result); return result; } SourceMatcher(String fileName); @Override String toString(); @Override boolean match(BugInstance bugInstance); @Override void writeXML(XMLOutput xmlOutput, boolean disabled); }
SourceMatcher implements Matcher { @Override public boolean match(BugInstance bugInstance) { ClassAnnotation primaryClassAnnotation = bugInstance.getPrimaryClass(); if (primaryClassAnnotation == null) { return false; } boolean result = false; String bugFileName = primaryClassAnnotation.getSourceFileName(); if (bugFileName != null && !bugFileName.isEmpty()) { result = fileName.match(bugFileName); if (!result && bugInstance.getPrimarySourceLineAnnotation().isSourceFileKnown()) { bugFileName = bugInstance.getPrimarySourceLineAnnotation().getRealSourcePath(); result = fileName.match(bugFileName); } } LOG.debug("Matching {} with {}, result = {}", bugFileName, fileName, result); return result; } SourceMatcher(String fileName); @Override String toString(); @Override boolean match(BugInstance bugInstance); @Override void writeXML(XMLOutput xmlOutput, boolean disabled);  }