コード例 #1
0
  private void checkQualityGateStatusChange(
      Component project, Metric metric, QualityGateStatus rawStatus) {
    Optional<Measure> baseMeasure = measureRepository.getBaseMeasure(project, metric);
    if (!baseMeasure.isPresent()) {
      checkNewQualityGate(project, rawStatus);
      return;
    }

    if (!baseMeasure.get().hasQualityGateStatus()) {
      LOGGER.warn(
          String.format(
              "Previous alterStatus for project %s is not a supported value. Can not compute Quality Gate event",
              project.getKey()));
      checkNewQualityGate(project, rawStatus);
      return;
    }
    QualityGateStatus baseStatus = baseMeasure.get().getQualityGateStatus();

    if (baseStatus.getStatus() != rawStatus.getStatus()) {
      // The QualityGate status has changed
      String label =
          String.format(
              "%s (was %s)",
              rawStatus.getStatus().getColorName(), baseStatus.getStatus().getColorName());
      createEvent(project, label, rawStatus.getText());
      boolean isNewKo = rawStatus.getStatus() == Measure.Level.OK;
      notifyUsers(project, label, rawStatus, isNewKo);
    }
  }
コード例 #2
0
 @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.
   BatchReport.Changesets changesets =
       reportReader.readChangesets(file.getReportAttributes().getRef());
   if (changesets == null) {
     Optional<Measure> baseMeasure = measureRepository.getBaseMeasure(file, lastCommitDateMetric);
     if (baseMeasure.isPresent()) {
       path.current().addDate(baseMeasure.get().getLongValue());
     }
   } else {
     for (BatchReport.Changesets.Changeset changeset : changesets.getChangesetList()) {
       if (changeset.hasDate()) {
         path.current().addDate(changeset.getDate());
       }
     }
   }
   saveAndAggregate(file, path);
 }