com.puppycrawl.tools.checkstyle.api.SeverityLevel Java Examples
The following examples show how to use
com.puppycrawl.tools.checkstyle.api.SeverityLevel.
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: CheckstyleSeverityUtils.java From sonar-checkstyle with GNU Lesser General Public License v3.0 | 6 votes |
public static String toSeverity(String 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; }
Example #2
Source File: CheckstyleSeverityUtils.java From sonar-checkstyle with GNU Lesser General Public License v3.0 | 6 votes |
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; }
Example #3
Source File: CollectorListener.java From sputnik with Apache License 2.0 | 5 votes |
@NotNull private Severity convert(SeverityLevel severityLevel) { switch (severityLevel) { case IGNORE: return Severity.IGNORE; case INFO: return Severity.INFO; case WARNING: return Severity.WARNING; case ERROR: return Severity.ERROR; default: throw new IllegalArgumentException("Severity " + severityLevel + " is not supported"); } }
Example #4
Source File: AssertionsAuditListener.java From nohttp with Apache License 2.0 | 5 votes |
@Override public void auditFinished(AuditEvent event) { recordLevel(event); recordLocalizedMessage(DefaultLogger.AUDIT_FINISHED_MESSAGE); recordMessage(this.severityCounts.toString()); int errors = this.severityCounts.getOrDefault(SeverityLevel.ERROR, 0); recordMessage(errors + (errors == 1 ? " error" : " errors")); System.out.println(this.filenames); System.out.println(this.message); this.checks.forEach(this::runCheck); }
Example #5
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 #6
Source File: MailLogger.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) { if (SeverityLevel.ERROR.equals(aEvt.getSeverityLevel())) { mLogger.addError(aEvt); mErrors++; } }
Example #7
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 #8
Source File: VerboseListener.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) { printEvent(aEvt); if (SeverityLevel.ERROR.equals(aEvt.getSeverityLevel())) { mErrors++; mTotalErrors++; } }
Example #9
Source File: MailLogger.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) { if (SeverityLevel.ERROR.equals(aEvt.getSeverityLevel())) { mLogger.addError(aEvt); mErrors++; } }
Example #10
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 #11
Source File: VerboseListener.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) { printEvent(aEvt); if (SeverityLevel.ERROR.equals(aEvt.getSeverityLevel())) { mErrors++; mTotalErrors++; } }
Example #12
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 #13
Source File: Auditor.java From eclipse-cs with GNU Lesser General Public License v2.1 | 5 votes |
private int getSeverityValue(SeverityLevel severity) { int result = IMarker.SEVERITY_WARNING; if (severity.equals(SeverityLevel.INFO)) { result = IMarker.SEVERITY_INFO; } else if (severity.equals(SeverityLevel.WARNING)) { result = IMarker.SEVERITY_WARNING; } else if (severity.equals(SeverityLevel.ERROR)) { result = IMarker.SEVERITY_ERROR; } return result; }
Example #14
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 #15
Source File: AssertionsAuditListener.java From spring-javaformat with Apache License 2.0 | 5 votes |
@Override public void auditFinished(AuditEvent event) { recordLevel(event); recordLocalizedMessage(DefaultLogger.AUDIT_FINISHED_MESSAGE); recordMessage(this.severityCounts.toString()); int errors = this.severityCounts.getOrDefault(SeverityLevel.ERROR, 0); recordMessage(errors + (errors == 1 ? " error" : " errors")); System.out.println(this.filenames); System.out.println(this.message); this.checks.forEach(this::runCheck); }
Example #16
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 #17
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); } }