本文整理汇总了Java中org.sonar.api.server.rule.RulesDefinitionXmlLoader类的典型用法代码示例。如果您正苦于以下问题:Java RulesDefinitionXmlLoader类的具体用法?Java RulesDefinitionXmlLoader怎么用?Java RulesDefinitionXmlLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RulesDefinitionXmlLoader类属于org.sonar.api.server.rule包,在下文中一共展示了RulesDefinitionXmlLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: define
import org.sonar.api.server.rule.RulesDefinitionXmlLoader; //导入依赖的package包/类
@Override
public void define(Context context) {
try (
Reader xmlStreamValidationReader = xmlFactory.newRulesXmlReader();
Reader xmlStreamRulesDefinitionReader = xmlFactory.newRulesXmlReader();
Reader xsdStreamReader = xmlFactory.newRulesXsdReader()
) {
StreamSource xsdStreamSource = new StreamSource(xsdStreamReader);
StreamSource xmlStreamSource = new StreamSource(xmlStreamValidationReader);
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = schemaFactory.newSchema(xsdStreamSource);
Validator validator = schema.newValidator();
validator.validate(xmlStreamSource);
NewRepository repo = context.createRepository(repositoryKey(), "php").setName(repositoryName());
RulesDefinitionXmlLoader xmlLoader = new RulesDefinitionXmlLoader();
xmlLoader.load(repo, xmlStreamRulesDefinitionReader);
repo.done();
} catch (Exception e) {
throw new IllegalStateException("rules.xml not found or invalid", e);
}
}
示例2: defineRulesForLanguage
import org.sonar.api.server.rule.RulesDefinitionXmlLoader; //导入依赖的package包/类
private void defineRulesForLanguage(Context context, String repositoryKey, String repositoryName,
String languageKey) {
NewRepository repository = context.createRepository(repositoryKey, languageKey).setName(repositoryName);
try(InputStream rulesXml = this.getClass().getResourceAsStream(rulesDefinitionFilePath())) {
if (rulesXml != null) {
RulesDefinitionXmlLoader rulesLoader = new RulesDefinitionXmlLoader();
rulesLoader.load(repository, rulesXml, StandardCharsets.UTF_8.name());
addRemediationCost(repository.rules());
}
} catch (IOException e) {
throw MessageException.of("Unable to load rules defintion", e);
}
repository.done();
}
示例3: define
import org.sonar.api.server.rule.RulesDefinitionXmlLoader; //导入依赖的package包/类
@Override
public void define(Context context) {
NewRepository repository = context
.createRepository("gherkin", GherkinLanguage.KEY)
.setName(REPOSITORY_NAME);
RulesDefinitionXmlLoader loader = new RulesDefinitionXmlLoader();
loader.load(
repository,
new InputStreamReader(
getClass().getResourceAsStream("/org/silverbulleters/sonar/plugins/gherkin/rules.xml"),
Charsets.UTF_8
)
);
repository.done();
}
示例4: defineRulesForLanguage
import org.sonar.api.server.rule.RulesDefinitionXmlLoader; //导入依赖的package包/类
private void defineRulesForLanguage(final Context context) {
final String[] paths = settings.getStringArray(Constants.PLUGIN_CUSTOM_RULES_PATH);
final String rulesPrefix = settings.getString(Constants.PLUGIN_CUSTOM_RULES_PREFIX);
final Map<String, SqlRules> rules = provider.getRules(null, rulesPrefix, paths);
for (final String key : rules.keySet()) {
final SqlRules type = rules.get(key);
final String repositoryKey = type.getRepoKey();
final String repositoryName = type.getRepoName();
final NewRepository repository = context.createRepository(repositoryKey, TSQLLanguage.KEY)
.setName(repositoryName);
try {
InputStream rulesXml = new FileInputStream(key);
if (rulesXml != null) {
final RulesDefinitionXmlLoader rulesLoader = new RulesDefinitionXmlLoader();
rulesLoader.load(repository, rulesXml, StandardCharsets.UTF_8.name());
}
} catch (FileNotFoundException e) {
LOGGER.info("File was not found: " + key);
}
repository.done();
}
}
示例5: define
import org.sonar.api.server.rule.RulesDefinitionXmlLoader; //导入依赖的package包/类
@Override
public void define(final Context context) {
try {
final SqlRules rules = this.provider.getRules();
final String rulesXml = PluginHelper.ruleToString(rules);
final NewRepository repository = context.createRepository(rules.getRepoKey(), TSQLLanguage.KEY)
.setName(rules.getRepoName());
final RulesDefinitionXmlLoader rulesLoader = new RulesDefinitionXmlLoader();
rulesLoader.load(repository, IOUtils.toInputStream(rulesXml, "UTF-8"), StandardCharsets.UTF_8.name());
repository.done();
} catch (final Throwable e) {
LOGGER.warn("Error occured loading custom plugin rules.", e);
}
}
示例6: addCoreComponents
import org.sonar.api.server.rule.RulesDefinitionXmlLoader; //导入依赖的package包/类
private void addCoreComponents() {
add(StandaloneRuleDefinitionsLoader.class,
new StandaloneRulesProvider(),
RuleFinderCompatibility.class,
RulesDefinitionXmlLoader.class,
XMLProfileParser.class,
StandaloneActiveRulesProvider.class,
// for cfamily plugin
new MapSettings());
}
示例7: defineRulesForLanguage
import org.sonar.api.server.rule.RulesDefinitionXmlLoader; //导入依赖的package包/类
private void defineRulesForLanguage(final Context context, final String repositoryKey, final String repositoryName,
String languageKey) {
final NewRepository repository = context.createRepository(repositoryKey, languageKey).setName(repositoryName);
final InputStream rulesXml = this.getClass().getResourceAsStream(rulesDefinition);
if (rulesXml != null) {
final RulesDefinitionXmlLoader rulesLoader = new RulesDefinitionXmlLoader();
rulesLoader.load(repository, rulesXml, StandardCharsets.UTF_8.name());
LOGGER.info("Loaded: " + repository.rules().size());
}
repository.done();
}
示例8: defineRulesForLanguage
import org.sonar.api.server.rule.RulesDefinitionXmlLoader; //导入依赖的package包/类
private void defineRulesForLanguage(Context context, String repositoryKey, String repositoryName,
String languageKey) {
NewRepository repository = context.createRepository(repositoryKey, languageKey).setName(repositoryName);
InputStream rulesXml = this.getClass().getResourceAsStream(rulesDefinitionFilePath());
if (rulesXml != null) {
RulesDefinitionXmlLoader rulesLoader = new RulesDefinitionXmlLoader();
rulesLoader.load(repository, rulesXml, StandardCharsets.UTF_8.name());
}
repository.done();
}
示例9: extractRulesData
import org.sonar.api.server.rule.RulesDefinitionXmlLoader; //导入依赖的package包/类
@VisibleForTesting
static void extractRulesData(NewRepository repository, String xmlRulesFilePath,
String htmlDescriptionFolder) throws IOException {
final RulesDefinitionXmlLoader ruleLoader = new RulesDefinitionXmlLoader();
try (InputStream resource = CheckstyleRulesDefinition.class
.getResourceAsStream(xmlRulesFilePath)) {
ruleLoader.load(repository, resource, "UTF-8");
}
ExternalDescriptionLoader.loadHtmlDescriptions(repository, htmlDescriptionFolder);
try (InputStream resource = CheckstyleRulesDefinition.class
.getResourceAsStream("/org/sonar/l10n/checkstyle.properties")) {
PropertyFileLoader.loadNames(repository, resource);
}
SqaleXmlLoader.load(repository, "/com/sonar/sqale/checkstyle-model.xml");
}
示例10: defineRulesForLanguage
import org.sonar.api.server.rule.RulesDefinitionXmlLoader; //导入依赖的package包/类
private void defineRulesForLanguage(final Context context) {
final NewRepository repository = context.createRepository(this.repositoryKey, TSQLLanguage.KEY)
.setName(this.repositoryName);
final InputStream rulesXml = this.getClass().getResourceAsStream(this.rulesPath);
if (rulesXml != null) {
final RulesDefinitionXmlLoader rulesLoader = new RulesDefinitionXmlLoader();
rulesLoader.load(repository, rulesXml, StandardCharsets.UTF_8.name());
}
repository.done();
}
示例11: ColdFusionSonarRulesDefinition
import org.sonar.api.server.rule.RulesDefinitionXmlLoader; //导入依赖的package包/类
public ColdFusionSonarRulesDefinition(RulesDefinitionXmlLoader rulesLoader) {
this.rulesLoader = rulesLoader;
}
示例12: SonarRulesDefinition
import org.sonar.api.server.rule.RulesDefinitionXmlLoader; //导入依赖的package包/类
public SonarRulesDefinition(RulesDefinitionXmlLoader xmlLoader) {
this.xmlLoader = xmlLoader;
}
示例13: getRepositoryOfRules
import org.sonar.api.server.rule.RulesDefinitionXmlLoader; //导入依赖的package包/类
public static RulesDefinition.Repository getRepositoryOfRules() {
SonarRulesDefinition rulesDefinition = new SonarRulesDefinition(new RulesDefinitionXmlLoader());
RulesDefinition.Context context = new RulesDefinition.Context();
rulesDefinition.define(context);
return context.repository(SonarRulesDefinition.REPOSITORY_KEY);
}
示例14: BWRulesDefinition
import org.sonar.api.server.rule.RulesDefinitionXmlLoader; //导入依赖的package包/类
public BWRulesDefinition(RulesDefinitionXmlLoader xmlLoader) {
this.xmlLoader = xmlLoader;
}
示例15: DScannerRules
import org.sonar.api.server.rule.RulesDefinitionXmlLoader; //导入依赖的package包/类
public DScannerRules(RulesDefinitionXmlLoader xmlLoader) {
this.xmlLoader = xmlLoader;
}