use of org.sonar.scanner.protocol.output.ScannerReport.Changesets.Builder in project sonarqube by SonarSource.
the class DefaultBlameOutput method blameResult.
@Override
public synchronized void blameResult(InputFile file, List<BlameLine> lines) {
Preconditions.checkNotNull(file);
Preconditions.checkNotNull(lines);
Preconditions.checkArgument(allFilesToBlame.contains(file), "It was not expected to blame file %s", file.relativePath());
if (lines.size() != file.lines()) {
LOG.debug("Ignoring blame result since provider returned {} blame lines but file {} has {} lines", lines.size(), file.relativePath(), file.lines());
return;
}
Builder scmBuilder = ScannerReport.Changesets.newBuilder();
DefaultInputFile inputFile = (DefaultInputFile) file;
scmBuilder.setComponentRef(inputFile.batchId());
Map<String, Integer> changesetsIdByRevision = new HashMap<>();
int lineId = 1;
for (BlameLine line : lines) {
validateLine(line, lineId, file);
Integer changesetId = changesetsIdByRevision.get(line.revision());
if (changesetId == null) {
addChangeset(scmBuilder, line);
changesetId = scmBuilder.getChangesetCount() - 1;
changesetsIdByRevision.put(line.revision(), changesetId);
}
scmBuilder.addChangesetIndexByLine(changesetId);
lineId++;
}
writer.writeComponentChangesets(scmBuilder.build());
allFilesToBlame.remove(file);
count++;
progressReport.message(count + "/" + total + " files analyzed");
}
use of org.sonar.scanner.protocol.output.ScannerReport.Changesets.Builder in project sonarqube by SonarSource.
the class ScmPublisher method askToCopyDataFromPreviousAnalysis.
private static void askToCopyDataFromPreviousAnalysis(DefaultInputFile f, ScannerReportWriter writer) {
Builder scmBuilder = ScannerReport.Changesets.newBuilder();
scmBuilder.setComponentRef(f.batchId());
scmBuilder.setCopyFromPrevious(true);
writer.writeComponentChangesets(scmBuilder.build());
}
Aggregations