public IEnumerable <Mutation> Generate(string arg)
        {
            for (int i = 0; i < arg.Length; i++)
            {
                List <char> n = QwertyKeyboardHelper.GetNeighboringCharacters(arg[i]).ToList();

                foreach (char c in n)
                {
                    // We don't want mutations like pkg:npm//lodash, that is the same as pkg:npm/lodash
                    if (i == 0 && c == '/')
                    {
                        continue;
                    }

                    yield return(new Mutation(
                                     mutated: string.Concat(arg[..i], c, arg[i..]),
Exemple #2
0
        public IEnumerable <Mutation> Generate(string arg)
        {
            for (int i = 0; i < arg.Length; i++)
            {
                List <char>?n = QwertyKeyboardHelper.GetNeighboringCharacters(arg[i]).ToList();

                foreach (char c in n)
                {
                    // We don't want mutations like pkg:npm//odash mutated from pkg:npm/lodash that is the same as pkg:npm/odash
                    if (i == 0 && c == '/')
                    {
                        continue;
                    }

                    yield return(new Mutation(
                                     mutated: arg.ReplaceCharAtPosition(c, i),
                                     original: arg,
                                     mutator: Kind,
                                     reason: $"Close Letters on QWERTY Keyboard: {arg[i]} => {c}"));
                }
            }
        }