本文整理汇总了Java中org.sonar.api.batch.sensor.issue.Issue类的典型用法代码示例。如果您正苦于以下问题:Java Issue类的具体用法?Java Issue怎么用?Java Issue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Issue类属于org.sonar.api.batch.sensor.issue包,在下文中一共展示了Issue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testOnClasses
import org.sonar.api.batch.sensor.issue.Issue; //导入依赖的package包/类
@Test
public void testOnClasses() {
settings.setProperty(PackageAnalyzerProperties.ISSUE_MODE_KEY, PackageAnalyzerProperties.ISSUE_MODE_CLASS);
settings.setProperty(PackageAnalyzerProperties.CLASS_MODE_KEY, PackageAnalyzerProperties.CLASS_MODE_ALL);
final Model<Location> model = createModel();
subject.scanModel(sensorContext, activeRule, model);
// Check two issues on packageC
Assert.assertEquals(2, sensorContext.allIssues().size());
final Map<String,Issue> issues = sensorContext.allIssues().stream().collect(Collectors.toMap(issue -> issue.primaryLocation().inputComponent().key(),
Function.identity()));
issues.containsKey(BaseRuleTest.PROJECT_KEY + ":packageC/ClassA.java");
issues.containsKey(BaseRuleTest.PROJECT_KEY + ":packageC/ClassB.java");
}
示例2: testOnClasses
import org.sonar.api.batch.sensor.issue.Issue; //导入依赖的package包/类
@Test
public void testOnClasses() {
settings.setProperty(PackageAnalyzerProperties.ISSUE_MODE_KEY, PackageAnalyzerProperties.ISSUE_MODE_CLASS);
final Model<Location> model = createModel();
subject.scanModel(sensorContext, activeRule, model);
// Check two issues on packageA
Assert.assertEquals(2, sensorContext.allIssues().size());
Map<String,Issue> issues = sensorContext.allIssues().stream().collect(Collectors.toMap(issue -> issue.primaryLocation().inputComponent().key(),
Function.identity()));
issues.containsKey(BaseRuleTest.PROJECT_KEY + ":packageA/ClassA.java");
issues.containsKey(BaseRuleTest.PROJECT_KEY + ":packageA/ClassC.java");
}
开发者ID:willemsrb,项目名称:sonar-packageanalyzer-plugin,代码行数:17,代码来源:NumberOfClassesAndInterfacesRuleTest.java
示例3: test
import org.sonar.api.batch.sensor.issue.Issue; //导入依赖的package包/类
@Test
public void test() {
final Model<Location> model = createModel();
subject.scanModel(sensorContext, activeRule, model);
// Check one issue on packageA
Assert.assertEquals(1, sensorContext.allIssues().size());
final Issue issue = sensorContext.allIssues().iterator().next();
final String message = issue.primaryLocation().message();
System.out.println("Message: " + message);
Assert.assertEquals(BaseRuleTest.PROJECT_KEY + ":packageA/package-info.java",
issue.primaryLocation().inputComponent().key());
Assert.assertEquals(
"Reduce number of packages used by this package to lower instability (allowed: 75%, actual: 100%)",
message);
}
示例4: testOnClasses
import org.sonar.api.batch.sensor.issue.Issue; //导入依赖的package包/类
@Test
public void testOnClasses() {
settings.setProperty(PackageAnalyzerProperties.ISSUE_MODE_KEY, PackageAnalyzerProperties.ISSUE_MODE_CLASS);
final Model<Location> model = createModel();
subject.scanModel(sensorContext, activeRule, model);
// Check two issues on packageA
Assert.assertEquals(2, sensorContext.allIssues().size());
Map<String,Issue> issues = sensorContext.allIssues().stream().collect(Collectors.toMap(issue -> issue.primaryLocation().inputComponent().key(),
Function.identity()));
issues.containsKey(BaseRuleTest.PROJECT_KEY + ":packageA/ClassB.java");
issues.containsKey(BaseRuleTest.PROJECT_KEY + ":packageA/ClassC.java");
}
示例5: store
import org.sonar.api.batch.sensor.issue.Issue; //导入依赖的package包/类
@Override
public void store(Issue issue) {
InputComponent inputComponent = issue.primaryLocation().inputComponent();
DefaultRule rule = validateRule(issue);
ActiveRule activeRule = activeRules.find(issue.ruleKey());
if (activeRule == null) {
// rule does not exist or is not enabled -> ignore the issue
return;
}
String primaryMessage = Strings.isNullOrEmpty(issue.primaryLocation().message()) ? rule.name() : issue.primaryLocation().message();
org.sonar.api.batch.rule.Severity overriddenSeverity = issue.overriddenSeverity();
String severity = overriddenSeverity != null ? overriddenSeverity.name() : activeRule.severity();
String type = rule.type();
DefaultClientIssue newIssue = new DefaultClientIssue(severity, type, activeRule, rules.find(activeRule.ruleKey()), primaryMessage, issue.primaryLocation().textRange(),
inputComponent.isFile() ? ((SonarLintInputFile) inputComponent).getClientInputFile() : null, issue.flows());
issueListener.handle(newIssue);
}
示例6: should_raise_an_issue_because_the_parsing_error_rule_is_activated
import org.sonar.api.batch.sensor.issue.Issue; //导入依赖的package包/类
@Test
public void should_raise_an_issue_because_the_parsing_error_rule_is_activated() {
inputFile("parsingError.css");
ActiveRules activeRules = (new ActiveRulesBuilder())
.create(RuleKey.of(CheckList.CSS_REPOSITORY_KEY, "S2260"))
.activate()
.build();
checkFactory = new CheckFactory(activeRules);
context.setActiveRules(activeRules);
createCssSquidSensor().execute(context);
Collection<Issue> issues = context.allIssues();
assertThat(issues).hasSize(1);
Issue issue = issues.iterator().next();
assertThat(issue.primaryLocation().textRange().start().line()).isEqualTo(1);
}
示例7: should_raise_an_issue_because_the_parsing_error_rule_is_activated
import org.sonar.api.batch.sensor.issue.Issue; //导入依赖的package包/类
@Test
public void should_raise_an_issue_because_the_parsing_error_rule_is_activated() {
inputFile("parsingError.less");
ActiveRules activeRules = (new ActiveRulesBuilder())
.create(RuleKey.of(CheckList.LESS_REPOSITORY_KEY, "S2260"))
.activate()
.build();
checkFactory = new CheckFactory(activeRules);
context.setActiveRules(activeRules);
createLessSquidSensor().execute(context);
Collection<Issue> issues = context.allIssues();
assertThat(issues).hasSize(1);
Issue issue = issues.iterator().next();
assertThat(issue.primaryLocation().textRange().start().line()).isEqualTo(1);
}
示例8: should_raise_an_issue_because_the_parsing_error_rule_is_activated
import org.sonar.api.batch.sensor.issue.Issue; //导入依赖的package包/类
@Test
public void should_raise_an_issue_because_the_parsing_error_rule_is_activated() {
inputFile("parsingError.scss");
ActiveRules activeRules = (new ActiveRulesBuilder())
.create(RuleKey.of(CheckList.SCSS_REPOSITORY_KEY, "S2260"))
.activate()
.build();
checkFactory = new CheckFactory(activeRules);
context.setActiveRules(activeRules);
createScssSquidSensor().execute(context);
Collection<Issue> issues = context.allIssues();
assertThat(issues).hasSize(1);
Issue issue = issues.iterator().next();
assertThat(issue.primaryLocation().textRange().start().line()).isEqualTo(1);
}
示例9: test_issues_get_imported
import org.sonar.api.batch.sensor.issue.Issue; //导入依赖的package包/类
@Test
public void test_issues_get_imported() throws FileNotFoundException {
SensorContextTester tester = SensorContextTester.create(TEST_DATA_DIR);
DefaultInputFile inputFile = new DefaultInputFile("dummyKey", TEST_FILE_PATH)
.initMetadata(new FileMetadata().readMetadata(new FileReader(TEST_FILE)));
tester.fileSystem().add(inputFile);
File protobuf = new File(TEST_DATA_DIR, ISSUES_OUTPUT_PROTOBUF_NAME);
assertThat(protobuf.isFile()).withFailMessage("no such file: " + protobuf).isTrue();
new IssuesImporter(tester, "dummy", f -> true).accept(protobuf.toPath());
Collection<Issue> issues = tester.allIssues();
assertThat(issues).hasSize(6);
assertThat(issues.stream().map(p -> p.ruleKey().rule()).collect(Collectors.toList()))
.containsOnly("S1186", "S1172", "S1118", "S101", "S101", "S105");
TextRange exactLocation = issues.stream().filter(i -> i.ruleKey().rule().equals("S1186")).findFirst().get().primaryLocation().textRange();
assertThat(exactLocation.start().line() != exactLocation.end().line() || exactLocation.start().lineOffset() != exactLocation.end().lineOffset()).isTrue();
exactLocation = issues.stream().filter(i -> i.ruleKey().rule().equals("S105")).findFirst().get().primaryLocation().textRange();
assertThat(exactLocation).isNull();
}
示例10: i_have_an_issue_with_rules_key_on_file
import org.sonar.api.batch.sensor.issue.Issue; //导入依赖的package包/类
@Then("^I have an issue with rules key \"([^\"]*)\" on file \"([^\"]*)\"$")
public void i_have_an_issue_with_rules_key_on_file(String rulesKey, String fileName) throws Throwable {
Issue findedIssue = null;
for (Issue _issue: this.context.allIssues()
) {
if (_issue.ruleKey().rule().equals(rulesKey)) {
InputFile ruleInputFile = ((InputFile)_issue.primaryLocation().inputComponent());
if (ruleInputFile.language().equals("gherkin")) {
if (ruleInputFile.relativePath().equals(fileName)) {
findedIssue = _issue;
break;
}
}
}
}
assertThat(findedIssue).isNotNull();
}
示例11: should_raise_an_issue_because_the_parsing_error_rule_is_activated
import org.sonar.api.batch.sensor.issue.Issue; //导入依赖的package包/类
@Test
public void should_raise_an_issue_because_the_parsing_error_rule_is_activated() {
String relativePath = "parsing-error.feature";
inputFile(relativePath, Charsets.UTF_8);
ActiveRules activeRules = (new ActiveRulesBuilder())
.create(RuleKey.of(GherkinRulesDefinition.REPOSITORY_KEY, "S2260"))
.activate()
.build();
checkFactory = new CheckFactory(activeRules);
context.setActiveRules(activeRules);
createGherkinSquidSensor().execute(context);
Collection<Issue> issues = context.allIssues();
assertThat(issues).hasSize(1);
Issue issue = issues.iterator().next();
assertThat(issue.primaryLocation().textRange().start().line()).isEqualTo(1);
}
示例12: should_raise_an_issue_because_the_parsing_error_rule_is_activated
import org.sonar.api.batch.sensor.issue.Issue; //导入依赖的package包/类
@Test
public void should_raise_an_issue_because_the_parsing_error_rule_is_activated() {
String relativePath = "parsingError.properties";
inputFile(relativePath, Charsets.ISO_8859_1);
ActiveRules activeRules = (new ActiveRulesBuilder())
.create(RuleKey.of(GenericJavaPropertiesRulesDefinition.GENERIC_REPOSITORY_KEY, "S2260"))
.activate()
.build();
checkFactory = new CheckFactory(activeRules);
context.setActiveRules(activeRules);
createJavaPropertiesSquidSensor().execute(context);
Collection<Issue> issues = context.allIssues();
assertThat(issues).hasSize(1);
Issue issue = issues.iterator().next();
assertThat(issue.primaryLocation().textRange().start().line()).isEqualTo(2);
}
示例13: should_raise_an_issue_because_the_parsing_error_rule_is_activated
import org.sonar.api.batch.sensor.issue.Issue; //导入依赖的package包/类
@Test
public void should_raise_an_issue_because_the_parsing_error_rule_is_activated() {
inputFile("parsingError.json");
ActiveRules activeRules = (new ActiveRulesBuilder())
.create(RuleKey.of(CheckList.REPOSITORY_KEY, "S2260"))
.activate()
.build();
checkFactory = new CheckFactory(activeRules);
context.setActiveRules(activeRules);
createJSONSquidSensor().execute(context);
Collection<Issue> issues = context.allIssues();
assertThat(issues).hasSize(1);
Issue issue = issues.iterator().next();
assertThat(issue.primaryLocation().textRange().start().line()).isEqualTo(1);
}
示例14: test
import org.sonar.api.batch.sensor.issue.Issue; //导入依赖的package包/类
@Test
public void test() {
final Model<Location> model = createModel();
subject.scanModel(sensorContext, activeRule, model);
// Check one issue on packageA
Assert.assertEquals(1, sensorContext.allIssues().size());
final Issue issue = sensorContext.allIssues().iterator().next();
final String message = issue.primaryLocation().message();
System.out.println("Message: " + message);
Assert.assertEquals(BaseRuleTest.PROJECT_KEY + ":packageC/package-info.java",
issue.primaryLocation().inputComponent().key());
Assert.assertEquals("Reduce number of packages used by this package (allowed: 1, actual: 2)", message);
}
示例15: test
import org.sonar.api.batch.sensor.issue.Issue; //导入依赖的package包/类
@Test
public void test() {
final Model<Location> model = createModel();
subject.scanModel(sensorContext, activeRule, model);
// Check one issue on packageA
Assert.assertEquals(3, sensorContext.allIssues().size());
Map<String, Issue> issues = sensorContext.allIssues().stream().collect(
Collectors.toMap(issue -> issue.primaryLocation().inputComponent().key(), Function.identity()));
issues.containsKey(BaseRuleTest.PROJECT_KEY + ":packageA/package-info.java");
issues.containsKey(BaseRuleTest.PROJECT_KEY + ":packageD/ClassB.java");
issues.containsKey(BaseRuleTest.PROJECT_KEY + ":packageD/ClassC.java");
}