コード例 #1
0
ファイル: DefaultIndex.java プロジェクト: ratlsun/view_sonar
  boolean registerDependency(Dependency dependency) {
    Bucket fromBucket = doIndex(dependency.getFrom());
    Bucket toBucket = doIndex(dependency.getTo());

    if (fromBucket != null
        && !fromBucket.isExcluded()
        && toBucket != null
        && !toBucket.isExcluded()) {
      dependencies.add(dependency);
      registerOutgoingDependency(dependency);
      registerIncomingDependency(dependency);
      return true;
    }
    return false;
  }
コード例 #2
0
ファイル: DefaultIndex.java プロジェクト: ratlsun/view_sonar
 private boolean checkExclusion(Resource resource, Bucket parent) {
   boolean excluded =
       (parent != null && parent.isExcluded())
           || (resourceFilters != null && resourceFilters.isExcluded(resource));
   resource.setExcluded(excluded);
   return excluded;
 }
コード例 #3
0
ファイル: DefaultIndex.java プロジェクト: ratlsun/view_sonar
 @Override
 public void setSource(Resource reference, String source) {
   Bucket bucket = checkIndexed(reference);
   if (bucket != null && !bucket.isExcluded()) {
     persistence.setSource(reference, source);
   }
 }
コード例 #4
0
ファイル: DefaultIndex.java プロジェクト: ratlsun/view_sonar
  @Override
  public void addViolation(Violation violation, boolean force) {
    Resource resource = violation.getResource();
    if (resource == null) {
      violation.setResource(currentProject);
    } else if (!Scopes.isHigherThanOrEquals(resource, Scopes.FILE)) {
      throw new IllegalArgumentException(
          "Violations are only supported on files, directories and project");
    }

    Rule rule = violation.getRule();
    if (rule == null) {
      LOG.warn("Rule is null. Ignoring violation {}", violation);
      return;
    }

    Bucket bucket = checkIndexed(resource);
    if (bucket == null || bucket.isExcluded()) {
      return;
    }

    // keep a limitation (bug?) of deprecated violations api : severity is always
    // set by sonar. The severity set by plugins is overridden.
    // This is not the case with issue api.
    violation.setSeverity(null);

    violation.setResource(bucket.getResource());
    scanIssues.initAndAddViolation(violation);
  }
コード例 #5
0
ファイル: DefaultIndex.java プロジェクト: ratlsun/view_sonar
 private Bucket getBucket(Resource resource, boolean acceptExcluded) {
   Bucket bucket = null;
   if (resource != null) {
     bucket = buckets.get(resource);
     if (!acceptExcluded && bucket != null && bucket.isExcluded()) {
       bucket = null;
     }
   }
   return bucket;
 }
コード例 #6
0
ファイル: DefaultIndex.java プロジェクト: ratlsun/view_sonar
 public List<Resource> getChildren(Resource resource, boolean acceptExcluded) {
   List<Resource> children = Lists.newLinkedList();
   Bucket bucket = getBucket(resource, acceptExcluded);
   if (bucket != null) {
     for (Bucket childBucket : bucket.getChildren()) {
       if (acceptExcluded || !childBucket.isExcluded()) {
         children.add(childBucket.getResource());
       }
     }
   }
   return children;
 }
コード例 #7
0
ファイル: DefaultIndex.java プロジェクト: ratlsun/view_sonar
  /** the measure is updated if it's already registered. */
  @Override
  public Measure addMeasure(Resource resource, Measure measure) {
    Bucket bucket = checkIndexed(resource);
    if (bucket != null && !bucket.isExcluded()) {
      Metric metric = metricFinder.findByKey(measure.getMetricKey());
      if (metric == null) {
        throw new SonarException("Unknown metric: " + measure.getMetricKey());
      }
      measure.setMetric(metric);
      bucket.addMeasure(measure);

      if (measure.getPersistenceMode().useDatabase()) {
        persistence.saveMeasure(resource, measure);
      }
    }
    return measure;
  }
コード例 #8
0
ファイル: DefaultIndex.java プロジェクト: ratlsun/view_sonar
 @Override
 public boolean isExcluded(Resource reference) {
   Bucket bucket = getBucket(reference, true);
   return bucket != null && bucket.isExcluded();
 }
コード例 #9
0
ファイル: DefaultIndex.java プロジェクト: ratlsun/view_sonar
 @Override
 public boolean index(Resource resource, Resource parentReference) {
   Bucket bucket = doIndex(resource, parentReference);
   return bucket != null && !bucket.isExcluded();
 }