use of org.sonar.scanner.rule.ModuleQProfiles in project sonarqube by SonarSource.
the class QualityProfileProviderTest method testProvide.
@Test
public void testProvide() {
when(loader.load(eq("project"), isNull(String.class))).thenReturn(response);
ModuleQProfiles qps = qualityProfileProvider.provide(key, loader, projectRepo, props);
assertResponse(qps);
verify(loader).load(eq("project"), isNull(String.class));
verifyNoMoreInteractions(loader);
}
use of org.sonar.scanner.rule.ModuleQProfiles in project sonarqube by SonarSource.
the class QualityProfileProviderTest method testProfilePropDefault.
@Test
public void testProfilePropDefault() {
when(projectRepo.exists()).thenReturn(false);
when(loader.loadDefault(eq("custom"))).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);
assertResponse(qps);
verify(loader).loadDefault(eq("custom"));
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.");
}
use of org.sonar.scanner.rule.ModuleQProfiles in project sonarqube by SonarSource.
the class ActiveRulesProviderTest method testCombinationOfRules.
@Test
public void testCombinationOfRules() {
LoadedActiveRule r1 = mockRule("rule1");
LoadedActiveRule r2 = mockRule("rule2");
LoadedActiveRule r3 = mockRule("rule3");
List<LoadedActiveRule> qp1Rules = ImmutableList.of(r1, r2);
List<LoadedActiveRule> qp2Rules = ImmutableList.of(r2, r3);
List<LoadedActiveRule> qp3Rules = ImmutableList.of(r1, r3);
when(loader.load(eq("qp1"))).thenReturn(qp1Rules);
when(loader.load(eq("qp2"))).thenReturn(qp2Rules);
when(loader.load(eq("qp3"))).thenReturn(qp3Rules);
ModuleQProfiles profiles = mockProfiles("qp1", "qp2", "qp3");
ActiveRules activeRules = provider.provide(loader, profiles);
assertThat(activeRules.findAll()).hasSize(3);
assertThat(activeRules.findAll()).extracting("ruleKey").containsOnly(RuleKey.of("rule1", "rule1"), RuleKey.of("rule2", "rule2"), RuleKey.of("rule3", "rule3"));
verify(loader).load(eq("qp1"));
verify(loader).load(eq("qp2"));
verify(loader).load(eq("qp3"));
verifyNoMoreInteractions(loader);
}
use of org.sonar.scanner.rule.ModuleQProfiles in project sonarqube by SonarSource.
the class QualityProfileProvider method provide.
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));
} else {
profileList = loader.load(projectKey.get(), getSonarProfile(props));
}
profiler.stopInfo();
profiles = new ModuleQProfiles(profileList);
}
return profiles;
}
use of org.sonar.scanner.rule.ModuleQProfiles in project sonarqube by SonarSource.
the class QualityProfileProviderTest method testProfileProp.
@Test
public void testProfileProp() {
when(loader.load(eq("project"), eq("custom"))).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);
assertResponse(qps);
verify(loader).load(eq("project"), eq("custom"));
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.");
}
Aggregations