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


Java RuleFinder类代码示例

本文整理汇总了Java中org.sonar.api.rules.RuleFinder的典型用法代码示例。如果您正苦于以下问题:Java RuleFinder类的具体用法?Java RuleFinder怎么用?Java RuleFinder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: load_profile_keys

import org.sonar.api.rules.RuleFinder; //导入依赖的package包/类
@Test
public void load_profile_keys() throws Exception {
  ruleFinder = mock(RuleFinder.class);
  when(ruleFinder.findByKey(anyString(), anyString())).thenAnswer(new Answer<Rule>() {
    @Override
    public Rule answer(InvocationOnMock iom) throws Throwable {
      String repositoryKey = (String) iom.getArguments()[0];
      String ruleKey = (String) iom.getArguments()[1];
      return Rule.create(repositoryKey, ruleKey, ruleKey);
    }
  });

  RulesProfile profile = RulesProfile.create("profile-name", "lang-key");
  ProfileDefinitionReader definitionReader = new ProfileDefinitionReader(ruleFinder);
  definitionReader.activateRules(profile, "repo-key", "org/sonarsource/analyzer/commons/Sonar_way_profile.json");
  assertThat(profile.getActiveRules()).hasSize(2);
  assertThat(profile.getActiveRule("repo-key", "S100")).isNotNull();
  assertThat(profile.getActiveRule("repo-key", "S110")).isNotNull();
  assertThat(profile.getActiveRule("repo-key", "S123")).isNull();
  assertThat(profile.getActiveRule("repo-key", "S666")).isNull();
}
 
开发者ID:SonarSource,项目名称:sonar-analyzer-commons,代码行数:22,代码来源:ProfileDefinitionReaderTest.java

示例2: fails_with_non_existing_rule_key

import org.sonar.api.rules.RuleFinder; //导入依赖的package包/类
@Test
public void fails_with_non_existing_rule_key() throws Exception {
  ruleFinder = mock(RuleFinder.class);
  when(ruleFinder.findByKey(anyString(), anyString())).thenAnswer(new Answer<Rule>() {
    @Override
    public Rule answer(InvocationOnMock iom) throws Throwable {
      String repositoryKey = (String) iom.getArguments()[0];
      String ruleKey = (String) iom.getArguments()[1];
      if (ruleKey.equals("S666")) {
        return null;
      }
      return Rule.create(repositoryKey, ruleKey, ruleKey);
    }
  });

  RulesProfile profile = RulesProfile.create("profile-name", "lang-key");
  ProfileDefinitionReader definitionReader = new ProfileDefinitionReader(ruleFinder);

  thrown.expect(IllegalStateException.class);
  thrown.expectMessage("Failed to activate rule with key 'S666'. No corresponding rule found in repository with key 'repo-key'.");

  definitionReader.activateRules(profile, "repo-key", "org/sonarsource/analyzer/commons/Sonar_way_profile_invalid.json");
}
 
开发者ID:SonarSource,项目名称:sonar-analyzer-commons,代码行数:24,代码来源:ProfileDefinitionReaderTest.java

示例3: init

import org.sonar.api.rules.RuleFinder; //导入依赖的package包/类
@Before
public void init() throws Exception {
  sonarIssue = new DefaultIssue()
    .setKey("ABCD")
    .setMessage("The Cyclomatic Complexity of this method is 14 which is greater than 10 authorized.")
    .setSeverity("MINOR")
    .setRuleKey(RuleKey.of("squid", "CycleBetweenPackages"));

  ruleFinder = mock(RuleFinder.class);
  when(ruleFinder.findByKey(RuleKey.of("squid", "CycleBetweenPackages"))).thenReturn(org.sonar.api.rules.Rule.create().setName("Avoid cycle between java packages"));

  settings = new Settings(new PropertyDefinitions(JiraIssueCreator.class, JiraPlugin.class));
  settings.setProperty(CoreProperties.SERVER_BASE_URL, "http://my.sonar.com");
  settings.setProperty(JiraConstants.SERVER_URL_PROPERTY, "http://my.jira.com");
  settings.setProperty(JiraConstants.USERNAME_PROPERTY, "foo");
  settings.setProperty(JiraConstants.PASSWORD_PROPERTY, "bar");
  settings.setProperty(JiraConstants.JIRA_PROJECT_KEY_PROPERTY, "TEST");

  jiraIssueCreator = new JiraIssueCreator(ruleFinder);
}
 
开发者ID:aifraenkel,项目名称:caltec-tools,代码行数:21,代码来源:JiraIssueCreatorTest.java

示例4: universalRuleFinder

import org.sonar.api.rules.RuleFinder; //导入依赖的package包/类
private RuleFinder universalRuleFinder() {
  RuleFinder ruleFinder = mock(RuleFinder.class);
  when(ruleFinder.findByKey(anyString(), anyString())).thenAnswer(
    iom -> Rule.create((String) iom.getArguments()[0], (String) iom.getArguments()[1], (String) iom.getArguments()[1]));

  return ruleFinder;
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:8,代码来源:CssProfileTest.java

示例5: ruleFinder

import org.sonar.api.rules.RuleFinder; //导入依赖的package包/类
RuleFinder ruleFinder() {
  return when(ruleFinder.findByKey(anyString(), anyString())).thenAnswer(new Answer<Rule>() {
    @Override
    public Rule answer(InvocationOnMock invocation) {
      Object[] arguments = invocation.getArguments();
      return Rule.create((String) arguments[0], (String) arguments[1], (String) arguments[1]);
    }
  }).getMock();
}
 
开发者ID:sonar-perl,项目名称:sonar-perl,代码行数:10,代码来源:SonarWayProfileTest.java

示例6: testCreateSonarWayProfile

import org.sonar.api.rules.RuleFinder; //导入依赖的package包/类
@Test
public void testCreateSonarWayProfile() {
    ValidationMessages validation = ValidationMessages.create();

    RuleFinder ruleFinder = buildRuleFinder();
    ApexProfile definition = new ApexProfile(ruleFinder);
    RulesProfile profile = definition.createProfile(validation);

    assertThat(profile.getLanguage(), equalTo(Apex.KEY));
    assertThat(profile.getName(), equalTo(CheckList.SONAR_WAY_PROFILE));
    assertThat(validation.hasErrors(), is(FALSE));
}
 
开发者ID:fundacionjala,项目名称:enforce-sonarqube-plugin,代码行数:13,代码来源:ApexProfileTest.java

示例7: buildRuleFinder

import org.sonar.api.rules.RuleFinder; //导入依赖的package包/类
static RuleFinder buildRuleFinder() {
    Rule rule = mock(RuleFinder.class).findByKey(anyString(), anyString());
    return when(rule).thenAnswer((InvocationOnMock invocation) -> {
        Object[] arguments = invocation.getArguments();
        return Rule.create(String.valueOf(arguments[0]),
                String.valueOf(arguments[1]),
                String.valueOf(arguments[1]));
    }).getMock();
}
 
开发者ID:fundacionjala,项目名称:enforce-sonarqube-plugin,代码行数:10,代码来源:ApexProfileTest.java

示例8: universalRuleFinder

import org.sonar.api.rules.RuleFinder; //导入依赖的package包/类
private RuleFinder universalRuleFinder() {
  RuleFinder ruleFinder = mock(RuleFinder.class);
  when(ruleFinder.findByKey(anyString(), anyString())).thenAnswer(new Answer<Rule>() {
    @Override
    public Rule answer(InvocationOnMock iom) throws Throwable {
      return Rule.create((String) iom.getArguments()[0], (String) iom.getArguments()[1], (String) iom.getArguments()[1]);
    }
  });

  return ruleFinder;
}
 
开发者ID:racodond,项目名称:sonar-gherkin-plugin,代码行数:12,代码来源:GherkinProfileTest.java

示例9: should_create_sonar_way_profile

import org.sonar.api.rules.RuleFinder; //导入依赖的package包/类
@Test
public void should_create_sonar_way_profile() {
  ValidationMessages validation = ValidationMessages.create();

  RuleFinder ruleFinder = ruleFinder();
  XmlSonarWayProfile definition = new XmlSonarWayProfile(ruleFinder);
  RulesProfile profile = definition.createProfile(validation);

  assertThat(profile.getLanguage()).isEqualTo(Xml.KEY);
  assertThat(profile.getName()).isEqualTo(RulesProfile.SONAR_WAY_NAME);
  assertThat(profile.getActiveRulesByRepository(CheckRepository.REPOSITORY_KEY)).hasSize(1);
  assertThat(validation.hasErrors()).isFalse();
}
 
开发者ID:SonarSource,项目名称:sonar-xml,代码行数:14,代码来源:XmlSonarWayProfileTest.java

示例10: ruleFinder

import org.sonar.api.rules.RuleFinder; //导入依赖的package包/类
static RuleFinder ruleFinder() {
  return when(mock(RuleFinder.class).findByKey(Mockito.anyString(), Mockito.anyString())).thenAnswer(new Answer<Rule>() {
    public Rule answer(InvocationOnMock invocation) {
      Object[] arguments = invocation.getArguments();
      return Rule.create((String) arguments[0], (String) arguments[1], (String) arguments[1]);
    }
  }).getMock();
}
 
开发者ID:SonarSource,项目名称:sonar-xml,代码行数:9,代码来源:XmlSonarWayProfileTest.java

示例11: should_create_sonar_way_profile

import org.sonar.api.rules.RuleFinder; //导入依赖的package包/类
@Test
public void should_create_sonar_way_profile() {
  ValidationMessages validation = ValidationMessages.create();

  RuleFinder ruleFinder = ruleFinder();
  LuaProfile definition = new LuaProfile(ruleFinder);
  RulesProfile profile = definition.createProfile(validation);

  assertThat(profile.getLanguage()).isEqualTo(Lua.KEY);
  assertThat(profile.getName()).isEqualTo(CheckList.SONAR_WAY_PROFILE);
  assertThat(profile.getActiveRulesByRepository(CheckList.REPOSITORY_KEY)).hasSize(15);
  assertThat(validation.hasErrors()).isFalse();
}
 
开发者ID:SonarQubeCommunity,项目名称:sonar-lua,代码行数:14,代码来源:LuaProfileTest.java

示例12: ruleFinder

import org.sonar.api.rules.RuleFinder; //导入依赖的package包/类
static RuleFinder ruleFinder() {
  return when(mock(RuleFinder.class).findByKey(anyString(), anyString())).thenAnswer(new Answer<Rule>() {
    @Override
    public Rule answer(InvocationOnMock invocation) {
      Object[] arguments = invocation.getArguments();
      return Rule.create((String) arguments[0], (String) arguments[1], (String) arguments[1]);
    }
  }).getMock();
}
 
开发者ID:SonarQubeCommunity,项目名称:sonar-lua,代码行数:10,代码来源:LuaProfileTest.java

示例13: ProfileDefinitionReader

import org.sonar.api.rules.RuleFinder; //导入依赖的package包/类
public ProfileDefinitionReader(RuleFinder ruleFinder) {
  this.ruleFinder = ruleFinder;
}
 
开发者ID:SonarSource,项目名称:sonar-analyzer-commons,代码行数:4,代码来源:ProfileDefinitionReader.java

示例14: OneCQualityProfile

import org.sonar.api.rules.RuleFinder; //导入依赖的package包/类
public OneCQualityProfile(RuleFinder ruleFinder) {
    this.ruleFinder = ruleFinder;
}
 
开发者ID:antowski,项目名称:sonar-onec,代码行数:4,代码来源:OneCQualityProfile.java

示例15: CssProfile

import org.sonar.api.rules.RuleFinder; //导入依赖的package包/类
public CssProfile(RuleFinder ruleFinder) {
  this.ruleFinder = ruleFinder;
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:4,代码来源:CssProfile.java


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