public void processRecognitionException(RecognitionException e, File file) { addAnalysisError(e, file.getPath(), AnalysisError.Kind.PARSE_ERROR); if(sonarComponents == null || !sonarComponents.reportAnalysisError(e, file)) { this.visitFile(null); executableScanners.stream() .filter(scanner -> scanner instanceof ExceptionHandler) .forEach(scanner -> ((ExceptionHandler) scanner).processRecognitionException(e)); } }
public void processRecognitionException(RecognitionException e, File file) { addAnalysisError(e, file.getPath(), AnalysisError.Kind.PARSE_ERROR); if(sonarComponents == null || !sonarComponents.reportAnalysisError(e, file)) { this.visitFile(null); executableScanners.stream() .filter(scanner -> scanner instanceof ExceptionHandler) .forEach(scanner -> ((ExceptionHandler) scanner).processRecognitionException(e)); } }
private void runScanner(JavaFileScannerContext javaFileScannerContext, JavaFileScanner scanner, AnalysisError.Kind kind) { try { scanner.scanFile(javaFileScannerContext); } catch (IllegalRuleParameterException e) { // bad configuration of a rule parameter, we want to fail analysis fast. throw e; } catch (Exception e) { if (sonarComponents != null && sonarComponents.shouldFailAnalysisOnException()) { throw e; } Throwable rootCause = Throwables.getRootCause(e); if (rootCause instanceof InterruptedIOException || rootCause instanceof InterruptedException) { throw e; } Rule annotation = AnnotationUtils.getAnnotation(scanner.getClass(), Rule.class); String key = ""; if (annotation != null) { key = annotation.key(); } LOG.error( String.format("Unable to run check %s - %s on file %s, To help improve SonarJava, please report this problem to SonarSource : see https://www.sonarqube.org/community/", scanner.getClass(), key, currentFile.getPath()), e); addAnalysisError(e, currentFile.getPath(), kind); } }
private void runScanner(JavaFileScannerContext javaFileScannerContext, JavaFileScanner scanner, AnalysisError.Kind kind) { try { scanner.scanFile(javaFileScannerContext); } catch (IllegalRuleParameterException e) { // bad configuration of a rule parameter, we want to fail analysis fast. throw e; } catch (Exception e) { if (sonarComponents != null && sonarComponents.shouldFailAnalysisOnException()) { throw e; } Throwable rootCause = Throwables.getRootCause(e); if (rootCause instanceof InterruptedIOException || rootCause instanceof InterruptedException) { throw e; } Rule annotation = AnnotationUtils.getAnnotation(scanner.getClass(), Rule.class); String key = ""; if (annotation != null) { key = annotation.key(); } LOG.error( String.format("Unable to run check %s - %s on file %s, To help improve SonarJava, please report this problem to SonarSource : see https://www.sonarqube.org/community/", scanner.getClass(), key, currentFile.getPath()), e); addAnalysisError(e, currentFile.getPath(), kind); } }
} catch (Exception e) { LOG.error("Unable to create symbol table for : " + currentFile.getAbsolutePath(), e); addAnalysisError(e, currentFile.getPath(), AnalysisError.Kind.SEMANTIC_ERROR); sonarComponents.reportAnalysisError(currentFile, e.getMessage()); return;
} catch (Exception e) { LOG.error("Unable to create symbol table for : " + currentFile.getAbsolutePath(), e); addAnalysisError(e, currentFile.getPath(), AnalysisError.Kind.SEMANTIC_ERROR); sonarComponents.reportAnalysisError(currentFile, e.getMessage()); return;