Ejemplo n.º 1
0
        /// <summary>
        /// Fetch all rules in the specified quality, both active and inactive
        /// </summary>
        public static async Task <IList <SonarQubeRule> > GetAllRulesAsync(this ISonarQubeService sonarQubeService, string qualityProfileKey, CancellationToken token)
        {
            var activeRules = await sonarQubeService.GetRulesAsync(true, qualityProfileKey, token);

            token.ThrowIfCancellationRequested();

            var inactiveRules = await sonarQubeService.GetRulesAsync(false, qualityProfileKey, token);

            var allRules = (activeRules ?? Enumerable.Empty <SonarQubeRule>())
                           .Union(inactiveRules ?? Enumerable.Empty <SonarQubeRule>())
                           .ToList();

            return(allRules);
        }
        private async Task <IEnumerable <SonarQubeRule> > FetchSupportedRulesAsync(bool active, string qpKey, CancellationToken cancellationToken)
        {
            var rules = await WebServiceHelper.SafeServiceCallAsync(
                () => sonarQubeService.GetRulesAsync(active, qpKey, cancellationToken), logger);

            return(rules.Where(IsSupportedRule).ToArray());
        }