public bool Execute(string[] args, AnalysisConfig config, TeamBuildSettings settings, ILogger logger)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }

            IAnalysisPropertyProvider provider;
            if (!ArgumentProcessor.TryProcessArgs(args, logger, out provider))
            {
                return false;
            }

            logger.Verbosity = VerbosityCalculator.ComputeVerbosity(config.GetAnalysisSettings(true), logger);
            LogStartupSettings(config, settings, logger);

            if (!CheckEnvironmentConsistency(config, settings, logger))
            {
                return false;
            }

            // if initialisation fails a warning will have been logged at the source of the failure
            bool initialised = this.codeCoverageProcessor.Initialise(config, settings, logger);

            if (initialised && !this.codeCoverageProcessor.ProcessCoverageReports())
            {
                //  if processing fails, stop the workflow
                return false;
            }

            ProjectInfoAnalysisResult result = InvokeSonarRunner(provider, config, logger);
            this.reportBuilder.GenerateReports(settings, config, result, logger);
            return result.RanToCompletion;
        }
        private string TryGetRegularExpression(AnalysisConfig config)
        {
            Debug.Assert(config != null, "Not expecting the supplied config to be null");

            string regEx;
            config.GetAnalysisSettings(true).TryGetValue(TestRegExSettingId, out regEx);

            if (!string.IsNullOrWhiteSpace(regEx))
            {
                this.Log.LogMessage(MessageImportance.Low, Resources.IsTest_UsingRegExFromConfig, regEx);
            }

            return regEx;
        }
        /// <summary>
        /// Returns all of the analysis properties that should
        /// be written to the sonar-project properties file
        /// </summary>
        private static AnalysisProperties GetAnalysisPropertiesToWrite(AnalysisConfig config, ILogger logger)
        {
            AnalysisProperties properties = new AnalysisProperties();

            properties.AddRange(config.GetAnalysisSettings(false).GetAllProperties()
                // Strip out any sensitive properties
                .Where(p => !p.ContainsSensitiveData()));

            // There are some properties we want to override regardless of what the user sets
            AddOrSetProperty(VSBootstrapperPropertyKey, "false", properties, logger);

            return properties;
        }
        private static IEnumerable<string> GetSensitiveFileSettings(AnalysisConfig config, IEnumerable<string> userCmdLineArguments)
        {
            IEnumerable<Property> allPropertiesFromConfig = config.GetAnalysisSettings(false).GetAllProperties();

            return allPropertiesFromConfig.Where(p => p.ContainsSensitiveData() && !UserSettingExists(p, userCmdLineArguments))
                .Select(p => p.AsSonarRunnerArg());
        }
 private static void AssertSettingDoesNotExist(string key, AnalysisConfig actualConfig)
 {
     Property setting;
     bool found = actualConfig.GetAnalysisSettings(true).TryGetProperty(key, out setting);
     Assert.IsFalse(found, "The setting should not exist. Key: {0}", key);
 }
        private static string FindBranch(AnalysisConfig config)
        {
            string branch = null;

            IAnalysisPropertyProvider localSettings = config.GetAnalysisSettings(includeServerSettings: false);
            Debug.Assert(localSettings != null);

            localSettings.TryGetValue(SonarProperties.ProjectBranch, out branch);

            return branch;
        }
        private static void VerifySummaryReportData(
            SummaryReportBuilder.SummaryReportData summaryReportData,
            ProjectInfoAnalysisResult analysisResult,
            string expectedHostUrl,
            AnalysisConfig config)
        {
            string expectedUrl;
            string branch;

            config.GetAnalysisSettings(false).TryGetValue("sonar.branch", out branch);

            if (String.IsNullOrEmpty(branch))
            {
                expectedUrl = String.Format(
                    SummaryReportBuilder.DashboardUrlFormat, 
                    expectedHostUrl, 
                    config.SonarProjectKey);
            }
            else
            {
                expectedUrl = String.Format(
                    SummaryReportBuilder.DashboardUrlFormatWithBranch, 
                    expectedHostUrl, 
                    config.SonarProjectKey, 
                    branch);
            }

            Assert.AreEqual(expectedUrl, summaryReportData.DashboardUrl, "Invalid dashboard url");
            Assert.AreEqual(analysisResult.RanToCompletion, summaryReportData.Succeeded, "Invalid outcome");

        }