Skip to content
Permalink
Browse files

Setting sonar.verbose=true should set sonar-scanner-cli's debug mode

  • Loading branch information...
Amaury Levé
Amaury Levé committed Jul 16, 2018
1 parent 587e09e commit 9919123e6cded53a7e11449a13c58257305fd68c
@@ -168,4 +168,6 @@ $RECYCLE.BIN/
# IntelliJ
.idea
*.iml

/.sonarqube
DeploymentArtifacts/
@@ -214,7 +214,12 @@ public void WriteGlobalSettings(AnalysisProperties properties)

foreach (var setting in properties)
{
AppendKeyValue(sb, setting.Id, setting.Value);
// We should no longer pass the sonar.verbose=true parameter to the scanner CLI.
// See: https://github.com/SonarSource/sonar-scanner-msbuild/issues/543
if (setting.Id != SonarProperties.Verbose)
{
AppendKeyValue(sb, setting.Id, setting.Value);
}
}
sb.AppendLine();
}
@@ -131,7 +131,7 @@ private static string FindScannerExe()

IgnoreSonarScannerHome(logger);

var allCmdLineArgs = GetAllCmdLineArgs(propertiesFileName, userCmdLineArguments, config);
var allCmdLineArgs = GetAllCmdLineArgs(propertiesFileName, userCmdLineArguments, config, logger);

var envVarsDictionary = GetAdditionalEnvVariables(logger);
Debug.Assert(envVarsDictionary != null);
@@ -214,7 +214,8 @@ private static string GetSonarScannerOptsValue(ILogger logger)
/// <summary>
/// Returns all of the command line arguments to pass to sonar-scanner
/// </summary>
private static IEnumerable<string> GetAllCmdLineArgs(string projectSettingsFilePath, IEnumerable<string> userCmdLineArguments, AnalysisConfig config)
private static IEnumerable<string> GetAllCmdLineArgs(string projectSettingsFilePath,
IEnumerable<string> userCmdLineArguments, AnalysisConfig config, ILogger logger)
{
// We don't know what all of the valid command line arguments are so we'll
// just pass them on for the sonar-scanner to validate.
@@ -227,12 +228,21 @@ private static IEnumerable<string> GetAllCmdLineArgs(string projectSettingsFileP
// Experimentation suggests that the sonar-scanner won't error if duplicate arguments
// are supplied - it will just use the last argument.
// So we'll set our additional properties last to make sure they take precedence.
args.Add(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}{1}={2}", CmdLineArgPrefix, ProjectSettingsFileArgName, projectSettingsFilePath));
args.Add(string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}{1}={2}", CmdLineArgPrefix,
ProjectSettingsFileArgName, projectSettingsFilePath));

// Let the scanner cli know it is run as an embedded tool (allows to tweak the behavior)
// See https://jira.sonarsource.com/browse/SQSCANNER-49
args.Add("--embedded");

// For debug mode, we need to pass the debug option to the scanner cli in order to see correctly stack traces.
// Note that in addition to this change, the sonar.verbose=true was removed from the config file.
// See: https://github.com/SonarSource/sonar-scanner-msbuild/issues/543
if (logger.Verbosity == LoggerVerbosity.Debug)
{
args.Add("--debug");
}

return args;
}

0 comments on commit 9919123

Please sign in to comment.
You can’t perform that action at this time.