本文整理汇总了Java中org.sonar.api.utils.ValidationMessages类的典型用法代码示例。如果您正苦于以下问题:Java ValidationMessages类的具体用法?Java ValidationMessages怎么用?Java ValidationMessages使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ValidationMessages类属于org.sonar.api.utils包,在下文中一共展示了ValidationMessages类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: before
import org.sonar.api.utils.ValidationMessages; //导入依赖的package包/类
@Before
public void before() {
messages = ValidationMessages.create();
/*
* The mocked rule finder defines 3 rules :
*
* - JavadocCheck with 2 paramters format and ignore, default priority
* is MAJOR
* - EqualsHashCodeCheck without parameters, default priority
* is BLOCKER
* - MissingOverride with 1 parameter javaFiveCompatibility,
* default priority is MINOR
*/
importer = new CheckstyleProfileImporter(newRuleFinder());
}
示例2: getExtensions
import org.sonar.api.utils.ValidationMessages; //导入依赖的package包/类
@Override
public List getExtensions() {
List extensions = new ArrayList<Object>();
extensions.add(new AbstractLanguage("vbnet") {
@Override
public String[] getFileSuffixes() {
return new String[] {".vb"};
}
});
extensions.add(new ProfileDefinition() {
@Override
public RulesProfile createProfile(ValidationMessages validation) {
RulesProfile profile = RulesProfile.create("Sonar Way", "vbnet");
profile.setDefaultProfile(true);
return profile;
}
});
return extensions;
}
示例3: importProfile
import org.sonar.api.utils.ValidationMessages; //导入依赖的package包/类
@Override
public RulesProfile importProfile(Reader reader, ValidationMessages messages) {
this.messages = messages;
profile = RulesProfile.create();
StaxParser parser = new StaxParser(new StaxParser.XmlStreamHandler() {
@Override
public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException {
rootCursor.advance();
parseRootNode(rootCursor);
}
});
try {
parser.parse(new ReaderInputStream(reader));
} catch (XMLStreamException e) {
String errorMessage = "Error parsing content";
messages.addErrorText(errorMessage + ": " + e);
LOG.error(errorMessage, e);
}
return profile;
}
示例4: test_profile_importer
import org.sonar.api.utils.ValidationMessages; //导入依赖的package包/类
@Test
public void test_profile_importer() throws Exception {
String content = "<wpf:ResourceDictionary xml:space=\"preserve\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" xmlns:s=\"clr-namespace:System;assembly=mscorlib\" xmlns:ss=\"urn:shemas-jetbrains-com:settings-storage-xaml\" xmlns:wpf=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">" +
"<s:String x:Key=\"/Default/CodeInspection/Highlighting/InspectionSeverities/=key1/@EntryIndexedValue\">WARNING</s:String>" +
"<s:String x:Key=\"/Default/CodeInspection/Highlighting/InspectionSeverities/=key2/@EntryIndexedValue\">ERROR</s:String>" +
"<s:String x:Key=\"/Default/CodeInspection/Highlighting/InspectionSeverities/=UnusedVariable_002ECompiler/@EntryIndexedValue\">HINT</s:String>" +
"<s:String x:Key=\"/Default/CodeInspection/Highlighting/InspectionSeverities/=key2/@EntryIndexedValue\">DO_NOT_SHOW</s:String>" +
"<s:String x:Key=\"/Default/CodeInspection/Highlighting/InspectionSeverities/=key2\">DO_NOT_SHOW</s:String>" +
"<s:String x:Key=\"/Default/CodeInspection/Highlighting/InspectionSeverities/=key2/@EntryIndexedValue\">INVALID_SEVERITY</s:String>" +
"<s:String x:Key=\"/other/entry\">value</s:String>" +
"<s:String>value</s:String>" +
"<s:other>value</s:other>" +
"</wpf:ResourceDictionary>";
ReSharperProfileImporter importer = new ReSharperProfileImporter(new ReSharperConfiguration("key", "key", "key"));
ValidationMessages messages = ValidationMessages.create();
RulesProfile profile = importer.importProfile(new StringReader(content), messages);
List<ActiveRule> rules = profile.getActiveRules();
assertThat(rules).hasSize(3);
Map<String, String> ruleKeys = getKeysWithSeverities(rules);
assertThat(ruleKeys.keySet()).containsOnly("key1", "key2", "UnusedVariable.Compiler");
assertThat(ruleKeys.get("key1")).isEqualTo("MAJOR");
assertThat(ruleKeys.get("key2")).isEqualTo("CRITICAL");
assertThat(ruleKeys.get("UnusedVariable.Compiler")).isEqualTo("INFO");
assertThat(messages.getErrors()).containsExactly("Skipping rule key2 because has an unexpected severity: INVALID_SEVERITY");
}
示例5: createProfile
import org.sonar.api.utils.ValidationMessages; //导入依赖的package包/类
@Override
public RulesProfile createProfile(ValidationMessages validation) {
AnnotationBasedProfileBuilder annotationBasedProfileBuilder = new AnnotationBasedProfileBuilder(ruleFinder);
return annotationBasedProfileBuilder.build(
CheckList.REPOSITORY_KEY,
CheckList.MAIN_PROFILE,
OneC.KEY,
CheckList.getChecks(),
validation);
}
示例6: profilesByLanguage
import org.sonar.api.utils.ValidationMessages; //导入依赖的package包/类
private static ListMultimap<String, RulesProfile> profilesByLanguage(ProfileDefinition[] profileDefinitions) {
ListMultimap<String, RulesProfile> byLang = ArrayListMultimap.create();
for (ProfileDefinition definition : profileDefinitions) {
ValidationMessages validation = ValidationMessages.create();
RulesProfile profile = definition.createProfile(validation);
if (profile != null && !validation.hasErrors()) {
byLang.put(StringUtils.lowerCase(profile.getLanguage()), profile);
}
}
return byLang;
}
示例7: createProfile
import org.sonar.api.utils.ValidationMessages; //导入依赖的package包/类
@Override
public RulesProfile createProfile(ValidationMessages messages) {
AnnotationBasedProfileBuilder annotationBasedProfileBuilder = new AnnotationBasedProfileBuilder(ruleFinder);
return annotationBasedProfileBuilder.build(
CheckList.CSS_REPOSITORY_KEY,
SONARQUBE_WAY_PROFILE_NAME,
CssLanguage.KEY,
CheckList.getCssChecks(),
messages);
}
示例8: createProfile
import org.sonar.api.utils.ValidationMessages; //导入依赖的package包/类
@Override
public RulesProfile createProfile(ValidationMessages messages) {
AnnotationBasedProfileBuilder annotationBasedProfileBuilder = new AnnotationBasedProfileBuilder(ruleFinder);
return annotationBasedProfileBuilder.build(
CheckList.LESS_REPOSITORY_KEY,
SONARQUBE_WAY_PROFILE_NAME,
LessLanguage.KEY,
CheckList.getLessChecks(),
messages);
}
示例9: createProfile
import org.sonar.api.utils.ValidationMessages; //导入依赖的package包/类
@Override
public RulesProfile createProfile(ValidationMessages messages) {
AnnotationBasedProfileBuilder annotationBasedProfileBuilder = new AnnotationBasedProfileBuilder(ruleFinder);
return annotationBasedProfileBuilder.build(
CheckList.SCSS_REPOSITORY_KEY,
SONARQUBE_WAY_PROFILE_NAME,
ScssLanguage.KEY,
CheckList.getScssChecks(),
messages);
}
示例10: should_create_sonarqube_way_profile
import org.sonar.api.utils.ValidationMessages; //导入依赖的package包/类
@Test
public void should_create_sonarqube_way_profile() {
ValidationMessages validation = ValidationMessages.create();
CssProfile definition = new CssProfile(universalRuleFinder());
RulesProfile profile = definition.createProfile(validation);
assertThat(profile.getName()).isEqualTo("SonarQube Way");
assertThat(profile.getLanguage()).isEqualTo("css");
assertThat(profile.getActiveRulesByRepository("css")).hasSize(73);
assertThat(validation.hasErrors()).isFalse();
}
示例11: should_create_sonarqube_way_profile
import org.sonar.api.utils.ValidationMessages; //导入依赖的package包/类
@Test
public void should_create_sonarqube_way_profile() {
ValidationMessages validation = ValidationMessages.create();
LessProfile definition = new LessProfile(universalRuleFinder());
RulesProfile profile = definition.createProfile(validation);
assertThat(profile.getName()).isEqualTo("SonarQube Way");
assertThat(profile.getLanguage()).isEqualTo("less");
assertThat(profile.getActiveRulesByRepository("less")).hasSize(73);
assertThat(validation.hasErrors()).isFalse();
}
示例12: should_create_sonarqube_way_profile
import org.sonar.api.utils.ValidationMessages; //导入依赖的package包/类
@Test
public void should_create_sonarqube_way_profile() {
ValidationMessages validation = ValidationMessages.create();
ScssProfile definition = new ScssProfile(universalRuleFinder());
RulesProfile profile = definition.createProfile(validation);
assertThat(profile.getName()).isEqualTo("SonarQube Way");
assertThat(profile.getLanguage()).isEqualTo("scss");
assertThat(profile.getActiveRulesByRepository("scss")).hasSize(84);
assertThat(validation.hasErrors()).isFalse();
}
示例13: importProfile
import org.sonar.api.utils.ValidationMessages; //导入依赖的package包/类
@Override
public RulesProfile importProfile(Reader reader, ValidationMessages messages) {
final SMInputFactory inputFactory = initStax();
final RulesProfile profile = RulesProfile.create();
try {
final Module checkerModule = loadModule(inputFactory.rootElementCursor(reader)
.advance());
for (Module rootModule : checkerModule.modules) {
final Map<String, String> rootModuleProperties = new HashMap<>(
checkerModule.properties);
rootModuleProperties.putAll(rootModule.properties);
if (StringUtils.equals(TREEWALKER_MODULE, rootModule.name)) {
processTreewalker(profile, rootModule, rootModuleProperties, messages);
}
else {
processModule(profile, CHECKER_MODULE + "/", rootModule.name,
rootModuleProperties, messages);
}
}
}
catch (XMLStreamException ex) {
final String message = "XML is not valid: " + ex.getMessage();
LOG.error(message, ex);
messages.addErrorText(message);
}
return profile;
}
示例14: processTreewalker
import org.sonar.api.utils.ValidationMessages; //导入依赖的package包/类
private void processTreewalker(RulesProfile profile, Module rootModule,
Map<String, String> rootModuleProperties, ValidationMessages messages) {
for (Module treewalkerModule : rootModule.modules) {
final Map<String, String> treewalkerModuleProperties = new HashMap<>(
rootModuleProperties);
treewalkerModuleProperties.putAll(treewalkerModule.properties);
processModule(profile, CHECKER_MODULE + "/" + TREEWALKER_MODULE + "/",
treewalkerModule.name, treewalkerModuleProperties, messages);
}
}
示例15: processModule
import org.sonar.api.utils.ValidationMessages; //导入依赖的package包/类
private void processModule(RulesProfile profile, String path, String moduleName,
Map<String, String> properties, ValidationMessages messages) {
if (isFilter(moduleName)) {
messages.addWarningText("Checkstyle filters are not imported: " + moduleName);
}
else if (!isIgnored(moduleName)) {
processRule(profile, path, moduleName, properties, messages);
}
}