本文整理了Java中org.sonar.api.rules.XMLRuleParser.parse()
方法的一些代码示例,展示了XMLRuleParser.parse()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLRuleParser.parse()
方法的具体详情如下:
包路径:org.sonar.api.rules.XMLRuleParser
类名称:XMLRuleParser
方法名:parse
[英]Warning : the input stream is closed in this method
[中]警告:此方法中的输入流已关闭
代码示例来源:origin: SonarSource/sonarqube
/**
* Warning : the input stream is closed in this method
*/
public List<Rule> parse(InputStream input) {
try (Reader reader = new InputStreamReader(input, UTF_8)) {
return parse(reader);
} catch (IOException e) {
throw new SonarException("Fail to load the xml stream", e);
}
}
代码示例来源:origin: SonarSource/sonarqube
public List<Rule> parse(File file) {
try (Reader reader = new InputStreamReader(FileUtils.openInputStream(file), UTF_8)) {
return parse(reader);
} catch (IOException e) {
throw new SonarException("Fail to load the file: " + file, e);
}
}
代码示例来源:origin: org.codehaus.sonar-plugins.java/sonar-checkstyle-plugin
@Override
public List<Rule> createRules() {
return xmlRuleParser.parse(getClass().getResourceAsStream("/org/sonar/plugins/checkstyle/rules.xml"));
}
}
代码示例来源:origin: org.codehaus.sonar.plugins/sonar-pmd-plugin
@Override
public List<Rule> createRules() {
InputStream input = getClass().getResourceAsStream("/org/sonar/plugins/pmd/rules-unit-tests.xml");
return xmlRuleParser.parse(input);
}
}
代码示例来源:origin: org.codehaus.sonar-plugins.dotnet/sonar-dotnet-fxcop-plugin
@Override
public List<Rule> createRules() {
List<Rule> rules = new ArrayList<Rule>();
rules.addAll(xmlRuleParser.parse(FxCopUnitTestsRuleRepository.class.getResourceAsStream("/org/sonar/plugins/csharp/fxcop/rules/rules-unit-tests.xml")));
for (File userExtensionXml : fileSystem.getExtensions(FxCopConstants.TEST_REPOSITORY_KEY, "xml")) {
rules.addAll(xmlRuleParser.parse(userExtensionXml));
}
return rules;
}
}
代码示例来源:origin: org.codehaus.sonar.plugins/sonar-checkstyle-plugin
@Override
public List<Rule> createRules() {
List<Rule> rules = Lists.newArrayList();
rules.addAll(xmlRuleParser.parse(getClass().getResourceAsStream("/org/sonar/plugins/checkstyle/rules.xml")));
for (File userExtensionXml : fileSystem.getExtensions(CheckstyleConstants.REPOSITORY_KEY, "xml")) {
rules.addAll(xmlRuleParser.parse(userExtensionXml));
}
return rules;
}
}
代码示例来源:origin: org.codehaus.sonar.plugins/sonar-pmd-plugin
@Override
public List<Rule> createRules() {
List<Rule> rules = Lists.newArrayList();
rules.addAll(xmlRuleParser.parse(getClass().getResourceAsStream("/org/sonar/plugins/pmd/rules.xml")));
for (File userExtensionXml : fileSystem.getExtensions(PmdConstants.REPOSITORY_KEY, "xml")) {
rules.addAll(xmlRuleParser.parse(userExtensionXml));
}
return rules;
}
}
代码示例来源:origin: org.codehaus.sonar-plugins.dotnet/sonar-dotnet-gendarme-plugin
@Override
public List<Rule> createRules() {
List<Rule> rules = new ArrayList<Rule>();
rules
.addAll(xmlRuleParser.parse(GendarmeUnitTestsRuleRepository.class.getResourceAsStream("/org/sonar/plugins/csharp/gendarme/rules/rules.xml")));
for (File userExtensionXml : fileSystem.getExtensions(GendarmeConstants.TEST_REPOSITORY_KEY, "xml")) {
rules.addAll(xmlRuleParser.parse(userExtensionXml));
}
return rules;
}
}
代码示例来源:origin: org.codehaus.sonar/sonar-deprecated
public List<Rule> parse(File file) {
Reader reader = null;
try {
reader = new InputStreamReader(FileUtils.openInputStream(file), CharEncoding.UTF_8);
return parse(reader);
} catch (IOException e) {
throw new SonarException("Fail to load the file: " + file, e);
} finally {
Closeables.closeQuietly(reader);
}
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-plugin-api
/**
* Warning : the input stream is closed in this method
*/
public List<Rule> parse(InputStream input) {
try (Reader reader = new InputStreamReader(input, UTF_8)) {
return parse(reader);
} catch (IOException e) {
throw new SonarException("Fail to load the xml stream", e);
}
}
代码示例来源:origin: org.codehaus.sonar-plugins.dotnet/sonar-dotnet-gendarme-plugin
@Override
public List<Rule> createRules() {
List<Rule> rules = new ArrayList<Rule>();
// Gendarme rules
rules.addAll(xmlRuleParser.parse(GendarmeRuleRepository.class.getResourceAsStream("/org/sonar/plugins/csharp/gendarme/rules/rules.xml")));
// Custom rules:
// - old fashion: XML files in the file system
for (File userExtensionXml : fileSystem.getExtensions(repositoryKey, "xml")) {
rules.addAll(xmlRuleParser.parse(userExtensionXml));
}
// - new fashion: through the Web interface
String customRules = settings.getString(GendarmeRuleRepositoryProvider.SONAR_GENDARME_CUSTOM_RULES_PROP_KEY);
if (StringUtils.isNotBlank(customRules)) {
rules.addAll(xmlRuleParser.parse(new StringReader(customRules)));
}
return rules;
}
}
代码示例来源:origin: org.codehaus.sonar/sonar-deprecated
/**
* Warning : the input stream is closed in this method
*/
public List<Rule> parse(InputStream input) {
Reader reader = null;
try {
reader = new InputStreamReader(input, CharEncoding.UTF_8);
return parse(reader);
} catch (IOException e) {
throw new SonarException("Fail to load the xml stream", e);
} finally {
Closeables.closeQuietly(reader);
}
}
代码示例来源:origin: org.codehaus.sonar-plugins.dotnet/sonar-dotnet-fxcop-plugin
@Override
public List<Rule> createRules() {
List<Rule> rules = new ArrayList<Rule>();
// FxCop rules
rules.addAll(xmlRuleParser.parse(FxCopRuleRepository.class.getResourceAsStream("/org/sonar/plugins/csharp/fxcop/rules/rules.xml")));
// Custom rules:
// - old fashion: XML files in the file system
for (File userExtensionXml : fileSystem.getExtensions(repositoryKey, "xml")) {
rules.addAll(xmlRuleParser.parse(userExtensionXml));
}
// - new fashion: through the Web interface
String customRules = settings.getString(FxCopRuleRepositoryProvider.SONAR_FXCOP_CUSTOM_RULES_PROP_KEY);
if (StringUtils.isNotBlank(customRules)) {
rules.addAll(xmlRuleParser.parse(new StringReader(customRules)));
}
return rules;
}
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-plugin-api
public List<Rule> parse(File file) {
try (Reader reader = new InputStreamReader(FileUtils.openInputStream(file), UTF_8)) {
return parse(reader);
} catch (IOException e) {
throw new SonarException("Fail to load the file: " + file, e);
}
}
代码示例来源:origin: org.codehaus.sonar-plugins/sonar-php-plugin
/**
* @see org.sonar.api.rules.RuleRepository#createRules()
*/
@Override
public List<Rule> createRules() {
List<Rule> rules = new ArrayList<Rule>();
rules.addAll(getParser().parse(getRuleInputStream()));
for (File userExtensionXml : getFileSystem().getExtensions(getRepositoryKey(), "xml")) {
rules.addAll(getParser().parse(userExtensionXml));
}
return rules;
}
内容来源于网络,如有侵权,请联系作者删除!