• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Severity类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getMetricForSeverity

import org.sonar.api.batch.rule.Severity; //导入依赖的package包/类
/**
 * Returns the metric object counting the Xanitizer findings of the given
 * severity
 * 
 * @param severity
 * @return
 */
public static Metric<Serializable> getMetricForSeverity(final Severity severity) {

	switch (severity) {
	case BLOCKER:
		return BLOCKER_FINDINGS_METRIC;
	case CRITICAL:
		return CRITICAL_FINDINGS_METRIC;
	case MAJOR:
		return MAJOR_FINDINGS_METRIC;
	case MINOR:
		return MINOR_FINDINGS_METRIC;
	case INFO:
		return INFO_FINDINGS_METRIC;
	default:
		return null;
	}
}
 
开发者ID:RIGS-IT,项目名称:sonar-xanitizer,代码行数:25,代码来源:XanitizerMetrics.java


示例2: incrementMetrics

import org.sonar.api.batch.rule.Severity; //导入依赖的package包/类
private void incrementMetrics(final XMLReportFinding xanFinding,
		final Map<Metric<Serializable>, Map<InputComponent, Integer>> metricValuesAccu,
		final DefaultInputModule project, final InputFile inputFile) {
	final Severity severity = SensorUtil.mkSeverity(xanFinding);

	final List<Metric<Serializable>> metrics = mkMetrics(xanFinding.getProblemType());
	for (final Metric<Serializable> metric : metrics) {
		incrementValueForFileAndProject(metric, inputFile, project, metricValuesAccu);
	}

	final String matchCode = xanFinding.getMatchCode();
	if ("NOT".equals(matchCode)) {
		incrementValueForFileAndProject(XanitizerMetrics.getMetricForNewXanFindings(),
				inputFile, project, metricValuesAccu);
	}

	final Metric<Serializable> metricForSeverity = XanitizerMetrics
			.getMetricForSeverity(severity);
	if (metricForSeverity != null) {
		incrementValueForFileAndProject(metricForSeverity, inputFile, project,
				metricValuesAccu);
	}
}
 
开发者ID:RIGS-IT,项目名称:sonar-xanitizer,代码行数:24,代码来源:XanitizerSensor.java


示例3: mkSeverity

import org.sonar.api.batch.rule.Severity; //导入依赖的package包/类
/**
 * Returns the severity of a SonarQube issue for the given Xanitizer finding
 * 
 * @param xanFinding
 * @return
 */
public static Severity mkSeverity(final XMLReportFinding xanFinding) {
	final String findingClassification = xanFinding.getFindingClassificationOrNull();
	if (findingClassification == null) {
		// Should not occur.
		return Severity.MINOR;
	}
	switch (findingClassification.toUpperCase()) {
	case "MUST FIX":
	case "URGENT FIX":
		return Severity.BLOCKER;

	default:
		return mkSeverityFromRating(xanFinding);
	}
}
 
开发者ID:RIGS-IT,项目名称:sonar-xanitizer,代码行数:22,代码来源:SensorUtil.java


示例4: testMetrics

import org.sonar.api.batch.rule.Severity; //导入依赖的package包/类
@Test
public void testMetrics() {
	assertNotNull(XanitizerMetrics.getMetricForAllXanFindings());
	assertNotNull(XanitizerMetrics.getMetricForNewXanFindings());

	for (Severity severity : Severity.values()) {
		assertNotNull("No metric for severity " + severity,
				XanitizerMetrics.getMetricForSeverity(severity));
	}

	final XanitizerMetrics metrics = new XanitizerMetrics();

	final int allMetrics = metrics.getMetrics().size();

	assertEquals(allMetrics, GeneratedProblemType.values().length + Severity.values().length
			+ 2 /* all and new findings */);

}
 
开发者ID:RIGS-IT,项目名称:sonar-xanitizer,代码行数:19,代码来源:PluginTest.java


示例5: testSanitizers

import org.sonar.api.batch.rule.Severity; //导入依赖的package包/类
@Test
public void testSanitizers() {
	final XMLReportParser parser = new XMLReportParser();
	final File reportFile = new File(
			getClass().getResource("/webgoat/webgoat-Findings-List-sanitizers.xml").getFile());
	try {
		final XMLReportContent content = parser.parse(reportFile);

		assertEquals("version 2.3.0, build no. 84 of 01.07.16", content.getToolVersionOrNull());
		assertEquals("2.3.0", content.getToolVersionShortOrNull());

		final List<XMLReportFinding> findings = content.getXMLReportFindings();
		assertEquals(1, findings.size());
		final XMLReportFinding finding = findings.get(0);
		assertEquals("Warning", finding.getFindingClassificationOrNull());
		final Severity severity = SensorUtil.mkSeverity(finding);
		assertEquals(Severity.INFO, severity);
	} catch (SAXException | IOException | ParserConfigurationException e) {
		LOG.error("Error parsing report file", e);
		fail(e.getMessage());
	}
}
 
开发者ID:RIGS-IT,项目名称:sonar-xanitizer,代码行数:23,代码来源:ParserTest.java


示例6: testSinks

import org.sonar.api.batch.rule.Severity; //导入依赖的package包/类
@Test
public void testSinks() {
	final XMLReportParser parser = new XMLReportParser();
	final File reportFile = new File(
			getClass().getResource("/webgoat/webgoat-Findings-List-sinks.xml").getFile());
	try {
		final XMLReportContent content = parser.parse(reportFile);

		assertEquals("version 2.3.0, build no. 84 of 01.07.16", content.getToolVersionOrNull());
		assertEquals("2.3.0", content.getToolVersionShortOrNull());

		final List<XMLReportFinding> findings = content.getXMLReportFindings();
		assertEquals(1, findings.size());
		final XMLReportFinding finding = findings.get(0);
		assertEquals("Must Fix", finding.getFindingClassificationOrNull());
		final Severity severity = SensorUtil.mkSeverity(finding);
		assertEquals(Severity.BLOCKER, severity);
	} catch (SAXException | IOException | ParserConfigurationException e) {
		LOG.error("Error parsing report file", e);
		fail(e.getMessage());
	}
}
 
开发者ID:RIGS-IT,项目名称:sonar-xanitizer,代码行数:23,代码来源:ParserTest.java


示例7: testSpecialCode

import org.sonar.api.batch.rule.Severity; //导入依赖的package包/类
@Test
public void testSpecialCode() {
	final XMLReportParser parser = new XMLReportParser();
	final File reportFile = new File(
			getClass().getResource("/webgoat/webgoat-Findings-List-specialcode.xml").getFile());
	try {
		final XMLReportContent content = parser.parse(reportFile);

		assertEquals("version 2.3.0, build no. 84 of 01.07.16", content.getToolVersionOrNull());
		assertEquals("2.3.0", content.getToolVersionShortOrNull());

		final List<XMLReportFinding> findings = content.getXMLReportFindings();
		assertEquals(1, findings.size());
		final XMLReportFinding finding = findings.get(0);
		assertEquals("Could Improve", finding.getFindingClassificationOrNull());
		final Severity severity = SensorUtil.mkSeverity(finding);
		assertEquals(Severity.CRITICAL, severity);
	} catch (SAXException | IOException | ParserConfigurationException e) {
		LOG.error("Error parsing report file", e);
		fail(e.getMessage());
	}
}
 
开发者ID:RIGS-IT,项目名称:sonar-xanitizer,代码行数:23,代码来源:ParserTest.java


示例8: testTaintPaths

import org.sonar.api.batch.rule.Severity; //导入依赖的package包/类
@Test
public void testTaintPaths() {
	final XMLReportParser parser = new XMLReportParser();
	final File reportFile = new File(
			getClass().getResource("/webgoat/webgoat-Findings-List-taintpaths.xml").getFile());
	try {
		final XMLReportContent content = parser.parse(reportFile);

		assertEquals("version 2.3.0, build no. 84 of 01.07.16", content.getToolVersionOrNull());
		assertEquals("2.3.0", content.getToolVersionShortOrNull());

		final List<XMLReportFinding> findings = content.getXMLReportFindings();
		assertEquals(1, findings.size());
		final XMLReportFinding finding = findings.get(0);
		assertEquals("Needs Further Study", finding.getFindingClassificationOrNull());
		final Severity severity = SensorUtil.mkSeverity(finding);
		assertEquals(Severity.MAJOR, severity);
	} catch (SAXException | IOException | ParserConfigurationException e) {
		LOG.error("Error parsing report file", e);
		fail(e.getMessage());
	}
}
 
开发者ID:RIGS-IT,项目名称:sonar-xanitizer,代码行数:23,代码来源:ParserTest.java


示例9: testUser

import org.sonar.api.batch.rule.Severity; //导入依赖的package包/类
@Test
public void testUser() {
	final XMLReportParser parser = new XMLReportParser();
	final File reportFile = new File(
			getClass().getResource("/webgoat/webgoat-Findings-List-user.xml").getFile());
	try {
		final XMLReportContent content = parser.parse(reportFile);

		assertEquals("version 2.3.0, build no. 84 of 01.07.16", content.getToolVersionOrNull());
		assertEquals("2.3.0", content.getToolVersionShortOrNull());

		final List<XMLReportFinding> findings = content.getXMLReportFindings();
		assertEquals(1, findings.size());
		final XMLReportFinding finding = findings.get(0);
		assertEquals("Warning", finding.getFindingClassificationOrNull());
		final Severity severity = SensorUtil.mkSeverity(finding);
		assertEquals(Severity.CRITICAL, severity);
	} catch (SAXException | IOException | ParserConfigurationException e) {
		LOG.error("Error parsing report file", e);
		fail(e.getMessage());
	}
}
 
开发者ID:RIGS-IT,项目名称:sonar-xanitizer,代码行数:23,代码来源:ParserTest.java


示例10: getEmojiForSeverity

import org.sonar.api.batch.rule.Severity; //导入依赖的package包/类
public String getEmojiForSeverity(Severity severity) {
    switch (severity) {
        case BLOCKER:
            return ":no_entry:";
        case CRITICAL:
            return ":no_entry_sign:";
        case MAJOR:
            return ":warning:";
        case MINOR:
            return ":arrow_down_small:";
        case INFO:
            return ":information_source:";
        default:
            return ":grey_question:";
    }
}
 
开发者ID:gabrie-allaigre,项目名称:sonar-gitlab-plugin,代码行数:17,代码来源:MarkDownUtils.java


示例11: testMultiIssue

import org.sonar.api.batch.rule.Severity; //导入依赖的package包/类
@Test
public void testMultiIssue() {
    settings.setProperty(GitLabPlugin.GITLAB_DISABLE_INLINE_COMMENTS, false);

    List<Reporter.ReportIssue> ris = Stream.iterate(0, i -> i++).limit(10)
            .map(i -> new Reporter.ReportIssue(Utils.newMockedIssue("component", null, 1, Severity.INFO, true, "Issue", "rule"), null, "lalal", "file", "http://myserver/coding_rules#rule_key=repo%3Arule", true)).collect(Collectors.toList());

    Assertions.assertThat(new InlineCommentBuilder(config, "123", null, 1, ris, new MarkDownUtils()).buildForMarkdown()).isEqualTo(
            ":information_source: Issue [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule)\n"
                    + ":information_source: Issue [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule)\n"
                    + ":information_source: Issue [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule)\n"
                    + ":information_source: Issue [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule)\n"
                    + ":information_source: Issue [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule)\n"
                    + ":information_source: Issue [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule)\n"
                    + ":information_source: Issue [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule)\n"
                    + ":information_source: Issue [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule)\n"
                    + ":information_source: Issue [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule)\n"
                    + ":information_source: Issue [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule)");
}
 
开发者ID:gabrie-allaigre,项目名称:sonar-gitlab-plugin,代码行数:20,代码来源:InlineCommentBuilderTest.java


示例12: testTemplateIssueOthers

import org.sonar.api.batch.rule.Severity; //导入依赖的package包/类
@Test
public void testTemplateIssueOthers() {
    settings.setProperty(GitLabPlugin.GITLAB_INLINE_TEMPLATE,
            "${emojiSeverity(BLOCKER)}\n${imageSeverity(BLOCKER)}\n${ruleLink(\"repo%3Arule0\")}\n<#list issues() as issue>${print(issue)}\n</#list>");

    List<Reporter.ReportIssue> ris = Stream.iterate(0, i -> i++).limit(10)
            .map(i -> new Reporter.ReportIssue(Utils.newMockedIssue("component", null, null, Severity.MAJOR, true, "Issue number:" + i, "rule" + i), null, GITLAB_URL + "/File.java#L" + i, "file", "http://myserver/coding_rules#rule_key=repo%3Arule" + i, false)).collect(Collectors.toList());

    Assertions.assertThat(new InlineCommentBuilder(config, "123", null, 1, ris, new MarkDownUtils()).buildForMarkdown()).isEqualTo(":no_entry:\n" +
            "![BLOCKER](https://github.com/gabrie-allaigre/sonar-gitlab-plugin/raw/master/images/severity-blocker.png)\n" +
            "http://myserver/coding_rules#rule_key=repo%253Arule0\n" +
            ":warning: [Issue number:0](https://gitlab.com/test/test/File.java#L0) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule0)\n" +
            ":warning: [Issue number:0](https://gitlab.com/test/test/File.java#L0) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule0)\n" +
            ":warning: [Issue number:0](https://gitlab.com/test/test/File.java#L0) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule0)\n" +
            ":warning: [Issue number:0](https://gitlab.com/test/test/File.java#L0) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule0)\n" +
            ":warning: [Issue number:0](https://gitlab.com/test/test/File.java#L0) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule0)\n" +
            ":warning: [Issue number:0](https://gitlab.com/test/test/File.java#L0) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule0)\n" +
            ":warning: [Issue number:0](https://gitlab.com/test/test/File.java#L0) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule0)\n" +
            ":warning: [Issue number:0](https://gitlab.com/test/test/File.java#L0) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule0)\n" +
            ":warning: [Issue number:0](https://gitlab.com/test/test/File.java#L0) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule0)\n" +
            ":warning: [Issue number:0](https://gitlab.com/test/test/File.java#L0) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule0)\n");
}
 
开发者ID:gabrie-allaigre,项目名称:sonar-gitlab-plugin,代码行数:23,代码来源:InlineCommentBuilderTest.java


示例13: testShouldFormatIssuesForMarkdownMixInlineGlobal

import org.sonar.api.batch.rule.Severity; //导入依赖的package包/类
@Test
public void testShouldFormatIssuesForMarkdownMixInlineGlobal() {
    settings.setProperty(GitLabPlugin.GITLAB_DISABLE_INLINE_COMMENTS, false);

    Reporter reporter = new Reporter(config);
    reporter.process(Utils.newMockedIssue("component", null, null, Severity.INFO, true, "Issue 0", "rule0"), null, GITLAB_URL, "file", "http://myserver/coding_rules#rule_key=repo%3Arule0", true, false);
    reporter.process(Utils.newMockedIssue("component", null, null, Severity.MINOR, true, "Issue 1", "rule1"), null, GITLAB_URL, "file", "http://myserver/coding_rules#rule_key=repo%3Arule1", false, false);
    reporter.process(Utils.newMockedIssue("component", null, null, Severity.MAJOR, true, "Issue 2", "rule2"), null, GITLAB_URL, "file", "http://myserver/coding_rules#rule_key=repo%3Arule2", true, false);
    reporter.process(Utils.newMockedIssue("component", null, null, Severity.CRITICAL, true, "Issue 3", "rule3"), null, GITLAB_URL, "file", "http://myserver/coding_rules#rule_key=repo%3Arule3", false, false);
    reporter.process(Utils.newMockedIssue("component", null, null, Severity.BLOCKER, true, "Issue 4", "rule4"), null, GITLAB_URL, "file", "http://myserver/coding_rules#rule_key=repo%3Arule4", true, false);

    Assertions.assertThat(new GlobalCommentBuilder(config, null, reporter, new MarkDownUtils()).buildForMarkdown()).isEqualTo(
            "SonarQube analysis reported 5 issues\n" + "* :no_entry: 1 blocker\n" + "* :no_entry_sign: 1 critical\n" + "* :warning: 1 major\n" + "* :arrow_down_small: 1 minor\n"
                    + "* :information_source: 1 info\n" + "\n" + "Watch the comments in this conversation to review them.\n" + "\n" + "#### 2 extra issues\n" + "\n"
                    + "Note: The following issues were found on lines that were not modified in the commit. Because these issues can't be reported as line comments, they are summarized here:\n\n"
                    + "1. :no_entry_sign: [Issue 3](https://gitlab.com/test/test) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule3)\n"
                    + "1. :arrow_down_small: [Issue 1](https://gitlab.com/test/test) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule1)\n");
}
 
开发者ID:gabrie-allaigre,项目名称:sonar-gitlab-plugin,代码行数:19,代码来源:GlobalTemplateTest.java


示例14: testShouldFormatIssuesForMarkdownWhenInlineCommentsDisabled

import org.sonar.api.batch.rule.Severity; //导入依赖的package包/类
@Test
public void testShouldFormatIssuesForMarkdownWhenInlineCommentsDisabled() {
    settings.setProperty(GitLabPlugin.GITLAB_DISABLE_INLINE_COMMENTS, true);

    Reporter reporter = new Reporter(config);
    reporter.process(Utils.newMockedIssue("component", null, null, Severity.INFO, true, "Issue 0", "rule0"), null, GITLAB_URL, "file", "http://myserver/coding_rules#rule_key=repo%3Arule0", false, false);
    reporter.process(Utils.newMockedIssue("component", null, null, Severity.MINOR, true, "Issue 1", "rule1"), null, GITLAB_URL, "file", "http://myserver/coding_rules#rule_key=repo%3Arule1", false, false);
    reporter.process(Utils.newMockedIssue("component", null, null, Severity.MAJOR, true, "Issue 2", "rule2"), null, GITLAB_URL, "file", "http://myserver/coding_rules#rule_key=repo%3Arule2", false, false);
    reporter.process(Utils.newMockedIssue("component", null, null, Severity.CRITICAL, true, "Issue 3", "rule3"), null, GITLAB_URL, "file", "http://myserver/coding_rules#rule_key=repo%3Arule3", false, false);
    reporter.process(Utils.newMockedIssue("component", null, null, Severity.BLOCKER, true, "Issue 4", "rule4"), null, GITLAB_URL, "file", "http://myserver/coding_rules#rule_key=repo%3Arule4", false, false);

    Assertions.assertThat(new GlobalCommentBuilder(config, null, reporter, new MarkDownUtils()).buildForMarkdown()).isEqualTo(
            "SonarQube analysis reported 5 issues\n" + "* :no_entry: 1 blocker\n" + "* :no_entry_sign: 1 critical\n" + "* :warning: 1 major\n" + "* :arrow_down_small: 1 minor\n"
                    + "* :information_source: 1 info\n" + "\n" + "1. :no_entry: [Issue 4](https://gitlab.com/test/test) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule4)\n"
                    + "1. :no_entry_sign: [Issue 3](https://gitlab.com/test/test) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule3)\n"
                    + "1. :warning: [Issue 2](https://gitlab.com/test/test) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule2)\n"
                    + "1. :arrow_down_small: [Issue 1](https://gitlab.com/test/test) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule1)\n"
                    + "1. :information_source: [Issue 0](https://gitlab.com/test/test) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule0)\n");
}
 
开发者ID:gabrie-allaigre,项目名称:sonar-gitlab-plugin,代码行数:20,代码来源:GlobalTemplateTest.java


示例15: shouldFormatIssuesForMarkdownWhenInlineCommentsDisabledAndLimitReached

import org.sonar.api.batch.rule.Severity; //导入依赖的package包/类
@Test
public void shouldFormatIssuesForMarkdownWhenInlineCommentsDisabledAndLimitReached() {
    settings.setProperty(GitLabPlugin.GITLAB_DISABLE_INLINE_COMMENTS, true);
    settings.setProperty(GitLabPlugin.GITLAB_MAX_GLOBAL_ISSUES, "4");

    Reporter reporter = new Reporter(config);
    reporter.process(Utils.newMockedIssue("component", null, null, Severity.INFO, true, "Issue 0", "rule0"), null, GITLAB_URL, "file", "http://myserver/coding_rules#rule_key=repo%3Arule0", false, false);
    reporter.process(Utils.newMockedIssue("component", null, null, Severity.MINOR, true, "Issue 1", "rule1"), null, GITLAB_URL, "file", "http://myserver/coding_rules#rule_key=repo%3Arule1", false, false);
    reporter.process(Utils.newMockedIssue("component", null, null, Severity.MAJOR, true, "Issue 2", "rule2"), null, GITLAB_URL, "file", "http://myserver/coding_rules#rule_key=repo%3Arule2", false, false);
    reporter.process(Utils.newMockedIssue("component", null, null, Severity.CRITICAL, true, "Issue 3", "rule3"), null, GITLAB_URL, "file", "http://myserver/coding_rules#rule_key=repo%3Arule3", false, false);
    reporter.process(Utils.newMockedIssue("component", null, null, Severity.BLOCKER, true, "Issue 4", "rule4"), null, GITLAB_URL, "file", "http://myserver/coding_rules#rule_key=repo%3Arule4", false, false);

    Assertions.assertThat(new GlobalCommentBuilder(config, null, reporter, new MarkDownUtils()).buildForMarkdown()).isEqualTo(
            "SonarQube analysis reported 5 issues\n" + "* :no_entry: 1 blocker\n" + "* :no_entry_sign: 1 critical\n" + "* :warning: 1 major\n" + "* :arrow_down_small: 1 minor\n"
                    + "* :information_source: 1 info\n" + "\n" + "#### Top 4 issues\n" + "\n"
                    + "1. :no_entry: [Issue 4](https://gitlab.com/test/test) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule4)\n"
                    + "1. :no_entry_sign: [Issue 3](https://gitlab.com/test/test) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule3)\n"
                    + "1. :warning: [Issue 2](https://gitlab.com/test/test) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule2)\n"
                    + "1. :arrow_down_small: [Issue 1](https://gitlab.com/test/test) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule1)\n" + "* ... 1 more\n");
}
 
开发者ID:gabrie-allaigre,项目名称:sonar-gitlab-plugin,代码行数:21,代码来源:GlobalTemplateTest.java


示例16: testShouldLimitGlobalIssues

import org.sonar.api.batch.rule.Severity; //导入依赖的package包/类
@Test
public void testShouldLimitGlobalIssues() {
    settings.setProperty(GitLabPlugin.GITLAB_DISABLE_INLINE_COMMENTS, false);

    Reporter reporter = new Reporter(config);
    for (int i = 0; i < 17; i++) {
        reporter.process(Utils.newMockedIssue("component", null, null, Severity.MAJOR, true, "Issue number:" + i, "rule" + i), null, GITLAB_URL + "/File.java#L" + i, "File" + i, "http://myserver/coding_rules#rule_key=repo%3Arule" + i, false, false);
    }

    Assertions.assertThat(new GlobalCommentBuilder(config, null, reporter, new MarkDownUtils()).buildForMarkdown()).isEqualTo(
            "SonarQube analysis reported 17 issues\n" + "* :warning: 17 major\n" + "\n" + "#### Top 10 extra issues\n" + "\n"
                    + "Note: The following issues were found on lines that were not modified in the commit. Because these issues can't be reported as line comments, they are summarized here:\n"
                    + "\n" + "1. :warning: [Issue number:0](https://gitlab.com/test/test/File.java#L0) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule0)\n"
                    + "1. :warning: [Issue number:1](https://gitlab.com/test/test/File.java#L1) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule1)\n"
                    + "1. :warning: [Issue number:2](https://gitlab.com/test/test/File.java#L2) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule2)\n"
                    + "1. :warning: [Issue number:3](https://gitlab.com/test/test/File.java#L3) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule3)\n"
                    + "1. :warning: [Issue number:4](https://gitlab.com/test/test/File.java#L4) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule4)\n"
                    + "1. :warning: [Issue number:5](https://gitlab.com/test/test/File.java#L5) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule5)\n"
                    + "1. :warning: [Issue number:6](https://gitlab.com/test/test/File.java#L6) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule6)\n"
                    + "1. :warning: [Issue number:7](https://gitlab.com/test/test/File.java#L7) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule7)\n"
                    + "1. :warning: [Issue number:8](https://gitlab.com/test/test/File.java#L8) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule8)\n"
                    + "1. :warning: [Issue number:9](https://gitlab.com/test/test/File.java#L9) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule9)\n" + "* ... 7 more\n");
}
 
开发者ID:gabrie-allaigre,项目名称:sonar-gitlab-plugin,代码行数:24,代码来源:GlobalTemplateTest.java


示例17: testShouldLimitGlobalIssuesWhenInlineCommentsDisabled

import org.sonar.api.batch.rule.Severity; //导入依赖的package包/类
@Test
public void testShouldLimitGlobalIssuesWhenInlineCommentsDisabled() {
    settings.setProperty(GitLabPlugin.GITLAB_DISABLE_INLINE_COMMENTS, true);

    Reporter reporter = new Reporter(config);
    for (int i = 0; i < 17; i++) {
        reporter.process(Utils.newMockedIssue("component", null, null, Severity.MAJOR, true, "Issue number:" + i, "rule" + i), null, GITLAB_URL + "/File.java#L" + i, "File" + i, "http://myserver/coding_rules#rule_key=repo%3Arule" + i, false, false);
    }

    Assertions.assertThat(new GlobalCommentBuilder(config, null, reporter, new MarkDownUtils()).buildForMarkdown()).isEqualTo(
            "SonarQube analysis reported 17 issues\n" + "* :warning: 17 major\n" + "\n" + "#### Top 10 issues\n" + "\n"
                    + "1. :warning: [Issue number:0](https://gitlab.com/test/test/File.java#L0) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule0)\n"
                    + "1. :warning: [Issue number:1](https://gitlab.com/test/test/File.java#L1) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule1)\n"
                    + "1. :warning: [Issue number:2](https://gitlab.com/test/test/File.java#L2) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule2)\n"
                    + "1. :warning: [Issue number:3](https://gitlab.com/test/test/File.java#L3) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule3)\n"
                    + "1. :warning: [Issue number:4](https://gitlab.com/test/test/File.java#L4) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule4)\n"
                    + "1. :warning: [Issue number:5](https://gitlab.com/test/test/File.java#L5) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule5)\n"
                    + "1. :warning: [Issue number:6](https://gitlab.com/test/test/File.java#L6) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule6)\n"
                    + "1. :warning: [Issue number:7](https://gitlab.com/test/test/File.java#L7) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule7)\n"
                    + "1. :warning: [Issue number:8](https://gitlab.com/test/test/File.java#L8) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule8)\n"
                    + "1. :warning: [Issue number:9](https://gitlab.com/test/test/File.java#L9) [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule9)\n" + "* ... 7 more\n");
}
 
开发者ID:gabrie-allaigre,项目名称:sonar-gitlab-plugin,代码行数:23,代码来源:GlobalTemplateTest.java


示例18: testCommitAnalysisWithNewIssuesOnlyReview

import org.sonar.api.batch.rule.Severity; //导入依赖的package包/类
@Test
public void testCommitAnalysisWithNewIssuesOnlyReview() {
    settings.setProperty(GitLabPlugin.GITLAB_ONLY_ISSUE_FROM_COMMIT_FILE, true);

    DefaultInputFile inputFile1 = new DefaultInputFile("foo", "src/Foo.php");
    PostJobIssue newIssue1 = Utils.newMockedIssue("foo:src/Foo.php", inputFile1, 1, Severity.BLOCKER, true, "msg1");
    PostJobIssue newIssue2 = Utils.newMockedIssue("foo:src/Foo.php", inputFile1, 1, Severity.BLOCKER, true, "msg2");
    Mockito.when(commitFacade.getGitLabUrl(null, inputFile1, 1)).thenReturn("http://gitlab/blob/abc123/src/Foo.php#L1");
    Mockito.when(commitFacade.getRuleLink("repo:rule")).thenReturn("http://myserver/coding_rules#rule_key=repo%3Arule");

    PostJobIssue newIssue3 = Utils.newMockedIssue("foo:src/Foo.php", inputFile1, 2, Severity.BLOCKER, true, "msg3");
    Mockito.when(commitFacade.getGitLabUrl("def456", inputFile1, 2)).thenReturn("http://gitlab/blob/abc123/src/Foo.php#L2");

    Mockito.when(context.issues()).thenReturn(Arrays.asList(newIssue1, newIssue2, newIssue3));
    Mockito.when(commitFacade.hasFile(inputFile1)).thenReturn(true);
    Mockito.when(commitFacade.getRevisionForLine(inputFile1, 1)).thenReturn("abc123");
    Mockito.when(commitFacade.getRevisionForLine(inputFile1, 2)).thenReturn("abc123");

    commitIssuePostJob.execute(context);

    Mockito.verify(commitFacade).createOrUpdateReviewComment("abc123", inputFile1, 1,
            ":no_entry: msg1 [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule)\n" + ":no_entry: msg2 [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule)");
    Mockito.verify(commitFacade).createOrUpdateReviewComment("abc123", inputFile1, 2, ":no_entry: msg3 [:blue_book:](http://myserver/coding_rules#rule_key=repo%3Arule)");
}
 
开发者ID:gabrie-allaigre,项目名称:sonar-gitlab-plugin,代码行数:25,代码来源:CommitIssuePostJobTest.java


示例19: testCommitAnalysisWithNewBlockerAndCriticalIssues

import org.sonar.api.batch.rule.Severity; //导入依赖的package包/类
@Test
public void testCommitAnalysisWithNewBlockerAndCriticalIssues() {
    DefaultInputFile inputFile1 = new DefaultInputFile("foo", "src/Foo.php");
    PostJobIssue newIssue = Utils.newMockedIssue("foo:src/Foo.php", inputFile1, 1, Severity.CRITICAL, true, "msg1");
    when(commitFacade.getGitLabUrl(null, inputFile1, 1)).thenReturn("http://gitlab/blob/abc123/src/Foo.php#L1");

    PostJobIssue lineNotVisible = Utils.newMockedIssue("foo:src/Foo.php", inputFile1, 2, Severity.BLOCKER, true, "msg2");
    when(commitFacade.getGitLabUrl(null, inputFile1, 2)).thenReturn("http://gitlab/blob/abc123/src/Foo.php#L2");

    when(context.issues()).thenReturn(Arrays.asList(newIssue, lineNotVisible));
    when(commitFacade.hasFile(inputFile1)).thenReturn(true);
    when(commitFacade.getRevisionForLine(inputFile1, 1)).thenReturn(null);

    commitIssuePostJob.execute(context);

    verify(commitFacade).createOrUpdateSonarQubeStatus("failed", "SonarQube reported 2 issues, with 1 blocker (fail) and 1 critical (fail)");
}
 
开发者ID:gabrie-allaigre,项目名称:sonar-gitlab-plugin,代码行数:18,代码来源:CommitIssuePostJobTest.java


示例20: testCommitAnalysisWithNewIssuesNoBlockerNorCritical2

import org.sonar.api.batch.rule.Severity; //导入依赖的package包/类
@Test
public void testCommitAnalysisWithNewIssuesNoBlockerNorCritical2() {
    settings.setProperty(GitLabPlugin.GITLAB_STATUS_NOTIFICATION_MODE, StatusNotificationsMode.EXIT_CODE.getMeaning());

    DefaultInputFile inputFile1 = new DefaultInputFile("foo", "src/Foo.php");
    PostJobIssue newIssue = Utils.newMockedIssue("foo:src/Foo.php", inputFile1, 1, Severity.MAJOR, true, "msg1");
    when(commitFacade.getGitLabUrl(null, inputFile1, 1)).thenReturn("http://gitlab/blob/abc123/src/Foo.php#L1");

    when(context.issues()).thenReturn(Collections.singletonList(newIssue));
    when(commitFacade.hasFile(inputFile1)).thenReturn(true);
    when(commitFacade.getRevisionForLine(inputFile1, 1)).thenReturn(null);

    commitIssuePostJob.execute(context);

    Mockito.verify(commitFacade, Mockito.never()).createOrUpdateSonarQubeStatus("success", "SonarQube reported 1 issue, no criticals or blockers");
}
 
开发者ID:gabrie-allaigre,项目名称:sonar-gitlab-plugin,代码行数:17,代码来源:CommitIssuePostJobTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DefaultBuildContext类代码示例发布时间:2022-05-23
下一篇:
Java Transaction类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap