Пример #1
0
 private boolean settingsCondition(DefaultSensorDescriptor descriptor) {
   if (!descriptor.properties().isEmpty()) {
     for (String propertyKey : descriptor.properties()) {
       if (!settings.hasKey(propertyKey)) {
         return false;
       }
     }
   }
   return true;
 }
Пример #2
0
 private boolean activeRulesCondition(DefaultSensorDescriptor descriptor) {
   if (!descriptor.ruleRepositories().isEmpty()) {
     for (String repoKey : descriptor.ruleRepositories()) {
       if (!activeRules.findByRepository(repoKey).isEmpty()) {
         return true;
       }
     }
     return false;
   }
   return true;
 }
Пример #3
0
 /** Decide if the given Sensor should be executed. */
 public boolean shouldExecute(DefaultSensorDescriptor descriptor) {
   if (!fsCondition(descriptor)) {
     LOG.debug(
         "'{}' skipped because there is no related file in current project", descriptor.name());
     return false;
   }
   if (!activeRulesCondition(descriptor)) {
     LOG.debug(
         "'{}' skipped because there is no related rule activated in the quality profile",
         descriptor.name());
     return false;
   }
   if (!settingsCondition(descriptor)) {
     LOG.debug(
         "'{}' skipped because one of the required properties is missing", descriptor.name());
     return false;
   }
   if (descriptor.isDisabledInPreview() && analysisMode.isPreview()) {
     LOG.debug("'{}' skipped in preview mode", descriptor.name());
     return false;
   }
   if (descriptor.isDisabledInIssues() && analysisMode.isIssues()) {
     LOG.debug("'{}' skipped in issues mode", descriptor.name());
     return false;
   }
   return true;
 }
Пример #4
0
  private boolean fsCondition(DefaultSensorDescriptor descriptor) {
    if (!descriptor.languages().isEmpty() || descriptor.type() != null) {
      FilePredicate langPredicate =
          descriptor.languages().isEmpty()
              ? fs.predicates().all()
              : fs.predicates().hasLanguages(descriptor.languages());

      FilePredicate typePredicate =
          descriptor.type() == null
              ? fs.predicates().all()
              : fs.predicates().hasType(descriptor.type());
      return fs.hasFiles(fs.predicates().and(langPredicate, typePredicate));
    }
    return true;
  }