Java Code Examples for com.puppycrawl.tools.checkstyle.api.AuditEvent#getSeverityLevel()
The following examples show how to use
com.puppycrawl.tools.checkstyle.api.AuditEvent#getSeverityLevel() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AssertionsAuditListener.java From nohttp with Apache License 2.0 | 5 votes |
@Override public void addError(AuditEvent event) { recordLevel(event); if (event.getSeverityLevel() != SeverityLevel.IGNORE) { recordMessage(FORMATTER.format(event)); } }
Example 2
Source File: AssertionsAuditListener.java From spring-javaformat with Apache License 2.0 | 5 votes |
@Override public void addError(AuditEvent event) { recordLevel(event); if (event.getSeverityLevel() != SeverityLevel.IGNORE) { recordMessage(FORMATTER.format(event)); } }
Example 3
Source File: CheckerListener.java From vscode-checkstyle with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void addError(AuditEvent error) { final SeverityLevel severity = error.getSeverityLevel(); if (severity.equals(SeverityLevel.IGNORE)) { return; } fileErrors.get(error.getFileName()).add(new CheckResult( error.getLine(), error.getColumn(), error.getMessage(), severity.toString().toLowerCase(), error.getSourceName().substring(error.getSourceName().lastIndexOf('.') + 1))); }
Example 4
Source File: CommonsLoggingListener.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
/** @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()); } } }
Example 5
Source File: CommonsLoggingListener.java From contribution with GNU Lesser General Public License v2.1 | 5 votes |
/** @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()); } } }
Example 6
Source File: CoderadarAuditListener.java From coderadar with MIT License | 5 votes |
@Override public void addError(AuditEvent evt) { if (evt.getSeverityLevel() != SeverityLevel.IGNORE) { Metric metric = new Metric("checkstyle:" + evt.getSourceName()); Finding finding = new Finding( evt.getLine(), evt.getLine(), evt.getColumn(), evt.getColumn(), evt.getMessage()); Long metricCount = metricCountExtractor.extractMetricCount(evt); metrics.addFinding(metric, finding, metricCount); } }
Example 7
Source File: Auditor.java From eclipse-cs with GNU Lesser General Public License v2.1 | 4 votes |
@Override public void addError(AuditEvent error) { try { if (!mLimitMarkers || mMarkerCount < mMarkerLimit) { SeverityLevel severity = error.getSeverityLevel(); if (!severity.equals(SeverityLevel.IGNORE) && mResource != null) { RuleMetadata metaData = MetadataFactory.getRuleMetadata(error.getSourceName()); // create generic metadata if none can be found if (metaData == null) { Module module = new Module(error.getSourceName()); metaData = MetadataFactory.createGenericMetadata(module); } mMarkerAttributes.put(CheckstyleMarker.MODULE_NAME, metaData.getInternalName()); mMarkerAttributes.put(CheckstyleMarker.MESSAGE_KEY, error.getLocalizedMessage().getKey()); mMarkerAttributes.put(IMarker.PRIORITY, Integer.valueOf(IMarker.PRIORITY_NORMAL)); mMarkerAttributes.put(IMarker.SEVERITY, Integer.valueOf(getSeverityValue(severity))); mMarkerAttributes.put(IMarker.LINE_NUMBER, Integer.valueOf(error.getLine())); mMarkerAttributes.put(IMarker.MESSAGE, getMessage(error)); // calculate offset for editor annotations calculateMarkerOffset(error, mMarkerAttributes); // enables own category under Java Problem Type // setting for Problems view (RFE 1530366) mMarkerAttributes.put("categoryId", Integer.valueOf(999)); //$NON-NLS-1$ // create a marker for the actual resource IMarker marker = mResource.createMarker(CheckstyleMarker.MARKER_ID); marker.setAttributes(mMarkerAttributes); mMarkerCount++; // clear the marker attributes to reuse the map for the // next error mMarkerAttributes.clear(); } } } catch (CoreException e) { CheckstyleLog.log(e); } }