예제 #1
0
 public void decorate(Resource resource, DecoratorContext context) {
   if (Scopes.isFile(resource) && !Qualifiers.UNIT_TEST_FILE.equals(resource.getQualifier())) {
     int classes = 0;
     for (DecoratorContext child : context.getChildren()) {
       if (Scopes.isProgramUnit(child.getResource())) {
         classes++;
       }
     }
     context.saveMeasure(new Measure(CoreMetrics.CLASSES, (double) classes));
   }
 }
예제 #2
0
 private Bucket checkIndexed(Resource resource) {
   Bucket bucket = getBucket(resource, true);
   if (bucket == null) {
     if (lock.isLocked()) {
       if (lock.isFailWhenLocked()) {
         throw new ResourceNotIndexedException(resource);
       }
       LOG.warn("Resource will be ignored in next Sonar versions, index is locked: " + resource);
     }
     if (Scopes.isDirectory(resource) || Scopes.isFile(resource)) {
       bucket = doIndex(resource);
     } else if (!lock.isLocked()) {
       LOG.warn(
           "Resource will be ignored in next Sonar versions, it must be indexed before adding data: "
               + resource);
     }
   }
   return bucket;
 }