public void Generate(SonarWebService ws, string sonarProjectKey, string outputFilePath) { if (ws == null) { throw new ArgumentNullException("ws"); } if (string.IsNullOrWhiteSpace(sonarProjectKey)) { throw new ArgumentNullException("sonarProjectKey"); } if (string.IsNullOrWhiteSpace(outputFilePath)) { throw new ArgumentNullException("outputFilePath"); } var qualityProfile = ws.GetQualityProfile(sonarProjectKey); var activeRuleKeys = ws.GetActiveRuleKeys(qualityProfile); if (activeRuleKeys.Any()) { var internalKeys = ws.GetInternalKeys(); var ids = activeRuleKeys.Select( k => { var fullKey = Repository + ':' + k; return(internalKeys.ContainsKey(fullKey) ? internalKeys[fullKey] : k); }); File.WriteAllText(outputFilePath, RulesetWriter.ToString(ids)); } else { File.Delete(outputFilePath); } }
public void Generate(SonarWebService ws, string requiredPluginKey, string language, string fxcopRepositoryKey, string sonarProjectKey, string outputFilePath) { if (ws == null) { throw new ArgumentNullException("ws"); } if (string.IsNullOrWhiteSpace(requiredPluginKey)) { throw new ArgumentNullException("requiredPluginKey"); } if (string.IsNullOrWhiteSpace(language)) { throw new ArgumentNullException("language"); } if (string.IsNullOrWhiteSpace(fxcopRepositoryKey)) { throw new ArgumentNullException("fxcopRepositoryKey"); } if (string.IsNullOrWhiteSpace(sonarProjectKey)) { throw new ArgumentNullException("sonarProjectKey"); } if (string.IsNullOrWhiteSpace(outputFilePath)) { throw new ArgumentNullException("outputFilePath"); } IEnumerable <string> activeRuleKeys = Enumerable.Empty <string>(); if (ws.GetInstalledPlugins().Contains(requiredPluginKey)) { string qualityProfile; if (ws.TryGetQualityProfile(sonarProjectKey, language, out qualityProfile)) { activeRuleKeys = ws.GetActiveRuleKeys(qualityProfile, language, fxcopRepositoryKey); } } if (activeRuleKeys.Any()) { var internalKeys = ws.GetInternalKeys(fxcopRepositoryKey); var ids = activeRuleKeys.Select( k => { var fullKey = fxcopRepositoryKey + ':' + k; return(internalKeys.ContainsKey(fullKey) ? internalKeys[fullKey] : k); }); File.WriteAllText(outputFilePath, RulesetWriter.ToString(ids)); } else { File.Delete(outputFilePath); } }
public void Generate(SonarWebService ws, string requiredPluginKey, string language, string fxcopRepositoryKey, string sonarProjectKey, string outputFilePath) { if (ws == null) { throw new ArgumentNullException("ws"); } if (string.IsNullOrWhiteSpace(requiredPluginKey)) { throw new ArgumentNullException("requiredPluginKey"); } if (string.IsNullOrWhiteSpace(language)) { throw new ArgumentNullException("language"); } if (string.IsNullOrWhiteSpace(fxcopRepositoryKey)) { throw new ArgumentNullException("fxcopRepositoryKey"); } if (string.IsNullOrWhiteSpace(sonarProjectKey)) { throw new ArgumentNullException("sonarProjectKey"); } if (string.IsNullOrWhiteSpace(outputFilePath)) { throw new ArgumentNullException("outputFilePath"); } IEnumerable<string> activeRuleKeys = Enumerable.Empty<string>(); if (ws.GetInstalledPlugins().Contains(requiredPluginKey)) { string qualityProfile; if (ws.TryGetQualityProfile(sonarProjectKey, language, out qualityProfile)) { activeRuleKeys = ws.GetActiveRuleKeys(qualityProfile, language, fxcopRepositoryKey); } } if (activeRuleKeys.Any()) { var internalKeys = ws.GetInternalKeys(fxcopRepositoryKey); var ids = activeRuleKeys.Select( k => { var fullKey = fxcopRepositoryKey + ':' + k; return internalKeys.ContainsKey(fullKey) ? internalKeys[fullKey] : k; }); File.WriteAllText(outputFilePath, RulesetWriter.ToString(ids)); } else { File.Delete(outputFilePath); } }