use of org.sonar.scanner.issue.tracking.TrackedIssue in project sonarqube by SonarSource.
the class JSONReport method writeJsonIssues.
private void writeJsonIssues(JsonWriter json, Set<RuleKey> ruleKeys, Set<String> logins) throws IOException {
json.name("issues").beginArray();
for (TrackedIssue issue : getIssues()) {
if (issue.resolution() == null) {
InputComponent component = componentStore.getByKey(issue.componentKey());
String componentKey = getModule(component).definition().getKeyWithBranch();
if (component instanceof InputPath) {
componentKey = ComponentKeys.createEffectiveKey(componentKey, (InputPath) component);
}
json.beginObject().prop("key", issue.key()).prop("component", componentKey).prop("line", issue.startLine()).prop("startLine", issue.startLine()).prop("startOffset", issue.startLineOffset()).prop("endLine", issue.endLine()).prop("endOffset", issue.endLineOffset()).prop("message", issue.getMessage()).prop("severity", issue.severity()).prop("rule", issue.getRuleKey().toString()).prop("status", issue.status()).prop("resolution", issue.resolution()).prop("isNew", issue.isNew()).prop("assignee", issue.assignee()).prop("effortToFix", issue.gap()).propDateTime("creationDate", issue.creationDate());
if (!StringUtils.isEmpty(issue.assignee())) {
logins.add(issue.assignee());
}
json.endObject();
ruleKeys.add(issue.getRuleKey());
}
}
json.endArray();
}
use of org.sonar.scanner.issue.tracking.TrackedIssue in project sonarqube by SonarSource.
the class ConsoleReport method execute.
@Override
public void execute() {
if (settings.getBoolean(CONSOLE_REPORT_ENABLED_KEY)) {
LOG.warn("Console report is deprecated. Use SonarLint CLI to have local reports of issues");
Report r = new Report();
r.setNoFile(!componentStore.allFilesToPublish().iterator().hasNext());
for (TrackedIssue issue : issueCache.all()) {
r.process(issue);
}
printReport(r);
}
}
use of org.sonar.scanner.issue.tracking.TrackedIssue in project sonarqube by SonarSource.
the class TrackedIssueTest method hashes.
@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");
}
use of org.sonar.scanner.issue.tracking.TrackedIssue in project sonarqube by SonarSource.
the class TrackedIssueTest method round_trip.
@Test
public void round_trip() {
TrackedIssue issue = new TrackedIssue();
issue.setStartLine(15);
assertThat(issue.getLine()).isEqualTo(15);
assertThat(issue.startLine()).isEqualTo(15);
}
use of org.sonar.scanner.issue.tracking.TrackedIssue in project sonarqube by SonarSource.
the class DefaultIssueCallbackTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
RuleKey ruleKey = RuleKey.of("repo", "key");
issue = new TrackedIssue();
issue.setKey("key");
issue.setAssignee("user");
issue.setRuleKey(ruleKey);
when(issueCache.all()).thenReturn(ImmutableList.of(issue));
ScannerInput.User.Builder userBuilder = ScannerInput.User.newBuilder();
userBuilder.setLogin("user");
userBuilder.setName("name");
when(userRepository.map(Collections.singleton("user"))).thenReturn(Collections.singletonMap("user", userBuilder.build()));
Rule r = mock(Rule.class);
when(r.name()).thenReturn("rule name");
when(rules.find(ruleKey)).thenReturn(r);
}
Aggregations