Search in sources :

Example 6 with Changeset

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();
}
Also used : Changeset(org.sonar.server.computation.task.projectanalysis.scm.Changeset)

Example 7 with Changeset

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);
    }
}
Also used : Period(org.sonar.server.computation.task.projectanalysis.period.Period) Changeset(org.sonar.server.computation.task.projectanalysis.scm.Changeset)

Example 8 with Changeset

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;
}
Also used : Changeset(org.sonar.server.computation.task.projectanalysis.scm.Changeset)

Aggregations

Changeset (org.sonar.server.computation.task.projectanalysis.scm.Changeset)8 Test (org.junit.Test)3 DefaultIssue (org.sonar.core.issue.DefaultIssue)2 ScmInfo (org.sonar.server.computation.task.projectanalysis.scm.ScmInfo)2 Period (org.sonar.server.computation.task.projectanalysis.period.Period)1 ScmInfoImpl (org.sonar.server.computation.task.projectanalysis.scm.ScmInfoImpl)1