public static void resolveRemove(TrackedIssue issue) { issue.setStatus(Issue.STATUS_CLOSED); issue.setStartLine(null); issue.setEndLine(null); issue.setResolution(Issue.RESOLUTION_REMOVED); }
@Test public void should_write_json() throws Exception { TrackedIssue issue = new TrackedIssue(); issue.setKey("200"); issue.setComponentKey("struts:src/main/java/org/apache/struts/Action.java"); issue.setRuleKey(RuleKey.of("squid", "AvoidCycles")); issue.setMessage("There are 2 cycles"); issue.setSeverity("MINOR"); issue.setStatus(Issue.STATUS_OPEN); issue.setResolution(null); issue.setStartLine(1); issue.setEndLine(2); issue.setStartLineOffset(3); issue.setEndLineOffset(4); issue.setGap(3.14); issue.setAssignee("simon"); issue.setCreationDate(SIMPLE_DATE_FORMAT.parse("2013-04-24")); issue.setNew(false); when(issueCache.all()).thenReturn(Collections.singleton(issue)); StringWriter writer = new StringWriter(); jsonReport.writeJson(writer); assertThatJson(writer.toString()).isEqualTo(IOUtils.toString(this.getClass().getResource(this.getClass().getSimpleName() + "/report.json"))); }
public static TrackedIssue toTrackedIssue(InputComponent component, ScannerReport.Issue rawIssue, @Nullable SourceHashHolder hashes) { RuleKey ruleKey = RuleKey.of(rawIssue.getRuleRepository(), rawIssue.getRuleKey()); Preconditions.checkNotNull(component.key(), "Component key must be set"); Preconditions.checkNotNull(ruleKey, "Rule key must be set"); TrackedIssue issue = new TrackedIssue(hashes != null ? hashes.getHashedSource() : null); issue.setKey(Uuids.createFast()); issue.setComponentKey(component.key()); issue.setRuleKey(ruleKey); issue.setGap(rawIssue.getGap() != 0 ? rawIssue.getGap() : null); issue.setSeverity(rawIssue.getSeverity().name()); issue.setMessage(StringUtils.trimToNull(rawIssue.getMsg())); issue.setResolution(null); issue.setStatus(Issue.STATUS_OPEN); issue.setNew(true); if (rawIssue.hasTextRange()) { TextRange r = rawIssue.getTextRange(); issue.setStartLine(r.getStartLine()); issue.setStartLineOffset(r.getStartOffset()); issue.setEndLine(r.getEndLine()); issue.setEndLineOffset(r.getEndOffset()); } return issue; }
public static void close(TrackedIssue issue) { issue.setStatus(Issue.STATUS_CLOSED); issue.setStartLine(null); issue.setEndLine(null); issue.setResolution(Issue.RESOLUTION_FIXED); }
public static TrackedIssue toTrackedIssue(InputComponent component, ScannerReport.Issue rawIssue, @Nullable SourceHashHolder hashes) { RuleKey ruleKey = RuleKey.of(rawIssue.getRuleRepository(), rawIssue.getRuleKey()); Preconditions.checkNotNull(component.key(), "Component key must be set"); Preconditions.checkNotNull(ruleKey, "Rule key must be set"); TrackedIssue issue = new TrackedIssue(hashes != null ? hashes.getHashedSource() : null); issue.setKey(Uuids.createFast()); issue.setComponentKey(component.key()); issue.setRuleKey(ruleKey); issue.setGap(rawIssue.getGap() != 0 ? rawIssue.getGap() : null); issue.setSeverity(rawIssue.getSeverity().name()); issue.setMessage(StringUtils.trimToNull(rawIssue.getMsg())); issue.setResolution(null); issue.setStatus(Issue.STATUS_OPEN); issue.setNew(true); if (rawIssue.hasTextRange()) { TextRange r = rawIssue.getTextRange(); issue.setStartLine(r.getStartLine()); issue.setStartLineOffset(r.getStartOffset()); issue.setEndLine(r.getEndLine()); issue.setEndLineOffset(r.getEndOffset()); } return issue; }
@Test public void round_trip() { TrackedIssue issue = new TrackedIssue(); issue.setStartLine(15); assertThat(issue.getLine()).isEqualTo(15); assertThat(issue.startLine()).isEqualTo(15); }
@Test public void hashes() { String[] hashArr = new String[] { "hash1", "hash2", "hash3" }; FileHashes hashes = FileHashes.create(hashArr); TrackedIssue issue = new TrackedIssue(hashes); issue.setStartLine(1); assertThat(issue.getLineHash()).isEqualTo("hash1"); } }
defaultIssue.setNew(true); defaultIssue.setKey("xyz"); defaultIssue.setStartLine(1); defaultIssue.setMessage("msg"); defaultIssue.setSeverity("BLOCKER");
.setSeverity("MAJOR") .setMessage("msg") .setStartLine(1) .setGap(2.0) .setStatus("RESOLVED")
public static TrackedIssue toTrackedIssue(ServerIssue serverIssue, String componentKey) { TrackedIssue issue = new TrackedIssue(); issue.setKey(serverIssue.getKey()); issue.setStatus(serverIssue.getStatus()); issue.setResolution(serverIssue.hasResolution() ? serverIssue.getResolution() : null); issue.setMessage(serverIssue.hasMsg() ? serverIssue.getMsg() : null); issue.setStartLine(serverIssue.hasLine() ? serverIssue.getLine() : null); issue.setEndLine(serverIssue.hasLine() ? serverIssue.getLine() : null); issue.setSeverity(serverIssue.getSeverity().name()); issue.setAssignee(serverIssue.hasAssigneeLogin() ? serverIssue.getAssigneeLogin() : null); // key in serverIssue might have branch, so don't use it issue.setComponentKey(componentKey); issue.setCreationDate(new Date(serverIssue.getCreationDate())); issue.setRuleKey(RuleKey.of(serverIssue.getRuleRepository(), serverIssue.getRuleKey())); issue.setNew(false); return issue; }
public static void close(TrackedIssue issue) { issue.setStatus(Issue.STATUS_CLOSED); issue.setStartLine(null); issue.setEndLine(null); issue.setResolution(Issue.RESOLUTION_FIXED); }
public static void resolveRemove(TrackedIssue issue) { issue.setStatus(Issue.STATUS_CLOSED); issue.setStartLine(null); issue.setEndLine(null); issue.setResolution(Issue.RESOLUTION_REMOVED); }
public static TrackedIssue toTrackedIssue(ServerIssue serverIssue, String componentKey) { TrackedIssue issue = new TrackedIssue(); issue.setKey(serverIssue.getKey()); issue.setStatus(serverIssue.getStatus()); issue.setResolution(serverIssue.hasResolution() ? serverIssue.getResolution() : null); issue.setMessage(serverIssue.hasMsg() ? serverIssue.getMsg() : null); issue.setStartLine(serverIssue.hasLine() ? serverIssue.getLine() : null); issue.setEndLine(serverIssue.hasLine() ? serverIssue.getLine() : null); issue.setSeverity(serverIssue.getSeverity().name()); issue.setAssignee(serverIssue.hasAssigneeLogin() ? serverIssue.getAssigneeLogin() : null); // key in serverIssue might have branch, so don't use it issue.setComponentKey(componentKey); issue.setCreationDate(new Date(serverIssue.getCreationDate())); issue.setRuleKey(RuleKey.of(serverIssue.getRuleRepository(), serverIssue.getRuleKey())); issue.setNew(false); return issue; }