use of org.sonar.server.computation.task.projectanalysis.scm.ScmInfo in project sonarqube by SonarSource.
the class NewMaintainabilityMeasuresVisitor method initNewDebtRatioCounter.
private void initNewDebtRatioCounter(Component file, Path<Counter> path) {
// first analysis, no period, no differential value to compute, save processing time and return now
if (!periodHolder.hasPeriod()) {
return;
}
Optional<Measure> nclocDataMeasure = measureRepository.getRawMeasure(file, this.nclocDataMetric);
if (!nclocDataMeasure.isPresent()) {
return;
}
Optional<ScmInfo> scmInfoOptional = scmInfoRepository.getScmInfo(file);
if (!scmInfoOptional.isPresent()) {
LOG.trace(String.format("No changeset for file %s. Dev cost will be zero.", file.getKey()));
return;
}
ScmInfo scmInfo = scmInfoOptional.get();
initNewDebtRatioCounter(path.current(), file, nclocDataMeasure.get(), scmInfo);
}
use of org.sonar.server.computation.task.projectanalysis.scm.ScmInfo in project sonarqube by SonarSource.
the class LastCommitVisitor method visitFile.
@Override
public void visitFile(Component file, Path<LastCommit> path) {
// load SCM blame information from report. It can be absent when the file was not touched
// since previous analysis (optimization to decrease execution of blame commands). In this case
// the date is loaded from database, as it did not change from previous analysis.
Optional<ScmInfo> scmInfoOptional = scmInfoRepository.getScmInfo(file);
if (scmInfoOptional.isPresent()) {
ScmInfo scmInfo = scmInfoOptional.get();
path.current().addDate(scmInfo.getLatestChangeset().getDate());
}
saveAndAggregate(file, path);
}
use of org.sonar.server.computation.task.projectanalysis.scm.ScmInfo in project sonarqube by SonarSource.
the class ScmLineReaderTest method set_scm_with_minim_fields.
@Test
public void set_scm_with_minim_fields() {
ScmInfo scmInfo = new ScmInfoImpl(newArrayList(Changeset.newChangesetBuilder().setDate(123456789L).setRevision("rev-1").build()));
ScmLineReader lineScm = new ScmLineReader(scmInfo);
DbFileSources.Line.Builder lineBuilder = DbFileSources.Data.newBuilder().addLinesBuilder().setLine(1);
lineScm.read(lineBuilder);
assertThat(lineBuilder.hasScmAuthor()).isFalse();
assertThat(lineBuilder.getScmDate()).isEqualTo(123456789L);
assertThat(lineBuilder.getScmRevision()).isEqualTo("rev-1");
}
use of org.sonar.server.computation.task.projectanalysis.scm.ScmInfo in project sonarqube by SonarSource.
the class ScmLineReaderTest method set_scm.
@Test
public void set_scm() {
ScmInfo scmInfo = new ScmInfoImpl(newArrayList(Changeset.newChangesetBuilder().setAuthor("john").setDate(123456789L).setRevision("rev-1").build()));
ScmLineReader lineScm = new ScmLineReader(scmInfo);
DbFileSources.Line.Builder lineBuilder = DbFileSources.Data.newBuilder().addLinesBuilder().setLine(1);
lineScm.read(lineBuilder);
assertThat(lineBuilder.getScmAuthor()).isEqualTo("john");
assertThat(lineBuilder.getScmDate()).isEqualTo(123456789L);
assertThat(lineBuilder.getScmRevision()).isEqualTo("rev-1");
}
use of org.sonar.server.computation.task.projectanalysis.scm.ScmInfo in project sonarqube by SonarSource.
the class IssueCreationDateCalculatorTest method withScm.
private void withScm(long blame) {
ScmInfo scmInfo = mock(ScmInfo.class);
Changeset changeset = Changeset.newChangesetBuilder().setDate(blame).setRevision("1").build();
when(scmInfoRepository.getScmInfo(component)).thenReturn(Optional.of(scmInfo));
when(scmInfo.getLatestChangeset()).thenReturn(changeset);
}
Aggregations