use of org.sonar.server.computation.task.projectanalysis.scm.Changeset in project sonarqube by SonarSource.
the class IssueCreationDateCalculator method getChangeset.
private static Optional<Changeset> getChangeset(ScmInfo scmInfo, DefaultIssue issue) {
Integer line = issue.getLine();
if (line != null) {
Changeset changesetForLine = scmInfo.getChangesetForLine(line);
if (changesetForLine != null) {
return Optional.of(changesetForLine);
}
}
Changeset latestChangeset = scmInfo.getLatestChangeset();
if (latestChangeset != null) {
return Optional.of(latestChangeset);
}
return Optional.empty();
}
use of org.sonar.server.computation.task.projectanalysis.scm.Changeset in project sonarqube by SonarSource.
the class NewMaintainabilityMeasuresVisitor method initNewDebtRatioCounter.
private void initNewDebtRatioCounter(Counter devCostCounter, Component file, Measure nclocDataMeasure, ScmInfo scmInfo) {
boolean hasDevCost = false;
long lineDevCost = ratingSettings.getDevCost(file.getFileAttributes().getLanguageKey());
for (Integer nclocLineIndex : nclocLineIndexes(nclocDataMeasure)) {
Changeset changeset = scmInfo.getChangesetForLine(nclocLineIndex);
Period period = periodHolder.getPeriod();
if (isLineInPeriod(changeset.getDate(), period)) {
devCostCounter.incrementDevCost(lineDevCost);
hasDevCost = true;
}
}
if (hasDevCost) {
long newDebt = getLongValue(measureRepository.getRawMeasure(file, this.newDebtMetric));
devCostCounter.incrementNewDebt(newDebt);
}
}
use of org.sonar.server.computation.task.projectanalysis.scm.Changeset in project sonarqube by SonarSource.
the class NewMaintainabilityMeasuresVisitorTest method createChangesets.
/**
* Creates changesets of {@code lines} lines which all have the same date {@code scmDate}.
*/
private static Changeset[] createChangesets(long scmDate, int lines) {
Changeset changetset = Changeset.newChangesetBuilder().setDate(scmDate).setRevision("rev-1").build();
Changeset[] changesets = new Changeset[lines];
for (int i = 0; i < lines; i++) {
changesets[i] = changetset;
}
return changesets;
}
Aggregations