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


Java RulesProfile.getActiveRules方法代码示例

本文整理汇总了Java中org.sonar.api.profiles.RulesProfile.getActiveRules方法的典型用法代码示例。如果您正苦于以下问题:Java RulesProfile.getActiveRules方法的具体用法?Java RulesProfile.getActiveRules怎么用?Java RulesProfile.getActiveRules使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.sonar.api.profiles.RulesProfile的用法示例。


在下文中一共展示了RulesProfile.getActiveRules方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test_profile_importer

import org.sonar.api.profiles.RulesProfile; //导入方法依赖的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");
}
 
开发者ID:GregBartlett,项目名称:sonar-resharper,代码行数:26,代码来源:ReSharperProfileImporterTest.java

示例2: createChecks

import org.sonar.api.profiles.RulesProfile; //导入方法依赖的package包/类
/**
 * Instantiate checks as defined in the RulesProfile.
 * 
 * @param profile
 */
public static List<BeanCheck> createChecks(final RulesProfile profile) {
    LOGGER.debug("Loading checks for profile " + profile.getName());

    List<BeanCheck> checks = new ArrayList<BeanCheck>();
    LOGGER.debug("SpringSensor analyse profile.getActiveRules().size(): " + profile.getActiveRules().size());

    for (ActiveRule activeRule : profile.getActiveRules()) {
    	LOGGER.debug("SpringRulesRepository createChecks activeRule: " + activeRule.toString());
        if (REPOSITORY_KEY.equals(activeRule.getRepositoryKey())) {
            Class<BeanCheck> checkClass = getCheckClass(activeRule);
        	LOGGER.debug("SpringRulesRepository createChecks checkClass.getName(): " + checkClass.getName());
            if (checkClass != null) {
                checks.add(createCheck(checkClass, activeRule));
            }
        }
    }

    return checks;
}
 
开发者ID:shmc,项目名称:sonar-spring-rules-plugin,代码行数:25,代码来源:SpringRulesRepository.java

示例3: registerProfile

import org.sonar.api.profiles.RulesProfile; //导入方法依赖的package包/类
private static void registerProfile(ActiveRulesBuilder builder, String language, Map.Entry<String, Collection<RulesProfile>> entry) {
  for (RulesProfile rp : entry.getValue()) {
    for (ActiveRule ar : rp.getActiveRules()) {
      NewActiveRule newAr = builder.create(RuleKey.of(ar.getRepositoryKey(), ar.getRuleKey()))
        .setLanguage(language)
        .setName(ar.getRule().getName())
        .setSeverity(ar.getSeverity().name())
        .setInternalKey(ar.getConfigKey());
      for (ActiveRuleParam param : ar.getActiveRuleParams()) {
        newAr.setParam(param.getKey(), param.getValue());
      }
      newAr.activate();
    }
  }
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:16,代码来源:StandaloneActiveRulesProvider.java

示例4: definesUnexpectedRules

import org.sonar.api.profiles.RulesProfile; //导入方法依赖的package包/类
@Test
public void definesUnexpectedRules() {
    RulesProfile profile = this.ruleProfile.createProfile(this.validationMessages);

    for (ActiveRule rule : profile.getActiveRules()) {
        assertTrue("Unexpected rule in plugin: " + rule.getRuleKey(), this.expectedRuleNames.contains(rule.getRuleKey()));
    }
}
 
开发者ID:Pablissimo,项目名称:SonarTsPlugin,代码行数:9,代码来源:TypeScriptRuleProfileTest.java

示例5: test_profile_importer

import org.sonar.api.profiles.RulesProfile; //导入方法依赖的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>" +
    "</wpf:ResourceDictionary>";
  CSharpReSharperProvider.CSharpReSharperProfileImporter importer = new CSharpReSharperProvider.CSharpReSharperProfileImporter();
  ValidationMessages messages = ValidationMessages.create();
  RulesProfile profile = importer.importProfile(new StringReader(content), messages);
  List<ActiveRule> rules = profile.getActiveRules();
  assertThat(rules).hasSize(1);
  assertThat(messages.getErrors()).isEmpty();
}
 
开发者ID:GregBartlett,项目名称:sonar-resharper,代码行数:13,代码来源:CSharpReSharperProviderTest.java

示例6: test_invalid_xml

import org.sonar.api.profiles.RulesProfile; //导入方法依赖的package包/类
@Test
public void test_invalid_xml() 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\">\n" +
    "  <s:String x:Key=\"/Defa";
  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).isEmpty();
  List<String> errors = messages.getErrors();
  assertThat(errors).hasSize(1);
  assertThat(errors.get(0)).startsWith("Error parsing content: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF ");
}
 
开发者ID:GregBartlett,项目名称:sonar-resharper,代码行数:14,代码来源:ReSharperProfileImporterTest.java

示例7: test_invalid_root_element

import org.sonar.api.profiles.RulesProfile; //导入方法依赖的package包/类
@Test
public void test_invalid_root_element() throws Exception {
  String content = "<bad 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\">\n" +
    "  <s:String x:Key=\"/Default/CodeInspection/Highlighting/InspectionSeverities/=key1/@EntryIndexedValue\">WARNING</s:String>\n" +
    "</bad>";
  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).isEmpty();
  assertThat(messages.getErrors()).containsExactly("Expected element: wpf:ResourceDictionary, actual: bad");
}
 
开发者ID:GregBartlett,项目名称:sonar-resharper,代码行数:13,代码来源:ReSharperProfileImporterTest.java

示例8: test_profile_importer

import org.sonar.api.profiles.RulesProfile; //导入方法依赖的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>" +
    "</wpf:ResourceDictionary>";
  ReSharperProfileImporter importer = new VBNetReSharperProvider.VBNetReSharperProfileImporter();
  ValidationMessages messages = ValidationMessages.create();
  RulesProfile profile = importer.importProfile(new StringReader(content), messages);
  List<ActiveRule> rules = profile.getActiveRules();
  assertThat(rules).hasSize(1);
  assertThat(messages.getErrors()).isEmpty();
}
 
开发者ID:GregBartlett,项目名称:sonar-resharper,代码行数:13,代码来源:VBNetReSharperProviderTest.java

示例9: IssuesChecker

import org.sonar.api.profiles.RulesProfile; //导入方法依赖的package包/类
public IssuesChecker(Settings settings, RulesProfile profile) {
  oldDumpFile = getFile(settings, LITSPlugin.OLD_DUMP_PROPERTY);
  newDumpFile = getFile(settings, LITSPlugin.NEW_DUMP_PROPERTY);
  differencesFile = getFile(settings, LITSPlugin.DIFFERENCES_PROPERTY);
  for (ActiveRule activeRule : profile.getActiveRules()) {
    if (!activeRule.getSeverity().toString().equals(Severity.INFO)) {
      throw MessageException.of("Rule '" + activeRule.getRepositoryKey() + ":" + activeRule.getRuleKey() + "' must be declared with severity INFO");
    }
  }
}
 
开发者ID:SonarSource,项目名称:sonar-lits,代码行数:11,代码来源:IssuesChecker.java

示例10: hasActiveRules

import org.sonar.api.profiles.RulesProfile; //导入方法依赖的package包/类
private boolean hasActiveRules(final RulesProfile profile) {
    for (ActiveRule activeRule : profile.getActiveRules()) {
        if (SpringRulesRepository.REPOSITORY_KEY.equals(activeRule.getRepositoryKey())) {
            return true;
        }
    }
    return false;
}
 
开发者ID:shmc,项目名称:sonar-spring-rules-plugin,代码行数:9,代码来源:SpringSensor.java


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