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


Java Issue类代码示例

本文整理汇总了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");
}
 
开发者ID:willemsrb,项目名称:sonar-packageanalyzer-plugin,代码行数:17,代码来源:EfferentCouplingRuleTest.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);
}
 
开发者ID:willemsrb,项目名称:sonar-packageanalyzer-plugin,代码行数:18,代码来源:InstabilityRuleTest.java

示例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");
}
 
开发者ID:willemsrb,项目名称:sonar-packageanalyzer-plugin,代码行数:17,代码来源:PackageDependencyCyclesRuleTest.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);
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:21,代码来源:DefaultSensorStorage.java

示例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);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:19,代码来源:CssAnalyzerSensorTest.java

示例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);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:19,代码来源:LessAnalyzerSensorTest.java

示例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);
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:19,代码来源:ScssAnalyzerSensorTest.java

示例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();
}
 
开发者ID:SonarSource,项目名称:sonar-dotnet-shared-library,代码行数:26,代码来源:IssuesImporterTest.java

示例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();

}
 
开发者ID:silverbulleters,项目名称:sonar-gherkin,代码行数:23,代码来源:GherkinSteps.java

示例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);
}
 
开发者ID:racodond,项目名称:sonar-gherkin-plugin,代码行数:20,代码来源:GherkinSquidSensorTest.java

示例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);
}
 
开发者ID:racodond,项目名称:sonar-jproperties-plugin,代码行数:20,代码来源:JavaPropertiesSquidSensorTest.java

示例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);
}
 
开发者ID:racodond,项目名称:sonar-json-plugin,代码行数:19,代码来源:JSONSquidSensorTest.java

示例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);
}
 
开发者ID:willemsrb,项目名称:sonar-packageanalyzer-plugin,代码行数:15,代码来源:EfferentCouplingRuleTest.java

示例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");
}
 
开发者ID:willemsrb,项目名称:sonar-packageanalyzer-plugin,代码行数:15,代码来源:AbstractnessRuleTest.java


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