Repository: microsoft/PowerToys
File: src/modules/launcher/Plugins/Community.PowerToys.Run.Plugin.ValueGenerator/Main.cs (C#)

Code before:
            {
                IComputeRequest computeRequest = _inputParser.ParseInput(query);
                var result = GetResult(computeRequest);

                if (!string.IsNullOrEmpty(result.Title))
                {
                    results.Add(result);
                }
                else
                {
                    return results;
                }
            }
            catch (ArgumentException e)
            {
                results.Add(GetErrorResult(e.Message));
            }
            catch (FormatException e)
            {
                Log.Debug(GetTranslatedPluginTitle() + ": " + e.Message, GetType());
                if (string.IsNullOrEmpty(query.ActionKeyword))
                {
                    return results;
                }

                return GetSuggestionFuzzyResults(query, results);
            }

            return results;
        }

        private List<Result> GetSuggestionResults(Query query, List<Result> results)
        {
            foreach (var generatorItem in QueryHelper.GeneratorList)
            {
                results.Add(new Result
                {
                    Title = generatorItem.Key,
                    SubTitle = generatorItem.Value,
                    IcoPath = GetIcoPath(),
                    Action = c =>
                    {
                        _context.API.ChangeQuery($"{query.ActionKeyword} {generatorItem.Key}");
                        return false;
                    },
                });
            }

            return results;
        }


Review comment (refactor):
I suggest put the "get suggestions" code into the if and switch to negated (not keyword empty). Then you can remove the `return results;` and we have less duplicate code.

Code after:
            {
                IComputeRequest computeRequest = _inputParser.ParseInput(query);
                var result = GetResult(computeRequest);

                if (!string.IsNullOrEmpty(result.Title))
                {
                    results.Add(result);
                }
                else
                {
                    return results;
                }
            }
            catch (ArgumentException e)
            {
                results.Add(GetErrorResult(e.Message));
            }
            catch (FormatException e)
            {
                Log.Debug(GetTranslatedPluginTitle() + ": " + e.Message, GetType());
                if (!string.IsNullOrEmpty(query.ActionKeyword))
                {
                    return GetSuggestionFuzzyResults(query, results);
                }
            }

            return results;
        }

        private List<Result> GetSuggestionResults(Query query, List<Result> results)
        {
            foreach (var generatorData in QueryHelper.GeneratorDataList)
            {
                results.Add(new Result
                {
                    Title = QueryHelper.GetResultTitle(generatorData),
                    SubTitle = QueryHelper.GetResultSubtitle(generatorData),
                    IcoPath = GetIcoPath(),
                    ToolTipData = new ToolTipData(QueryHelper.GetResultTitle(generatorData), QueryHelper.GetResultSubtitle(generatorData)),
                    QueryTextDisplay = generatorData.Keyword + " ",
                    Action = c =>
                    {
                        _context.API.ChangeQuery($"{query.ActionKeyword} {generatorData.Keyword} ", true);
                        return false;
                    },
                });
            }

            return results;
        }