当前位置: 首页>>代码示例>>Java>>正文


Java RulesDefinitionXmlLoader类代码示例

本文整理汇总了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);
	}
}
 
开发者ID:Wikia,项目名称:sonar-php-rules,代码行数:26,代码来源:PHPRuleDefinitions.java

示例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();
}
 
开发者ID:sonar-perl,项目名称:sonar-perl,代码行数:17,代码来源:PerlCriticRulesDefinition.java

示例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();
}
 
开发者ID:silverbulleters,项目名称:sonar-gherkin,代码行数:18,代码来源:GherkinRulesDefinition.java

示例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();
	}

}
 
开发者ID:gretard,项目名称:sonar-tsql-plugin,代码行数:27,代码来源:CustomUserChecksRulesDefinition.java

示例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);
	}

}
 
开发者ID:gretard,项目名称:sonar-tsql-plugin,代码行数:17,代码来源:CustomPluginChecksRulesDefinition.java

示例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());
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:11,代码来源:StandaloneRuleRepositoryContainer.java

示例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();
}
 
开发者ID:gretard,项目名称:sonar-ps-plugin,代码行数:14,代码来源:ScriptAnalyzerRulesDefinition.java

示例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();
}
 
开发者ID:lequal,项目名称:sonar-frama-c-plugin,代码行数:13,代码来源:FramaCRulesDefinition.java

示例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");
}
 
开发者ID:checkstyle,项目名称:sonar-checkstyle,代码行数:16,代码来源:CheckstyleRulesDefinition.java

示例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();
}
 
开发者ID:gretard,项目名称:sonar-tsql-plugin,代码行数:13,代码来源:BaseRulesDefinition.java

示例11: ColdFusionSonarRulesDefinition

import org.sonar.api.server.rule.RulesDefinitionXmlLoader; //导入依赖的package包/类
public ColdFusionSonarRulesDefinition(RulesDefinitionXmlLoader rulesLoader) {
    this.rulesLoader = rulesLoader;
}
 
开发者ID:stepstone-tech,项目名称:sonar-coldfusion,代码行数:4,代码来源:ColdFusionSonarRulesDefinition.java

示例12: SonarRulesDefinition

import org.sonar.api.server.rule.RulesDefinitionXmlLoader; //导入依赖的package包/类
public SonarRulesDefinition(RulesDefinitionXmlLoader xmlLoader) {
  this.xmlLoader = xmlLoader;
}
 
开发者ID:startupheroes,项目名称:startupheroes-checkstyle,代码行数:4,代码来源:SonarRulesDefinition.java

示例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);
}
 
开发者ID:startupheroes,项目名称:startupheroes-checkstyle,代码行数:7,代码来源:BaseRuleTestSupport.java

示例14: BWRulesDefinition

import org.sonar.api.server.rule.RulesDefinitionXmlLoader; //导入依赖的package包/类
public BWRulesDefinition(RulesDefinitionXmlLoader xmlLoader) {
	this.xmlLoader = xmlLoader;
}
 
开发者ID:fastconnect,项目名称:tibco-codereview,代码行数:4,代码来源:BWRulesDefinition.java

示例15: DScannerRules

import org.sonar.api.server.rule.RulesDefinitionXmlLoader; //导入依赖的package包/类
public DScannerRules(RulesDefinitionXmlLoader xmlLoader) {
    this.xmlLoader = xmlLoader;
}
 
开发者ID:economicmodeling,项目名称:sonar-d-plugin,代码行数:4,代码来源:DScannerRules.java


注:本文中的org.sonar.api.server.rule.RulesDefinitionXmlLoader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。