Skip to content

Commit

Permalink
SONARJAVA-4983 improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
johann-beleites-sonarsource committed Nov 18, 2024
1 parent 708fe30 commit cdfe3b5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,12 @@ private void registerCheckClasses(List<JavaCheck> destinationList, Checks<JavaCh
.sorted(Comparator.comparing(check -> classIndexes.getOrDefault(check.getClass(), Integer.MAX_VALUE)))
.toList();
destinationList.addAll(orderedChecks);
if (LOG.isDebugEnabled()) {
LOG.debug("Registered check: [{}]",
orderedChecks.stream()
.map(c -> c.getClass().getSimpleName() + " (" + createdChecks.ruleKey(c) + ")")
.collect(Collectors.joining(", ")));
}
jspChecks.addAll(orderedChecks.stream().filter(JspCodeVisitor.class::isInstance).toList());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,21 @@ public boolean scanWithoutParsing(InputFile inputFile) {
if (sonarComponents != null && sonarComponents.fileCanBeSkipped(inputFile)) {
PerformanceMeasure.Duration duration = PerformanceMeasure.start("ScanWithoutParsing");
boolean allScansSucceeded = true;

List<JavaFileScanner> scannersRequiringParsing = new ArrayList<>();
List<JavaFileScanner> scannersNotRequiringParsing = new ArrayList<>();

var fileScannerContext = createScannerContext(sonarComponents, inputFile, javaVersion, inAndroidContext, cacheContext);
for (var scanner: scannersThatCannotBeSkipped) {
boolean exceptionIsBlownUp = false;
PerformanceMeasure.Duration scannerDuration = PerformanceMeasure.start(scanner);
try {
allScansSucceeded &= scanner.scanWithoutParsing(fileScannerContext);
if (scanner.scanWithoutParsing(fileScannerContext)) {
scannersNotRequiringParsing.add(scanner);
} else {
scannersRequiringParsing.add(scanner);
allScansSucceeded = false;
}
} catch (AnalysisException e) {
// In the case where the IssuableSubscriptionVisitorsRunner throws an exception, the problem has already been
// logged and the exception formatted.
Expand All @@ -210,6 +219,10 @@ public boolean scanWithoutParsing(InputFile inputFile) {
}
}
duration.stop();

LOG.trace("Scanners that do not require parsing of {}: {}", inputFile, scannersNotRequiringParsing);
LOG.debug("Scanners that require parsing of {}: {}", inputFile, scannersRequiringParsing);

return allScansSucceeded;
} else {
return false;
Expand Down

0 comments on commit cdfe3b5

Please sign in to comment.