ItUtils.assertIssuesInJsonReport(result, 3, 0, 17);
}
+ // SONAR-8518
+ @Test
+ public void shoud_support_sonar_profile_prop() throws IOException {
+ restoreProfile("one-issue-per-line.xml");
+ restoreProfile("empty.xml");
+ orchestrator.getServer().provisionProject("sample", "xoo-sample");
+ orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "empty");
+
+ SonarRunner runner = configureRunner("shared/xoo-sample",
+ "sonar.verbose", "true",
+ "sonar.analysis.mode", "issues",
+ "sonar.profile", "one-issue-per-line");
+ BuildResult result = orchestrator.executeBuild(runner);
+ ItUtils.assertIssuesInJsonReport(result, 17, 0, 0);
+ }
+
// SONAR-5715
@Test
public void test_issues_mode_on_project_with_space_in_filename() throws IOException {
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.sonarqube.ws.QualityProfiles.SearchWsResponse.QualityProfile;
private static final String LOG_MSG = "Load quality profiles";
private ModuleQProfiles profiles = null;
- public ModuleQProfiles provide(ProjectKey projectKey, QualityProfileLoader loader, ProjectRepositories projectRepositories, AnalysisProperties props, DefaultAnalysisMode mode) {
+ public ModuleQProfiles provide(ProjectKey projectKey, QualityProfileLoader loader, ProjectRepositories projectRepositories, AnalysisProperties props) {
if (this.profiles == null) {
List<QualityProfile> profileList;
Profiler profiler = Profiler.create(LOG).startInfo(LOG_MSG);
if (!projectRepositories.exists()) {
- profileList = loader.loadDefault(getSonarProfile(props, mode));
+ profileList = loader.loadDefault(getSonarProfile(props));
} else {
- profileList = loader.load(projectKey.get(), getSonarProfile(props, mode));
+ profileList = loader.load(projectKey.get(), getSonarProfile(props));
}
profiler.stopInfo();
profiles = new ModuleQProfiles(profileList);
}
@CheckForNull
- private static String getSonarProfile(AnalysisProperties props, DefaultAnalysisMode mode) {
+ private static String getSonarProfile(AnalysisProperties props) {
String profile = null;
- if (!mode.isIssues() && props.properties().containsKey(ModuleQProfiles.SONAR_PROFILE_PROP)) {
+ if (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.");
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;
@Mock
private QualityProfileLoader loader;
@Mock
- private DefaultAnalysisMode mode;
- @Mock
private AnalysisProperties props;
@Mock
private ProjectKey key;
@Test
public void testProvide() {
when(loader.load(eq("project"), isNull(String.class))).thenReturn(response);
- ModuleQProfiles qps = qualityProfileProvider.provide(key, loader, projectRepo, props, mode);
+ ModuleQProfiles qps = qualityProfileProvider.provide(key, loader, projectRepo, props);
assertResponse(qps);
verify(loader).load(eq("project"), isNull(String.class));
public void testProjectDoesntExist() {
when(projectRepo.exists()).thenReturn(false);
when(loader.loadDefault(anyString())).thenReturn(response);
- ModuleQProfiles qps = qualityProfileProvider.provide(key, loader, projectRepo, props, mode);
+ ModuleQProfiles qps = qualityProfileProvider.provide(key, loader, projectRepo, props);
assertResponse(qps);
verify(loader).loadDefault(anyString());
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);
+ ModuleQProfiles qps = qualityProfileProvider.provide(key, loader, projectRepo, props);
assertResponse(qps);
verify(loader).load(eq("project"), eq("custom"));
+ "' is deprecated and will be dropped in a future SonarQube version. Please configure quality profile used by your project on SonarQube server.");
}
- @Test
- public void testIgnoreSonarProfileIssuesMode() {
- when(mode.isIssues()).thenReturn(true);
- when(loader.load(eq("project"), (String) eq(null))).thenReturn(response);
- when(props.property(ModuleQProfiles.SONAR_PROFILE_PROP)).thenReturn("custom");
-
- ModuleQProfiles qps = qualityProfileProvider.provide(key, loader, projectRepo, props, mode);
- assertResponse(qps);
-
- verify(loader).load(eq("project"), (String) eq(null));
- verifyNoMoreInteractions(loader);
- }
-
@Test
public void testProfilePropDefault() {
when(projectRepo.exists()).thenReturn(false);
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);
+ ModuleQProfiles qps = qualityProfileProvider.provide(key, loader, projectRepo, props);
assertResponse(qps);
verify(loader).loadDefault(eq("custom"));