NormalizeFormatId() public static method

public static NormalizeFormatId ( string ruleId, string formatId ) : string
ruleId string
formatId string
return string
Esempio n. 1
0
        public static Result BuildResult(ResultLevel level, IAnalysisContext context, Region region, string formatId, params string[] arguments)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (arguments == null)
            {
                throw new ArgumentNullException(nameof(arguments));
            }

            formatId = RuleUtilities.NormalizeFormatId(context.Rule.Id, formatId);

            Result result = new Result
            {
                RuleId = context.Rule.Id,

                FormattedRuleMessage = new FormattedRuleMessage()
                {
                    FormatId  = formatId,
                    Arguments = arguments
                },

                Level = level
            };

            string targetPath = context.TargetUri?.LocalPath;

            if (targetPath != null)
            {
                result.Locations = new List <Location> {
                    new Sarif.Location {
                        AnalysisTarget = new PhysicalLocation
                        {
                            Uri    = new Uri(targetPath),
                            Region = region
                        }
                    }
                };
            }

            if (level == ResultLevel.Warning)
            {
                context.RuntimeErrors |= RuntimeConditions.OneOrMoreWarningsFired;
            }

            if (level == ResultLevel.Error)
            {
                context.RuntimeErrors |= RuntimeConditions.OneOrMoreErrorsFired;
            }

            return(result);
        }