本文整理汇总了Java中org.sonar.api.batch.rule.Severity类的典型用法代码示例。如果您正苦于以下问题:Java Severity类的具体用法?Java Severity怎么用?Java Severity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Severity类属于org.sonar.api.batch.rule包,在下文中一共展示了Severity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例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);
}
}
示例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);
}
}
示例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 */);
}
示例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());
}
}
示例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());
}
}
示例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());
}
}
示例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());
}
}
示例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());
}
}
示例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:";
}
}
示例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)");
}
示例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");
}
示例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");
}
示例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");
}
示例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");
}