本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.SeverityLevel类的典型用法代码示例。如果您正苦于以下问题:Java SeverityLevel类的具体用法?Java SeverityLevel怎么用?Java SeverityLevel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SeverityLevel类属于com.puppycrawl.tools.checkstyle.api包,在下文中一共展示了SeverityLevel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: toSeverity
import com.puppycrawl.tools.checkstyle.api.SeverityLevel; //导入依赖的package包/类
public static String toSeverity(RulePriority priority) {
final String result;
switch (priority) {
case BLOCKER:
case CRITICAL:
result = SeverityLevel.ERROR.getName();
break;
case MAJOR:
result = SeverityLevel.WARNING.getName();
break;
case MINOR:
case INFO:
result = SeverityLevel.INFO.getName();
break;
default:
throw new IllegalArgumentException("Priority not supported: " + priority);
}
return result;
}
开发者ID:checkstyle,项目名称:sonar-checkstyle,代码行数:22,代码来源:CheckstyleSeverityUtils.java
示例2: fromSeverity
import com.puppycrawl.tools.checkstyle.api.SeverityLevel; //导入依赖的package包/类
public static RulePriority fromSeverity(String severity) {
RulePriority result = null;
try {
final SeverityLevel severityLevel = SeverityLevel.getInstance(severity);
switch (severityLevel) {
case ERROR:
result = RulePriority.BLOCKER;
break;
case WARNING:
result = RulePriority.MAJOR;
break;
case INFO:
case IGNORE:
result = RulePriority.INFO;
break;
default:
}
}
catch (Exception exc) {
LOG.warn("Smth wrong severity", exc);
}
return result;
}
开发者ID:checkstyle,项目名称:sonar-checkstyle,代码行数:27,代码来源:CheckstyleSeverityUtils.java
示例3: realExecute
import com.puppycrawl.tools.checkstyle.api.SeverityLevel; //导入依赖的package包/类
/**
* 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);
}
}
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:26,代码来源:CheckstyleAntTask.java
示例4: testLogIoExceptionFileNotFound
import com.puppycrawl.tools.checkstyle.api.SeverityLevel; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testLogIoExceptionFileNotFound() throws Exception {
//I can't put wrong file here. Checkstyle fails before check started.
//I saw some usage of file or handling of wrong file in Checker, or somewhere
//in checks running part. So I had to do it with reflection to improve coverage.
final TranslationCheck check = new TranslationCheck();
final DefaultConfiguration checkConfig = createModuleConfig(TranslationCheck.class);
check.configure(checkConfig);
final Checker checker = createChecker(checkConfig);
final SeverityLevelCounter counter = new SeverityLevelCounter(SeverityLevel.ERROR);
checker.addListener(counter);
check.setMessageDispatcher(checker);
final Method loadKeys =
check.getClass().getDeclaredMethod("getTranslationKeys", File.class);
loadKeys.setAccessible(true);
final Set<String> keys = (Set<String>) loadKeys.invoke(check, new File(""));
assertTrue("Translation keys should be empty when File is not found", keys.isEmpty());
assertEquals("Invalid error count", 1, counter.getCount());
}
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:22,代码来源:TranslationCheckTest.java
示例5: testAddErrorOnZeroColumns
import com.puppycrawl.tools.checkstyle.api.SeverityLevel; //导入依赖的package包/类
@Test
public void testAddErrorOnZeroColumns() throws Exception {
final XMLLogger logger = new XMLLogger(outStream, true);
logger.auditStarted(null);
final LocalizedMessage message =
new LocalizedMessage(1, 0,
"messages.properties", "key", null, SeverityLevel.ERROR, null,
getClass(), null);
final AuditEvent ev = new AuditEvent(this, "Test.java", message);
logger.fileStarted(ev);
logger.addError(ev);
logger.fileFinished(ev);
logger.auditFinished(null);
verifyXml(getPath("ExpectedXMLLoggerErrorZeroColumn.xml"), outStream,
message.getMessage());
}
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:17,代码来源:XMLLoggerTest.java
示例6: testAuditFinishedWithoutFileFinished
import com.puppycrawl.tools.checkstyle.api.SeverityLevel; //导入依赖的package包/类
@Test
public void testAuditFinishedWithoutFileFinished() throws Exception {
final XMLLogger logger = new XMLLogger(outStream, true);
logger.auditStarted(null);
final AuditEvent fileStartedEvent = new AuditEvent(this, "Test.java");
logger.fileStarted(fileStartedEvent);
final LocalizedMessage message =
new LocalizedMessage(1, 1,
"messages.properties", "key", null, SeverityLevel.ERROR, null,
getClass(), null);
final AuditEvent errorEvent = new AuditEvent(this, "Test.java", message);
logger.addError(errorEvent);
logger.fileFinished(errorEvent);
logger.auditFinished(null);
verifyXml(getPath("ExpectedXMLLoggerError.xml"), outStream, message.getMessage());
}
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:19,代码来源:XMLLoggerTest.java
示例7: testDefault
import com.puppycrawl.tools.checkstyle.api.SeverityLevel; //导入依赖的package包/类
@Test
public void testDefault() {
final AuditEvent ev = new AuditEvent(this, "Test.java");
assertFalse("no message", filter.accept(ev));
final SeverityLevel errorLevel = SeverityLevel.ERROR;
final LocalizedMessage errorMessage =
new LocalizedMessage(0, 0, "", "", null,
errorLevel, null, getClass(), null);
final AuditEvent ev2 = new AuditEvent(this, "ATest.java", errorMessage);
assertTrue("level:" + errorLevel, filter.accept(ev2));
final SeverityLevel infoLevel = SeverityLevel.INFO;
final LocalizedMessage infoMessage =
new LocalizedMessage(0, 0, "", "", null, infoLevel, null, getClass(), null);
final AuditEvent ev3 = new AuditEvent(this, "ATest.java", infoMessage);
assertFalse("level:" + infoLevel, filter.accept(ev3));
}
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:17,代码来源:SeverityMatchFilterTest.java
示例8: testSeverity
import com.puppycrawl.tools.checkstyle.api.SeverityLevel; //导入依赖的package包/类
@Test
public void testSeverity() {
filter.setSeverity(SeverityLevel.INFO);
final AuditEvent ev = new AuditEvent(this, "Test.java");
// event with no message has severity level INFO
assertTrue("no message", filter.accept(ev));
final SeverityLevel errorLevel = SeverityLevel.ERROR;
final LocalizedMessage errorMessage =
new LocalizedMessage(0, 0, "", "", null,
errorLevel, null, getClass(), null);
final AuditEvent ev2 = new AuditEvent(this, "ATest.java", errorMessage);
assertFalse("level:" + errorLevel, filter.accept(ev2));
final SeverityLevel infoLevel = SeverityLevel.INFO;
final LocalizedMessage infoMessage =
new LocalizedMessage(0, 0, "", "", null, infoLevel, null, getClass(), null);
final AuditEvent ev3 = new AuditEvent(this, "ATest.java", infoMessage);
assertTrue("level:" + infoLevel, filter.accept(ev3));
}
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:19,代码来源:SeverityMatchFilterTest.java
示例9: testAcceptOnMatch
import com.puppycrawl.tools.checkstyle.api.SeverityLevel; //导入依赖的package包/类
@Test
public void testAcceptOnMatch() {
filter.setSeverity(SeverityLevel.INFO);
filter.setAcceptOnMatch(false);
final AuditEvent ev = new AuditEvent(this, "Test.java");
// event with no message has severity level INFO
assertFalse("no message", filter.accept(ev));
final SeverityLevel errorLevel = SeverityLevel.ERROR;
final LocalizedMessage errorMessage =
new LocalizedMessage(0, 0, "", "", null,
errorLevel, null, getClass(), null);
final AuditEvent ev2 = new AuditEvent(this, "ATest.java", errorMessage);
assertTrue("level:" + errorLevel, filter.accept(ev2));
final SeverityLevel infoLevel = SeverityLevel.INFO;
final LocalizedMessage infoMessage = new LocalizedMessage(0, 0, "", "", null, infoLevel,
null, getClass(), null);
final AuditEvent ev3 = new AuditEvent(this, "ATest.java", infoMessage);
assertFalse("level:" + infoLevel, filter.accept(ev3));
}
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:20,代码来源:SeverityMatchFilterTest.java
示例10: testAcceptThrowsIllegalStateExceptionAsFileNotFound
import com.puppycrawl.tools.checkstyle.api.SeverityLevel; //导入依赖的package包/类
@Test
public void testAcceptThrowsIllegalStateExceptionAsFileNotFound() {
final LocalizedMessage message = new LocalizedMessage(1, 1, 1, TokenTypes.CLASS_DEF,
"messages.properties", "key", null, SeverityLevel.ERROR, null, getClass(), null);
final String fileName = "nonexisting_file";
final AuditEvent auditEvent = new AuditEvent(this, fileName, message);
final SuppressWithPlainTextCommentFilter filter = new SuppressWithPlainTextCommentFilter();
try {
filter.accept(auditEvent);
fail(IllegalStateException.class.getSimpleName() + " is expected");
}
catch (IllegalStateException ex) {
assertEquals("Invalid exception message",
"Cannot read source file: " + fileName, ex.getMessage());
final Throwable cause = ex.getCause();
assertTrue("Exception cause has invalid type",
cause instanceof FileNotFoundException);
assertEquals("Invalid exception message",
fileName + " (No such file or directory)", cause.getMessage());
}
}
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:25,代码来源:SuppressWithPlainTextCommentFilterTest.java
示例11: checkstyle
import com.puppycrawl.tools.checkstyle.api.SeverityLevel; //导入依赖的package包/类
@Test
public void checkstyle() {
// Analyze all sources in src/main/java
AnalyzerConfig config = AnalyzerConfig.maven().main();
// Only treat issues with severity WARNING or higher
StyleEventCollector collector = new StyleEventCollector().severity(SeverityLevel.WARNING)
.just(In.everywhere().ignore("import.avoidStar", "javadoc.missing"))
.because("in tests, long lines are ok", In.classes("*Test").ignore("maxLineLen"));
//use google checks, but adjust max line length
final StyleChecks checks = StyleChecks.google().maxLineLen(120);
CheckstyleResult result = new CheckstyleAnalyzer(config, checks, collector).analyze();
assertThat(result, hasNoCheckstyleIssues());
}
开发者ID:nidi3,项目名称:code-assert,代码行数:17,代码来源:CheckstyleTest.java
示例12: addError
import com.puppycrawl.tools.checkstyle.api.SeverityLevel; //导入依赖的package包/类
/** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
public void addError(AuditEvent aEvt)
{
printEvent(aEvt);
if (SeverityLevel.ERROR.equals(aEvt.getSeverityLevel())) {
mErrors++;
mTotalErrors++;
}
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:10,代码来源:VerboseListener.java
示例13: addError
import com.puppycrawl.tools.checkstyle.api.SeverityLevel; //导入依赖的package包/类
/** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
public void addError(AuditEvent aEvt)
{
final SeverityLevel severityLevel = aEvt.getSeverityLevel();
if (mInitialized && !SeverityLevel.IGNORE.equals(severityLevel)) {
final Log log = mLogFactory.getInstance(aEvt.getSourceName());
final String fileName = aEvt.getFileName();
final String message = aEvt.getMessage();
// avoid StringBuffer.expandCapacity
final int bufLen = message.length() + BUFFER_CUSHION;
final StringBuffer sb = new StringBuffer(bufLen);
sb.append("Line: ").append(aEvt.getLine());
if (aEvt.getColumn() > 0) {
sb.append(" Column: ").append(aEvt.getColumn());
}
sb.append(" Message: ").append(message);
if (aEvt.getSeverityLevel().equals(SeverityLevel.WARNING)) {
log.warn(sb.toString());
}
else if (aEvt.getSeverityLevel().equals(SeverityLevel.INFO)) {
log.info(sb.toString());
}
else {
log.error(sb.toString());
}
}
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:32,代码来源:CommonsLoggingListener.java
示例14: addError
import com.puppycrawl.tools.checkstyle.api.SeverityLevel; //导入依赖的package包/类
/** @see com.puppycrawl.tools.checkstyle.api.AuditListener */
public void addError(AuditEvent aEvt)
{
if (SeverityLevel.ERROR.equals(aEvt.getSeverityLevel())) {
mLogger.addError(aEvt);
mErrors++;
}
}
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:9,代码来源:MailLogger.java
示例15: endElement
import com.puppycrawl.tools.checkstyle.api.SeverityLevel; //导入依赖的package包/类
@Override
public void endElement(String uri,
String localName,
String qName) throws SAXException {
if (qName.equals(MODULE)) {
final Configuration recentModule =
configStack.pop();
// get severity attribute if it exists
SeverityLevel level = null;
if (containsAttribute(recentModule, SEVERITY)) {
try {
final String severity = recentModule.getAttribute(SEVERITY);
level = SeverityLevel.getInstance(severity);
}
catch (final CheckstyleException ex) {
// [email protected][IllegalInstantiation] SAXException is in the overridden
// method signature
throw new SAXException(
"Problem during accessing '" + SEVERITY + "' attribute for "
+ recentModule.getName(), ex);
}
}
// omit this module if these should be omitted and the module
// has the severity 'ignore'
final boolean omitModule = omitIgnoredModules
&& level == SeverityLevel.IGNORE;
if (omitModule && !configStack.isEmpty()) {
final DefaultConfiguration parentModule =
configStack.peek();
parentModule.removeChild(recentModule);
}
}
}
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:38,代码来源:ConfigurationLoader.java
示例16: addError
import com.puppycrawl.tools.checkstyle.api.SeverityLevel; //导入依赖的package包/类
@Override
public void addError(AuditEvent event) {
if (event.getSeverityLevel() != SeverityLevel.IGNORE) {
final String fileName = event.getFileName();
if (fileName == null || !fileMessages.containsKey(fileName)) {
synchronized (writerLock) {
writeFileError(event);
}
}
else {
final FileMessages messages = fileMessages.get(fileName);
messages.addError(event);
}
}
}
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:16,代码来源:XMLLogger.java
示例17: format
import com.puppycrawl.tools.checkstyle.api.SeverityLevel; //导入依赖的package包/类
@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();
}
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:38,代码来源:AuditEventDefaultFormatter.java
示例18: addError
import com.puppycrawl.tools.checkstyle.api.SeverityLevel; //导入依赖的package包/类
/**
* Print an Emacs compliant line on the error stream.
* If the column number is non zero, then also display it.
* @see AuditListener
**/
@Override
public void addError(AuditEvent event) {
final SeverityLevel severityLevel = event.getSeverityLevel();
if (severityLevel != SeverityLevel.IGNORE) {
final String errorMessage = formatter.format(event);
errorWriter.println(errorMessage);
}
}
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:14,代码来源:DefaultLogger.java
示例19: testAddError
import com.puppycrawl.tools.checkstyle.api.SeverityLevel; //导入依赖的package包/类
@Test
public void testAddError() throws Exception {
final XMLLogger logger = new XMLLogger(outStream, true);
logger.auditStarted(null);
final LocalizedMessage message =
new LocalizedMessage(1, 1,
"messages.properties", "key", null, SeverityLevel.ERROR, null,
getClass(), null);
final AuditEvent ev = new AuditEvent(this, "Test.java", message);
logger.fileStarted(ev);
logger.addError(ev);
logger.fileFinished(ev);
logger.auditFinished(null);
verifyXml(getPath("ExpectedXMLLoggerError.xml"), outStream, message.getMessage());
}
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:16,代码来源:XMLLoggerTest.java
示例20: testAddErrorWithNullFileName
import com.puppycrawl.tools.checkstyle.api.SeverityLevel; //导入依赖的package包/类
@Test
public void testAddErrorWithNullFileName() throws Exception {
final XMLLogger logger = new XMLLogger(outStream, true);
logger.auditStarted(null);
final LocalizedMessage message =
new LocalizedMessage(1, 1,
"messages.properties", "key", null, SeverityLevel.ERROR, null,
getClass(), null);
final AuditEvent ev = new AuditEvent(this, null, message);
logger.addError(ev);
logger.auditFinished(null);
verifyXml(getPath("ExpectedXMLLoggerErrorNullFileName.xml"), outStream,
message.getMessage());
}
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:15,代码来源:XMLLoggerTest.java
注:本文中的com.puppycrawl.tools.checkstyle.api.SeverityLevel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论