本文整理汇总了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();
}
示例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");
}
示例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);
}
示例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;
}
示例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();
}
示例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));
}
示例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();
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例13: ProfileDefinitionReader
import org.sonar.api.rules.RuleFinder; //导入依赖的package包/类
public ProfileDefinitionReader(RuleFinder ruleFinder) {
this.ruleFinder = ruleFinder;
}
示例14: OneCQualityProfile
import org.sonar.api.rules.RuleFinder; //导入依赖的package包/类
public OneCQualityProfile(RuleFinder ruleFinder) {
this.ruleFinder = ruleFinder;
}
示例15: CssProfile
import org.sonar.api.rules.RuleFinder; //导入依赖的package包/类
public CssProfile(RuleFinder ruleFinder) {
this.ruleFinder = ruleFinder;
}