diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2015-12-08 10:37:44 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2015-12-08 10:52:24 +0100 |
commit | 7f680d2af8f27bfb3c63813c66203c621c65d6ae (patch) | |
tree | 5118552bbc48e1e2d327f0f7197da0a6db8b6f63 /sonar-batch | |
parent | 72cec54788255865cff4e857ed1d1a926242d197 (diff) | |
download | sonarqube-7f680d2af8f27bfb3c63813c66203c621c65d6ae.tar.gz sonarqube-7f680d2af8f27bfb3c63813c66203c621c65d6ae.zip |
SONAR-6818 Restore warning when using sonar.profile
Diffstat (limited to 'sonar-batch')
-rw-r--r-- | sonar-batch/src/main/java/org/sonar/batch/repository/QualityProfileProvider.java | 23 | ||||
-rw-r--r-- | sonar-batch/src/test/java/org/sonar/batch/repository/QualityProfileProviderTest.java | 42 |
2 files changed, 38 insertions, 27 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/repository/QualityProfileProvider.java b/sonar-batch/src/main/java/org/sonar/batch/repository/QualityProfileProvider.java index e3de47efb81..fb3d8ff0a36 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/repository/QualityProfileProvider.java +++ b/sonar-batch/src/main/java/org/sonar/batch/repository/QualityProfileProvider.java @@ -19,21 +19,18 @@ */ package org.sonar.batch.repository; +import java.util.List; import javax.annotation.CheckForNull; - -import org.sonar.api.utils.log.Profiler; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; import org.apache.commons.lang.mutable.MutableBoolean; -import org.sonarqube.ws.QualityProfiles.SearchWsResponse.QualityProfile; -import org.sonar.batch.analysis.DefaultAnalysisMode; +import org.picocontainer.injectors.ProviderAdapter; import org.sonar.api.batch.bootstrap.ProjectKey; - -import java.util.List; - +import org.sonar.api.utils.log.Logger; +import org.sonar.api.utils.log.Loggers; +import org.sonar.api.utils.log.Profiler; import org.sonar.batch.analysis.AnalysisProperties; +import org.sonar.batch.analysis.DefaultAnalysisMode; import org.sonar.batch.rule.ModuleQProfiles; -import org.picocontainer.injectors.ProviderAdapter; +import org.sonarqube.ws.QualityProfiles.SearchWsResponse.QualityProfile; public class QualityProfileProvider extends ProviderAdapter { private static final Logger LOG = Loggers.get(QualityProfileProvider.class); @@ -44,7 +41,7 @@ public class QualityProfileProvider extends ProviderAdapter { if (this.profiles == null) { List<QualityProfile> profileList; MutableBoolean fromCache = new MutableBoolean(); - + Profiler profiler = Profiler.create(LOG).startInfo(LOG_MSG); if (mode.isNotAssociated() || !projectRepositories.exists()) { profileList = loader.loadDefault(getSonarProfile(props, mode), fromCache); @@ -61,8 +58,10 @@ public class QualityProfileProvider extends ProviderAdapter { @CheckForNull private static String getSonarProfile(AnalysisProperties props, DefaultAnalysisMode mode) { String profile = null; - if (!mode.isIssues()) { + if (!mode.isIssues() && props.properties().containsKey(ModuleQProfiles.SONAR_PROFILE_PROP)) { profile = props.property(ModuleQProfiles.SONAR_PROFILE_PROP); + LOG.warn("Ability to set quality profile from command line using '" + ModuleQProfiles.SONAR_PROFILE_PROP + + "' is deprecated and will be dropped in a future SonarQube version. Please configure quality profile used by your project on SonarQube server."); } return profile; } diff --git a/sonar-batch/src/test/java/org/sonar/batch/repository/QualityProfileProviderTest.java b/sonar-batch/src/test/java/org/sonar/batch/repository/QualityProfileProviderTest.java index 567dcd1380d..af65f530131 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/repository/QualityProfileProviderTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/repository/QualityProfileProviderTest.java @@ -19,31 +19,37 @@ */ package org.sonar.batch.repository; -import static org.mockito.Mockito.when; - +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; import org.apache.commons.lang.mutable.MutableBoolean; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; import org.sonar.api.batch.bootstrap.ProjectKey; +import org.sonar.api.utils.log.LogTester; +import org.sonar.api.utils.log.LoggerLevel; +import org.sonar.batch.analysis.AnalysisProperties; import org.sonar.batch.analysis.DefaultAnalysisMode; +import org.sonar.batch.rule.ModuleQProfiles; import org.sonarqube.ws.QualityProfiles.SearchWsResponse.QualityProfile; -import java.util.ArrayList; -import java.util.List; - +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.isNull; import static org.mockito.Matchers.eq; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Matchers.isNull; import static org.mockito.Mockito.verify; -import static org.assertj.core.api.Assertions.assertThat; -import org.sonar.batch.rule.ModuleQProfiles; -import org.junit.Test; -import org.sonar.batch.analysis.AnalysisProperties; -import org.mockito.MockitoAnnotations; -import org.mockito.Mock; -import org.junit.Before; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; public class QualityProfileProviderTest { + + @Rule + public LogTester logTester = new LogTester(); + private QualityProfileProvider qualityProfileProvider; @Mock @@ -110,12 +116,15 @@ public class QualityProfileProviderTest { when(mode.isNotAssociated()).thenReturn(false); when(loader.load(eq("project"), eq("custom"), any(MutableBoolean.class))).thenReturn(response); when(props.property(ModuleQProfiles.SONAR_PROFILE_PROP)).thenReturn("custom"); + when(props.properties()).thenReturn(ImmutableMap.of(ModuleQProfiles.SONAR_PROFILE_PROP, "custom")); ModuleQProfiles qps = qualityProfileProvider.provide(key, loader, projectRepo, props, mode); assertResponse(qps); verify(loader).load(eq("project"), eq("custom"), any(MutableBoolean.class)); verifyNoMoreInteractions(loader); + assertThat(logTester.logs(LoggerLevel.WARN)).contains("Ability to set quality profile from command line using '" + ModuleQProfiles.SONAR_PROFILE_PROP + + "' is deprecated and will be dropped in a future SonarQube version. Please configure quality profile used by your project on SonarQube server."); } @Test @@ -137,12 +146,15 @@ public class QualityProfileProviderTest { when(mode.isNotAssociated()).thenReturn(true); when(loader.loadDefault(eq("custom"), any(MutableBoolean.class))).thenReturn(response); when(props.property(ModuleQProfiles.SONAR_PROFILE_PROP)).thenReturn("custom"); + when(props.properties()).thenReturn(ImmutableMap.of(ModuleQProfiles.SONAR_PROFILE_PROP, "custom")); ModuleQProfiles qps = qualityProfileProvider.provide(key, loader, projectRepo, props, mode); assertResponse(qps); verify(loader).loadDefault(eq("custom"), any(MutableBoolean.class)); verifyNoMoreInteractions(loader); + assertThat(logTester.logs(LoggerLevel.WARN)).contains("Ability to set quality profile from command line using '" + ModuleQProfiles.SONAR_PROFILE_PROP + + "' is deprecated and will be dropped in a future SonarQube version. Please configure quality profile used by your project on SonarQube server."); } private void assertResponse(ModuleQProfiles qps) { |