aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src/main/java/org/sonar/scanner
diff options
context:
space:
mode:
authorJulien Camus <julien.camus@sonarsource.com>2024-12-27 15:22:10 +0100
committersonartech <sonartech@sonarsource.com>2024-12-27 20:03:07 +0000
commit643821403bceec551ad5305d80fd43bc63895e4f (patch)
treeb5523e048ea76741412391be28a6625369afdf76 /sonar-scanner-engine/src/main/java/org/sonar/scanner
parent670f4a2337ceeb3cce78cbff249a5b3ba6f3e319 (diff)
downloadsonarqube-643821403bceec551ad5305d80fd43bc63895e4f.tar.gz
sonarqube-643821403bceec551ad5305d80fd43bc63895e4f.zip
SONAR-24021 Invoke method(s) only conditionally
Diffstat (limited to 'sonar-scanner-engine/src/main/java/org/sonar/scanner')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/SpringGlobalContainer.java6
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/SpringScannerContainer.java15
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/CpdExecutor.java13
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/index/SonarCpdBlockIndex.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericCoverageSensor.java5
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensor.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/http/DefaultScannerWsClient.java9
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/scanner/IssueExclusionsRegexpScanner.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/postjob/PostJobsExecutor.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java16
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/InputModuleHierarchyProvider.java12
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/InputProjectProvider.java12
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/AbstractCoverageAndDuplicationExclusions.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/AbstractExclusionFilters.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java8
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/LanguageDetection.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ProjectFilePreprocessor.java3
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/DefaultBlameOutput.java3
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmPublisher.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorsExecutor.java8
20 files changed, 70 insertions, 62 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/SpringGlobalContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/SpringGlobalContainer.java
index a6193218f31..782eaa9364a 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/SpringGlobalContainer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/SpringGlobalContainer.java
@@ -19,10 +19,10 @@
*/
package org.sonar.scanner.bootstrap;
+import jakarta.annotation.Priority;
import java.time.Clock;
import java.util.List;
import java.util.Map;
-import jakarta.annotation.Priority;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@@ -141,7 +141,9 @@ public class SpringGlobalContainer extends SpringComponentContainer {
}
new SpringScannerContainer(this).execute();
- LOG.info("Analysis total time: {}", formatTime(System.currentTimeMillis() - startTime));
+ if (LOG.isInfoEnabled()) {
+ LOG.info("Analysis total time: {}", formatTime(System.currentTimeMillis() - startTime));
+ }
}
private void installRequiredPlugins() {
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/SpringScannerContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/SpringScannerContainer.java
index c368316f7fb..a0df8c926ed 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/SpringScannerContainer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/SpringScannerContainer.java
@@ -19,8 +19,8 @@
*/
package org.sonar.scanner.bootstrap;
-import javax.annotation.Nullable;
import jakarta.annotation.Priority;
+import javax.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.fs.internal.FileMetadata;
@@ -160,10 +160,12 @@ public class SpringScannerContainer extends SpringComponentContainer {
private void addSuffixesDeprecatedProperties() {
add(
- /* This is needed to support properly the deprecated sonar.rpg.suffixes property when the download optimization feature is enabled.
- The value of the property is needed at the preprocessing stage, but being defined by an optional analyzer means that at preprocessing
- it won't be properly available. This will be removed in SQ 11.0 together with the drop of the property from the rpg analyzer.
- See SONAR-21514 */
+ /*
+ * This is needed to support properly the deprecated sonar.rpg.suffixes property when the download optimization feature is enabled.
+ * The value of the property is needed at the preprocessing stage, but being defined by an optional analyzer means that at preprocessing
+ * it won't be properly available. This will be removed in SQ 11.0 together with the drop of the property from the rpg analyzer.
+ * See SONAR-21514
+ */
PropertyDefinition.builder("sonar.rpg.file.suffixes")
.deprecatedKey("sonar.rpg.suffixes")
.multiValues(true)
@@ -308,8 +310,7 @@ public class SpringScannerContainer extends SpringComponentContainer {
GitlabCi.class,
Jenkins.class,
SemaphoreCi.class,
- TravisCi.class
- );
+ TravisCi.class);
add(GitScmSupport.getObjects());
add(SvnScmSupport.getObjects());
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/CpdExecutor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/CpdExecutor.java
index d83ad4114e1..6560a4c5520 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/CpdExecutor.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/CpdExecutor.java
@@ -19,6 +19,7 @@
*/
package org.sonar.scanner.cpd;
+import jakarta.inject.Inject;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
@@ -31,7 +32,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Function;
import java.util.function.Predicate;
-import jakarta.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.fs.InputComponent;
@@ -103,7 +103,7 @@ public class CpdExecutor {
}
int filesWithoutBlocks = index.noIndexedFiles() - index.noResources();
- if (filesWithoutBlocks > 0) {
+ if (filesWithoutBlocks > 0 && LOG.isInfoEnabled()) {
LOG.info("CPD Executor {} {} had no CPD blocks", filesWithoutBlocks, pluralize(filesWithoutBlocks));
}
@@ -128,7 +128,9 @@ public class CpdExecutor {
}
void runCpdAnalysis(ExecutorService executorService, DefaultInputFile inputFile, Collection<Block> fileBlocks, long timeout) {
- LOG.debug("Detection of duplications for {}", inputFile.absolutePath());
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Detection of duplications for {}", inputFile.absolutePath());
+ }
progressReport.message(String.format("%d/%d - current file: %s", count, total, inputFile.absolutePath()));
List<CloneGroup> duplications;
@@ -199,9 +201,8 @@ public class CpdExecutor {
if (!duplicate.equals(originBlock)) {
clonePartCount++;
if (clonePartCount > MAX_CLONE_PART_PER_GROUP) {
- LOG.warn("Too many duplication references on file " + component + " for block at line " +
- originBlock.getStartLine() + ". Keep only the first "
- + MAX_CLONE_PART_PER_GROUP + " references.");
+ LOG.warn("Too many duplication references on file {} for block at line {}. Keep only the first {} references.",
+ component, originBlock.getStartLine(), MAX_CLONE_PART_PER_GROUP);
break;
}
blockBuilder.clear();
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/index/SonarCpdBlockIndex.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/index/SonarCpdBlockIndex.java
index dbc5eb1f711..996d6a19cb5 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/index/SonarCpdBlockIndex.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/index/SonarCpdBlockIndex.java
@@ -71,7 +71,7 @@ public class SonarCpdBlockIndex extends AbstractCloneIndex {
for (Block block : blocks) {
mem.insert(block);
}
- if (blocks.isEmpty()) {
+ if (blocks.isEmpty() && LOG.isDebugEnabled()) {
LOG.debug("Not enough content in '{}' to have CPD blocks, it will not be part of the duplication detection", inputFile.relativePath());
}
indexedFiles.add(inputFile);
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericCoverageSensor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericCoverageSensor.java
index d09949b9be7..3d9b5370992 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericCoverageSensor.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericCoverageSensor.java
@@ -77,11 +77,10 @@ public class GenericCoverageSensor implements ProjectSensor {
parser.parse(reportFile, context);
LOG.info("Imported coverage data for {} files", parser.numberOfMatchedFiles());
int numberOfUnknownFiles = parser.numberOfUnknownFiles();
- if (numberOfUnknownFiles > 0) {
- LOG.info("Coverage data ignored for " + numberOfUnknownFiles + " unknown files, including:\n" + parser.firstUnknownFiles().stream().collect(Collectors.joining("\n")));
+ if (numberOfUnknownFiles > 0 && LOG.isInfoEnabled()) {
+ LOG.info("Coverage data ignored for {} unknown files, including:\n{}", numberOfUnknownFiles, parser.firstUnknownFiles().stream().collect(Collectors.joining("\n")));
}
}
-
}
Set<String> loadReportPaths() {
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensor.java
index 6615372735b..7faffe640a2 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensor.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/genericcoverage/GenericTestExecutionSensor.java
@@ -87,7 +87,7 @@ public class GenericTestExecutionSensor implements Sensor {
parser.parse(reportFile, context);
LOG.info("Imported test execution data for {} files", parser.numberOfMatchedFiles());
int numberOfUnknownFiles = parser.numberOfUnknownFiles();
- if (numberOfUnknownFiles > 0) {
+ if (numberOfUnknownFiles > 0 && LOG.isInfoEnabled()) {
LOG.info("Test execution data ignored for {} unknown files, including:\n{}", numberOfUnknownFiles, parser.firstUnknownFiles().stream().collect(Collectors.joining("\n")));
}
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/http/DefaultScannerWsClient.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/http/DefaultScannerWsClient.java
index 0532b691e36..7a11df24669 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/http/DefaultScannerWsClient.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/http/DefaultScannerWsClient.java
@@ -130,12 +130,11 @@ public class DefaultScannerWsClient implements ScannerWsClient {
}
private static void logResponseDetailsIfDebug(WsResponse response) {
- if (!LOG.isDebugEnabled()) {
- return;
+ if (LOG.isDebugEnabled()) {
+ String content = response.hasContent() ? response.content() : "<no content>";
+ Map<String, List<String>> headers = response.headers();
+ LOG.debug("Error response content: {}, headers: {}", content, headers);
}
- String content = response.hasContent() ? response.content() : "<no content>";
- Map<String, List<String>> headers = response.headers();
- LOG.debug("Error response content: {}, headers: {}", content, headers);
}
private void checkAuthenticationWarnings(WsResponse response) {
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/scanner/IssueExclusionsRegexpScanner.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/scanner/IssueExclusionsRegexpScanner.java
index de70d2c7186..b0c88f5860b 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/scanner/IssueExclusionsRegexpScanner.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/scanner/IssueExclusionsRegexpScanner.java
@@ -88,7 +88,9 @@ public class IssueExclusionsRegexpScanner extends CharHandler {
fileLength = lineIndex;
if (!lineExclusions.isEmpty()) {
Set<LineRange> lineRanges = convertLineExclusionsToLineRanges();
- LOG.debug(" - Line exclusions found: {}", lineRanges.stream().map(LineRange::toString).collect(Collectors.joining(",")));
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(" - Line exclusions found: {}", lineRanges.stream().map(LineRange::toString).collect(Collectors.joining(",")));
+ }
inputFile.addIgnoreIssuesOnLineRanges(lineRanges.stream().map(r -> new int[] {r.from(), r.to()}).toList());
}
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/postjob/PostJobsExecutor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/postjob/PostJobsExecutor.java
index 1613e1fd911..582ebd63d53 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/postjob/PostJobsExecutor.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/postjob/PostJobsExecutor.java
@@ -51,8 +51,6 @@ public class PostJobsExecutor {
}
private static void logPostJobs(Collection<PostJobWrapper> postJobs) {
- if (LOG.isDebugEnabled()) {
- LOG.debug(() -> "Post-jobs : " + postJobs.stream().map(Object::toString).collect(Collectors.joining(" -> ")));
- }
+ LOG.debug(() -> "Post-jobs : " + postJobs.stream().map(Object::toString).collect(Collectors.joining(" -> ")));
}
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java
index 15f12eef49d..80b0ccb138f 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java
@@ -43,10 +43,10 @@ import org.sonar.api.utils.MessageException;
import org.sonar.api.utils.TempFolder;
import org.sonar.api.utils.ZipUtils;
import org.sonar.core.ce.CeTaskCharacteristics;
-import org.sonar.scanner.http.DefaultScannerWsClient;
import org.sonar.scanner.bootstrap.GlobalAnalysisMode;
import org.sonar.scanner.ci.CiConfiguration;
import org.sonar.scanner.fs.InputModuleHierarchy;
+import org.sonar.scanner.http.DefaultScannerWsClient;
import org.sonar.scanner.protocol.output.FileStructure;
import org.sonar.scanner.protocol.output.ScannerReportReader;
import org.sonar.scanner.protocol.output.ScannerReportWriter;
@@ -157,7 +157,7 @@ public class ReportPublisher implements Startable {
logDeprecationWarningIf32bitJava();
File report = generateReportFile();
if (properties.shouldKeepReport()) {
- LOG.info("Analysis report generated in " + reportDir);
+ LOG.info("Analysis report generated in {}", reportDir);
}
if (!analysisMode.isMediumTest()) {
String taskId = upload(report);
@@ -181,13 +181,17 @@ public class ReportPublisher implements Startable {
publisher.publish(writer);
}
long stopTime = System.currentTimeMillis();
- LOG.info("Analysis report generated in {}ms, dir size={}", stopTime - startTime, humanReadableByteCountSI(FileUtils.sizeOfDirectory(reportDir.toFile())));
+ if (LOG.isInfoEnabled()) {
+ LOG.info("Analysis report generated in {}ms, dir size={}", stopTime - startTime, humanReadableByteCountSI(FileUtils.sizeOfDirectory(reportDir.toFile())));
+ }
startTime = System.currentTimeMillis();
File reportZip = temp.newFile("scanner-report", ".zip");
ZipUtils.zipDir(reportDir.toFile(), reportZip);
stopTime = System.currentTimeMillis();
- LOG.info("Analysis report compressed in {}ms, zip size={}", stopTime - startTime, humanReadableByteCountSI(FileUtils.sizeOf(reportZip)));
+ if (LOG.isInfoEnabled()) {
+ LOG.info("Analysis report compressed in {}ms, zip size={}", stopTime - startTime, humanReadableByteCountSI(FileUtils.sizeOf(reportZip)));
+ }
return reportZip;
} catch (IOException e) {
throw new IllegalStateException("Unable to prepare analysis report", e);
@@ -218,7 +222,7 @@ public class ReportPublisher implements Startable {
.setPart("report", filePart);
ciConfiguration.getDevOpsPlatformInfo().ifPresent(devOpsPlatformInfo -> {
- post.setParam(CHARACTERISTIC, buildCharacteristicParam(DEVOPS_PLATFORM_URL ,devOpsPlatformInfo.getUrl()));
+ post.setParam(CHARACTERISTIC, buildCharacteristicParam(DEVOPS_PLATFORM_URL, devOpsPlatformInfo.getUrl()));
post.setParam(CHARACTERISTIC, buildCharacteristicParam(DEVOPS_PLATFORM_PROJECT_IDENTIFIER, devOpsPlatformInfo.getProjectIdentifier()));
});
String branchName = branchConfiguration.branchName();
@@ -250,7 +254,7 @@ public class ReportPublisher implements Startable {
throw new RuntimeException(e);
} finally {
long stopTime = System.currentTimeMillis();
- LOG.info("Analysis report uploaded in " + (stopTime - startTime) + "ms");
+ LOG.info("Analysis report uploaded in {}ms", (stopTime - startTime));
}
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/InputModuleHierarchyProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/InputModuleHierarchyProvider.java
index d818f0b91f1..1610cc640a6 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/InputModuleHierarchyProvider.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/InputModuleHierarchyProvider.java
@@ -22,11 +22,11 @@ package org.sonar.scanner.scan;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.fs.internal.DefaultInputModule;
import org.sonar.api.batch.fs.internal.DefaultInputProject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.sonar.scanner.scan.filesystem.ScannerComponentIdGenerator;
import org.springframework.context.annotation.Bean;
@@ -62,9 +62,11 @@ public class InputModuleHierarchyProvider {
private static DefaultInputModule createModule(ProjectDefinition def, int scannerComponentId) {
LOG.debug(" Init module '{}'", def.getName());
DefaultInputModule module = new DefaultInputModule(def, scannerComponentId);
- LOG.debug(" Base dir: {}", module.getBaseDir().toAbsolutePath().toString());
- LOG.debug(" Working dir: {}", module.getWorkDir().toAbsolutePath().toString());
- LOG.debug(" Module global encoding: {}, default locale: {}", module.getEncoding().displayName(), Locale.getDefault());
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(" Base dir: {}", module.getBaseDir().toAbsolutePath());
+ LOG.debug(" Working dir: {}", module.getWorkDir().toAbsolutePath());
+ LOG.debug(" Module global encoding: {}, default locale: {}", module.getEncoding().displayName(), Locale.getDefault());
+ }
return module;
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/InputProjectProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/InputProjectProvider.java
index 4b000374101..d25f05cbbdb 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/InputProjectProvider.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/InputProjectProvider.java
@@ -20,10 +20,10 @@
package org.sonar.scanner.scan;
import java.util.Locale;
-import org.sonar.api.batch.bootstrap.ProjectReactor;
-import org.sonar.api.batch.fs.internal.DefaultInputProject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.sonar.api.batch.bootstrap.ProjectReactor;
+import org.sonar.api.batch.fs.internal.DefaultInputProject;
import org.sonar.scanner.scan.filesystem.ScannerComponentIdGenerator;
import org.springframework.context.annotation.Bean;
@@ -44,9 +44,11 @@ public class InputProjectProvider {
workDirectoriesInit.execute(project);
LOG.info("Project key: {}", project.key());
- LOG.info("Base dir: {}", project.getBaseDir().toAbsolutePath().toString());
- LOG.info("Working dir: {}", project.getWorkDir().toAbsolutePath().toString());
- LOG.debug("Project global encoding: {}, default locale: {}", project.getEncoding().displayName(), Locale.getDefault());
+ LOG.info("Base dir: {}", project.getBaseDir().toAbsolutePath());
+ LOG.info("Working dir: {}", project.getWorkDir().toAbsolutePath());
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Project global encoding: {}, default locale: {}", project.getEncoding().displayName(), Locale.getDefault());
+ }
return project;
}
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/AbstractCoverageAndDuplicationExclusions.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/AbstractCoverageAndDuplicationExclusions.java
index b5d6b4c1e0d..74ce7717f61 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/AbstractCoverageAndDuplicationExclusions.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/AbstractCoverageAndDuplicationExclusions.java
@@ -84,7 +84,7 @@ public abstract class AbstractCoverageAndDuplicationExclusions {
}
private static void log(String title, Collection<WildcardPattern> patterns, String ident) {
- if (!patterns.isEmpty()) {
+ if (!patterns.isEmpty() && LOG.isInfoEnabled()) {
LOG.info("{}{} {}", ident, title, patterns.stream().map(WildcardPattern::toString).collect(Collectors.joining(", ")));
}
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/AbstractExclusionFilters.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/AbstractExclusionFilters.java
index 48ef929337b..15ff0342e6c 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/AbstractExclusionFilters.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/AbstractExclusionFilters.java
@@ -162,7 +162,7 @@ public abstract class AbstractExclusionFilters {
}
private static void log(String title, PathPattern[] patterns, String indent) {
- if (patterns.length > 0) {
+ if (patterns.length > 0 && LOG.isInfoEnabled()) {
LOG.info("{}{} {}", indent, title, Arrays.stream(patterns).map(PathPattern::toString).collect(Collectors.joining(", ")));
}
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java
index 6afd6163619..a97d782d83f 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/FileIndexer.java
@@ -102,8 +102,7 @@ public class FileIndexer {
language != null ? language.key() : null,
scannerComponentIdGenerator.getAsInt(),
sensorStrategy,
- scmChangedFiles.getOldRelativeFilePath(sourceFile)
- );
+ scmChangedFiles.getOldRelativeFilePath(sourceFile));
DefaultInputFile inputFile = new DefaultInputFile(indexedFile, f -> metadataGenerator.setMetadata(module.key(), f, module.getEncoding()),
f -> f.setStatus(statusDetection.findStatusFromScm(f)));
@@ -117,9 +116,7 @@ public class FileIndexer {
componentStore.put(module.key(), inputFile);
issueExclusionsLoader.addMulticriteriaPatterns(inputFile);
String langStr = inputFile.language() != null ? format("with language '%s'", inputFile.language()) : "with no language";
- if (LOG.isDebugEnabled()) {
- LOG.debug("'{}' indexed {}{}", inputFile, type == Type.TEST ? "as test " : "", langStr);
- }
+ LOG.debug("'{}' indexed {}{}", inputFile, type == Type.TEST ? "as test " : "", langStr);
evaluateCoverageExclusions(moduleCoverageAndDuplicationExclusions, inputFile);
evaluateDuplicationExclusions(moduleCoverageAndDuplicationExclusions, inputFile);
if (properties.preloadFileMetadata()) {
@@ -204,5 +201,4 @@ public class FileIndexer {
return count == 1 ? "file" : "files";
}
-
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/LanguageDetection.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/LanguageDetection.java
index 8873d79c60e..fad668d2c14 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/LanguageDetection.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/LanguageDetection.java
@@ -87,7 +87,9 @@ public class LanguageDetection {
PathPattern[] defaultLanguagePatterns = Stream.concat(fileSuffixes, filenamePatterns)
.distinct()
.toArray(PathPattern[]::new);
- LOG.debug("Declared patterns of language {} were converted to {}", language, getDetails(language, defaultLanguagePatterns));
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Declared patterns of language {} were converted to {}", language, getDetails(language, defaultLanguagePatterns));
+ }
return defaultLanguagePatterns;
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ProjectFilePreprocessor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ProjectFilePreprocessor.java
index 4f2b9570860..40d604fb082 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ProjectFilePreprocessor.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/ProjectFilePreprocessor.java
@@ -171,8 +171,7 @@ public class ProjectFilePreprocessor {
List<Path> processedFiles = new ArrayList<>();
Files.walkFileTree(path.normalize(), Collections.singleton(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE,
new DirectoryFileVisitor(file -> filePreprocessor.processFile(module, moduleExclusionFilters, file, type, exclusionCounter,
- ignoreCommand).ifPresent(processedFiles::add), module, moduleExclusionFilters, inputModuleHierarchy, type)
- );
+ ignoreCommand).ifPresent(processedFiles::add), module, moduleExclusionFilters, inputModuleHierarchy, type));
return processedFiles;
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/DefaultBlameOutput.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/DefaultBlameOutput.java
index 75ae9a29db5..b7a3f67bb43 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/DefaultBlameOutput.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/DefaultBlameOutput.java
@@ -139,7 +139,7 @@ class DefaultBlameOutput implements BlameOutput {
if (success && !allFilesToBlame.isEmpty()) {
LOG.warn("Missing blame information for the following files:");
for (InputFile f : allFilesToBlame) {
- LOG.warn(" * " + f);
+ LOG.warn(" * {}", f);
}
LOG.warn("This may lead to missing/broken features in SonarQube");
String docUrl = documentationLinkGenerator.getDocumentationLink(SCM_INTEGRATION_DOCUMENTATION_SUFFIX);
@@ -155,4 +155,3 @@ class DefaultBlameOutput implements BlameOutput {
return filesCount == 1 ? "source file" : "source files";
}
}
-
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmPublisher.java
index be3311e69d7..59c1422e8e8 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmPublisher.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scm/ScmPublisher.java
@@ -81,7 +81,7 @@ public final class ScmPublisher {
List<InputFile> filesToBlame = collectFilesToBlame(writer);
if (!filesToBlame.isEmpty()) {
String key = provider.key();
- LOG.info("SCM Publisher SCM provider for this project is: " + key);
+ LOG.info("SCM Publisher SCM provider for this project is: {}", key);
DefaultBlameOutput output = new DefaultBlameOutput(writer, analysisWarnings, filesToBlame, documentationLinkGenerator);
try {
provider.blameCommand().blame(new DefaultBlameInput(fs, filesToBlame), output);
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorsExecutor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorsExecutor.java
index a7a1c91a73f..fb814b421f9 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorsExecutor.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sensor/ProjectSensorsExecutor.java
@@ -42,9 +42,11 @@ public class ProjectSensorsExecutor {
public void execute() {
List<ProjectSensorWrapper> sensors = selector.selectSensors();
- LOG.debug("Sensors : {}", sensors.stream()
- .map(Object::toString)
- .collect(Collectors.joining(" -> ")));
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Sensors : {}", sensors.stream()
+ .map(Object::toString)
+ .collect(Collectors.joining(" -> ")));
+ }
for (ProjectSensorWrapper sensor : sensors) {
SensorId sensorId = getSensorId(sensor);
executingSensorCtx.setSensorExecuting(sensorId);