public static void resolveRemove(TrackedIssue issue) { issue.setStatus(Issue.STATUS_CLOSED); issue.setStartLine(null); issue.setEndLine(null); issue.setResolution(Issue.RESOLUTION_REMOVED); }
public static void close(TrackedIssue issue) { issue.setStatus(Issue.STATUS_CLOSED); issue.setStartLine(null); issue.setEndLine(null); issue.setResolution(Issue.RESOLUTION_FIXED); }
@VisibleForTesting protected void mergeMatched(Tracking<TrackedIssue, ServerIssueFromWs> result, Collection<TrackedIssue> mergeTo, Collection<TrackedIssue> rawIssues) { for (Map.Entry<TrackedIssue, ServerIssueFromWs> e : result.getMatchedRaws().entrySet()) { org.sonar.scanner.protocol.input.ScannerInput.ServerIssue dto = e.getValue().getDto(); TrackedIssue tracked = e.getKey(); // invariant fields tracked.setKey(dto.getKey()); // non-persisted fields tracked.setNew(false); // fields to update with old values tracked.setResolution(dto.hasResolution() ? dto.getResolution() : null); tracked.setStatus(dto.getStatus()); tracked.setAssignee(dto.hasAssigneeLogin() ? dto.getAssigneeLogin() : null); tracked.setCreationDate(new Date(dto.getCreationDate())); if (dto.getManualSeverity()) { // Severity overridden by user tracked.setSeverity(dto.getSeverity().name()); } mergeTo.add(tracked); } }
@Test public void should_exclude_resolved_issues() throws Exception { RuleKey ruleKey = RuleKey.of("squid", "AvoidCycles"); TrackedIssue issue = new TrackedIssue(); issue.setKey("200"); issue.setComponentKey("struts:src/main/java/org/apache/struts/Action.java"); issue.setRuleKey(ruleKey); issue.setStatus(Issue.STATUS_CLOSED); issue.setResolution(Issue.RESOLUTION_FIXED); 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-without-resolved-issues.json"))); }
@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"))); }
.setStartLine(1) .setGap(2.0) .setStatus("RESOLVED") .setResolution("FIXED") .setAssignee("tata")
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 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); }
@VisibleForTesting protected void mergeMatched(Tracking<TrackedIssue, ServerIssueFromWs> result, Collection<TrackedIssue> mergeTo, Collection<TrackedIssue> rawIssues) { for (Map.Entry<TrackedIssue, ServerIssueFromWs> e : result.getMatchedRaws().entrySet()) { org.sonar.scanner.protocol.input.ScannerInput.ServerIssue dto = e.getValue().getDto(); TrackedIssue tracked = e.getKey(); // invariant fields tracked.setKey(dto.getKey()); // non-persisted fields tracked.setNew(false); // fields to update with old values tracked.setResolution(dto.hasResolution() ? dto.getResolution() : null); tracked.setStatus(dto.getStatus()); tracked.setAssignee(dto.hasAssigneeLogin() ? dto.getAssigneeLogin() : null); tracked.setCreationDate(new Date(dto.getCreationDate())); if (dto.getManualSeverity()) { // Severity overridden by user tracked.setSeverity(dto.getSeverity().name()); } mergeTo.add(tracked); } }
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 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; }