diff options
author | Eric Giffon <eric.giffon@sonarsource.com> | 2023-03-30 11:09:11 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-03-30 20:03:07 +0000 |
commit | e36fcb5a436559c4b2fa1ae4ed5618a882002ba1 (patch) | |
tree | cf8c70793acac802b834c680e1ef8dcb383d9df2 /sonar-scanner-engine/src/main/java/org/sonar/scanner/scan | |
parent | 2628add44f0d29a5a1bc15f2bcb5da4264822114 (diff) | |
download | sonarqube-e36fcb5a436559c4b2fa1ae4ed5618a882002ba1.tar.gz sonarqube-e36fcb5a436559c4b2fa1ae4ed5618a882002ba1.zip |
SONAR-18828 Specify dotnet scanner version in warning
Diffstat (limited to 'sonar-scanner-engine/src/main/java/org/sonar/scanner/scan')
-rw-r--r-- | sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/DeprecatedPropertiesWarningGenerator.java | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/DeprecatedPropertiesWarningGenerator.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/DeprecatedPropertiesWarningGenerator.java index 8dfb0eccf3e..0a2b46d7a57 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/DeprecatedPropertiesWarningGenerator.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/DeprecatedPropertiesWarningGenerator.java @@ -21,11 +21,13 @@ package org.sonar.scanner.scan; import com.google.common.annotations.VisibleForTesting; import java.util.Optional; +import org.apache.commons.lang.StringUtils; import org.sonar.api.CoreProperties; import org.sonar.api.config.Configuration; import org.sonar.api.notifications.AnalysisWarnings; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; +import org.sonar.batch.bootstrapper.EnvironmentInformation; import org.sonar.scanner.bootstrap.ScannerWsClientProvider; public class DeprecatedPropertiesWarningGenerator { @@ -38,24 +40,43 @@ public class DeprecatedPropertiesWarningGenerator { @VisibleForTesting static final String LOGIN_WARN_MESSAGE = String.format("The property '%s' is deprecated and will be removed in the future. " + "Please use the '%s' property instead when passing a token.", CoreProperties.LOGIN, ScannerWsClientProvider.TOKEN_PROPERTY); + @VisibleForTesting + static final String SCANNER_DOTNET_WARN_MESSAGE = String.format(" The '%s' property is available from SonarScanner " + + "for .NET version 5.13.", ScannerWsClientProvider.TOKEN_PROPERTY); + private static final String ENV_KEY_SCANNER_DOTNET = "ScannerMSBuild"; private final Configuration configuration; private final AnalysisWarnings analysisWarnings; + private final EnvironmentInformation environmentInformation; - public DeprecatedPropertiesWarningGenerator(Configuration configuration, AnalysisWarnings analysisWarnings) { + public DeprecatedPropertiesWarningGenerator(Configuration configuration, AnalysisWarnings analysisWarnings, + EnvironmentInformation environmentInformation) { this.configuration = configuration; this.analysisWarnings = analysisWarnings; + this.environmentInformation = environmentInformation; } public void execute() { Optional<String> login = configuration.get(CoreProperties.LOGIN); Optional<String> password = configuration.get(CoreProperties.PASSWORD); + + String warningMessage = null; if (password.isPresent()) { - LOG.warn(PASSWORD_WARN_MESSAGE); - analysisWarnings.addUnique(PASSWORD_WARN_MESSAGE); + warningMessage = PASSWORD_WARN_MESSAGE; } else if (login.isPresent()) { - LOG.warn(LOGIN_WARN_MESSAGE); - analysisWarnings.addUnique(LOGIN_WARN_MESSAGE); + warningMessage = LOGIN_WARN_MESSAGE; + } + + if (warningMessage != null) { + if (isScannerDotNet()) { + warningMessage += SCANNER_DOTNET_WARN_MESSAGE; + } + LOG.warn(warningMessage); + analysisWarnings.addUnique(warningMessage); } } + + private boolean isScannerDotNet() { + return StringUtils.containsIgnoreCase(environmentInformation.getKey(), ENV_KEY_SCANNER_DOTNET); + } } |