예제 #1
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;
 }
예제 #2
0
  private static LoadStrategy getStrategy(AnalysisMode mode) {
    if (mode.isQuick()) {
      return LoadStrategy.CACHE_FIRST;
    }

    return LoadStrategy.SERVER_FIRST;
  }
 @Test
 public void no_cache_by_default_in_issues_mode() {
   when(mode.isIssues()).thenReturn(true);
   WSLoader loader =
       underTest.provide(
           mode, cache, wsClient, new AnalysisProperties(Maps.<String, String>newHashMap()));
   assertThat(loader.getDefaultStrategy()).isEqualTo(LoadStrategy.SERVER_ONLY);
 }
 @Override
 public HighlightingBuilder newHighlighting() {
   if (analysisMode.isIssues()) {
     return NO_OP_BUILDER;
   }
   DefaultHighlighting defaultHighlighting = new DefaultHighlighting(sensorStorage);
   defaultHighlighting.onFile(inputFile);
   return new DefaultHighlightingBuilder(defaultHighlighting);
 }
  @Test
  public void should_disabled_in_issues_mode() {
    DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor().disabledInIssues();
    assertThat(optimizer.shouldExecute(descriptor)).isTrue();

    when(analysisMode.isIssues()).thenReturn(true);

    assertThat(optimizer.shouldExecute(descriptor)).isFalse();
  }
예제 #6
0
 public WSLoader provide(
     AnalysisProperties props, AnalysisMode mode, PersistentCache cache, ServerClient client) {
   if (wsLoader == null) {
     // recreate cache directory if needed for this analysis
     cache.reconfigure();
     wsLoader = new WSLoader(isCacheEnabled(props.properties(), mode.isPreview()), cache, client);
     wsLoader.setStrategy(getStrategy(mode));
   }
   return wsLoader;
 }
예제 #7
0
 public void execute() {
   if (analysisMode.isPreview()) {
     // Decorators are not executed in preview mode
     return;
   }
   Collection<Decorator> decorators = decoratorsSelector.select(project);
   eventBus.fireEvent(new DecoratorsPhaseEvent(Lists.newArrayList(decorators), true));
   ((DefaultDecoratorContext) decorateResource(project, decorators, true)).end();
   eventBus.fireEvent(new DecoratorsPhaseEvent(Lists.newArrayList(decorators), false));
 }
 @Test
 public void enable_cache_in_issues_mode() {
   when(mode.isIssues()).thenReturn(true);
   WSLoader loader =
       underTest.provide(
           mode,
           cache,
           wsClient,
           new AnalysisProperties(
               ImmutableMap.of(AnalysisWSLoaderProvider.SONAR_USE_WS_CACHE, "true")));
   assertThat(loader.getDefaultStrategy()).isEqualTo(LoadStrategy.CACHE_ONLY);
 }
 private static void prepareNonAssociatedProject(Map<String, String> props, AnalysisMode mode) {
   if (mode.isIssues() && !props.containsKey(CoreProperties.PROJECT_KEY_PROPERTY)) {
     props.put(CoreProperties.PROJECT_KEY_PROPERTY, NON_ASSOCIATED_PROJECT_KEY);
   }
 }