Search in sources :

Example 1 with BuiltInQualityProfilesDefinition

use of org.sonar.api.server.profile.BuiltInQualityProfilesDefinition in project sonarqube by SonarSource.

the class XooBuiltInQualityProfilesDefinitionTest method test_built_in_quality_profile.

@Test
public void test_built_in_quality_profile() {
    BuiltInQualityProfilesDefinition.Context context = new BuiltInQualityProfilesDefinition.Context();
    underTest.define(context);
    BuiltInQualityProfile profile = context.profile("xoo", "test BuiltInQualityProfilesDefinition");
    assertThat(profile.isDefault()).isFalse();
    assertThat(profile.name()).isEqualTo("test BuiltInQualityProfilesDefinition");
    assertThat(profile.language()).isEqualTo("xoo");
    assertThat(profile.rules()).hasSize(1);
    BuiltInQualityProfilesDefinition.BuiltInActiveRule activeRule = profile.rule(RuleKey.of("xoo", "HasTag"));
    assertThat(activeRule.overriddenSeverity()).isEqualTo("BLOCKER");
    assertThat(activeRule.overriddenParams()).hasSize(1);
    assertThat(activeRule.overriddenParam("tag").overriddenValue()).isEqualTo("TODO");
}
Also used : BuiltInQualityProfile(org.sonar.api.server.profile.BuiltInQualityProfilesDefinition.BuiltInQualityProfile) BuiltInQualityProfilesDefinition(org.sonar.api.server.profile.BuiltInQualityProfilesDefinition) Test(org.junit.Test)

Example 2 with BuiltInQualityProfilesDefinition

use of org.sonar.api.server.profile.BuiltInQualityProfilesDefinition in project sonarqube by SonarSource.

the class BuiltInQProfileRepositoryImpl method initialize.

@Override
public void initialize() {
    checkState(qProfiles == null, "initialize must be called only once");
    Profiler profiler = Profiler.create(LOGGER).startInfo("Load quality profiles");
    BuiltInQualityProfilesDefinition.Context context = new BuiltInQualityProfilesDefinition.Context();
    for (BuiltInQualityProfilesDefinition definition : definitions) {
        definition.define(context);
    }
    Map<String, Map<String, BuiltInQualityProfile>> rulesProfilesByLanguage = validateAndClean(context);
    this.qProfiles = toFlatList(rulesProfilesByLanguage);
    ensureAllLanguagesHaveAtLeastOneBuiltInQP();
    profiler.stopDebug();
}
Also used : Profiler(org.sonar.api.utils.log.Profiler) BuiltInQualityProfilesDefinition(org.sonar.api.server.profile.BuiltInQualityProfilesDefinition) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

BuiltInQualityProfilesDefinition (org.sonar.api.server.profile.BuiltInQualityProfilesDefinition)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Test (org.junit.Test)1 BuiltInQualityProfile (org.sonar.api.server.profile.BuiltInQualityProfilesDefinition.BuiltInQualityProfile)1 Profiler (org.sonar.api.utils.log.Profiler)1