本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.SeverityLevel.WARNING属性的典型用法代码示例。如果您正苦于以下问题:Java SeverityLevel.WARNING属性的具体用法?Java SeverityLevel.WARNING怎么用?Java SeverityLevel.WARNING使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.SeverityLevel
的用法示例。
在下文中一共展示了SeverityLevel.WARNING属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: realExecute
/**
* Helper implementation to perform execution.
* @param checkstyleVersion Checkstyle compile version.
*/
private void realExecute(String checkstyleVersion) {
// Create the root module
RootModule rootModule = null;
try {
rootModule = createRootModule();
// setup the listeners
final AuditListener[] listeners = getListeners();
for (AuditListener element : listeners) {
rootModule.addListener(element);
}
final SeverityLevelCounter warningCounter =
new SeverityLevelCounter(SeverityLevel.WARNING);
rootModule.addListener(warningCounter);
processFiles(rootModule, warningCounter, checkstyleVersion);
}
finally {
destroyRootModule(rootModule);
}
}
示例2: format
@Override
public String format(AuditEvent event) {
final String fileName = event.getFileName();
final String message = event.getMessage();
final SeverityLevel severityLevel = event.getSeverityLevel();
final String severityLevelName;
if (severityLevel == SeverityLevel.WARNING) {
// We change the name of severity level intentionally
// to shorten the length of the log message.
severityLevelName = "WARN";
}
else {
severityLevelName = severityLevel.getName().toUpperCase(Locale.US);
}
// Avoid StringBuffer.expandCapacity
final int bufLen = calculateBufferLength(event, severityLevelName.length());
final StringBuilder sb = new StringBuilder(bufLen);
sb.append('[').append(severityLevelName).append("] ")
.append(fileName).append(':').append(event.getLine());
if (event.getColumn() > 0) {
sb.append(':').append(event.getColumn());
}
sb.append(": ").append(message).append(" [");
if (event.getModuleId() == null) {
final String checkShortName = getCheckShortName(event);
sb.append(checkShortName);
}
else {
sb.append(event.getModuleId());
}
sb.append(']');
return sb.toString();
}
示例3: testFormatFullyQualifiedModuleNameContainsCheckSuffix
@Test
public void testFormatFullyQualifiedModuleNameContainsCheckSuffix() {
final LocalizedMessage message = new LocalizedMessage(1, 1, null, null, null,
SeverityLevel.WARNING, null, TestModuleCheck.class, "Mocked message.");
final AuditEvent event = new AuditEvent("", "InputMockFile.java", message);
final AuditEventFormatter formatter = new AuditEventDefaultFormatter();
final String expected = "[WARN] InputMockFile.java:1:1: Mocked message. "
+ "[AuditEventDefaultFormatterTest$TestModule]";
assertEquals("Invalid format", expected, formatter.format(event));
}
示例4: testFormatFullyQualifiedModuleNameDoesNotContainCheckSuffix
@Test
public void testFormatFullyQualifiedModuleNameDoesNotContainCheckSuffix() {
final LocalizedMessage message = new LocalizedMessage(1, 1, null, null, null,
SeverityLevel.WARNING, null, TestModule.class, "Mocked message.");
final AuditEvent event = new AuditEvent("", "InputMockFile.java", message);
final AuditEventFormatter formatter = new AuditEventDefaultFormatter();
final String expected = "[WARN] InputMockFile.java:1:1: Mocked message. "
+ "[AuditEventDefaultFormatterTest$TestModule]";
assertEquals("Invalid format", expected, formatter.format(event));
}
示例5: testFormatModuleWithModuleId
@Test
public void testFormatModuleWithModuleId() {
final LocalizedMessage message = new LocalizedMessage(1, 1, null, null, null,
SeverityLevel.WARNING, "ModuleId", TestModule.class, "Mocked message.");
final AuditEvent event = new AuditEvent("", "InputMockFile.java", message);
final AuditEventFormatter formatter = new AuditEventDefaultFormatter();
final String expected = "[WARN] InputMockFile.java:1:1: Mocked message. [ModuleId]";
assertEquals("Invalid format", expected, formatter.format(event));
}