- Create a built in Quality profile for the Foo language.
- implements BuiltInQualityProfilesDefinition
- can set default profile - profile.setDefault(true)
- Load the profile giving profile name and active rule set. Here active rules were given in "foo_quality_profile.json" inside ""ruleKeys""
------------------------------------------------------------------
package com.plugin.sonar.language.foo;
import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition;
import org.sonarsource.analyzer.commons.BuiltInQualityProfileJsonLoader;
import static com.plugin.sonar.util.FooConstants.*;
public class FooQualityProfile implements BuiltInQualityProfilesDefinition {
@Override
public void define(Context context) {
NewBuiltInQualityProfile profile = context.createBuiltInQualityProfile(FooSQL_QUALITY_PROFILE_NAME, LANGUAGE_KEY);
profile.setDefault(true);
BuiltInQualityProfileJsonLoader.load(profile, REPO_KEY, JSON_PROFILE_PATH);
profile.done();
}
}
-------------------------------
below is the sample "foo_quality_profile.json" with 5 active keys.
-----------------------------------------------------------------------
{
"name": "Foo Quality Profile",
"ruleKeys": [
"1",
"2",
"3",
"4",
"5"
]
}
No comments:
Post a Comment