Repository: PowerShell/PowerShell
File: src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs (C#)

Code before:
                    else
                    {
                        list = new List<object> { value, baseObj };
                        commandTable[name] = list;
                    }
                }
            }

            List<CompletionResult> endResults = null;
            foreach (var keyValuePair in commandTable)
            {
                if (keyValuePair.Value is List<object> commandList)
                {
                    var modulesWithCommand = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
                    var importedModules = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
                    var commandInfoArray = new CommandInfo[commandList.Count];
                    for (int i = 0; i < commandInfoArray.Length; i++)
                    {
                        var commandInfo = (CommandInfo)commandList[i];
                        commandInfoArray[i] = commandInfo;
                        if (commandInfo.CommandType == CommandTypes.Application)
                        {
                            continue;
                        }

                        _ = modulesWithCommand.Add(commandInfo.ModuleName);
                        if ((commandInfo.CommandType != CommandTypes.Alias && commandInfo.CommandMetadata.CommandType is not null)
                            || (commandInfo.CommandType == CommandTypes.Alias && commandInfo.Definition is not null))
                        {
                            _ = importedModules.Add(commandInfo.ModuleName);
                        }
                    }

                    int moduleCount = modulesWithCommand.Count;
                    modulesWithCommand.Clear();
                    int index;
                    if (commandInfoArray[0].CommandType == CommandTypes.Application
                        || importedModules.Count == 1
                        || moduleCount < 2)
                    {
                        // We can use the short name for this command because there's no ambiguity about which command it resolves to.
                        index = 1;
                        results.Add(GetCommandNameCompletionResult(keyValuePair.Key, commandInfoArray[0], addAmpersandIfNecessary, quote));
                        _ = modulesWithCommand.Add(commandInfoArray[0].ModuleName);
                    }
                    else
                    {
                        index = 0;
                    }

                    for (; index < commandInfoArray.Length; index++)

Review comment (suggestion):
Please remove the `_ =` part from below, I believe it's not needed.
```suggestion
                        modulesWithCommand.Add(commandInfo.ModuleName);
```

Code after:
                    }
                    else
                    {
                        list = new List<object> { value, baseObj };
                        commandTable[name] = list;
                    }
                }
            }

            foreach (var keyValuePair in commandTable)
            {
                if (keyValuePair.Value is List<object> commandList)
                {
                    var modulesWithCommand = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
                    var importedModules = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
                    var commandInfoList = new List<CommandInfo>(commandList.Count);
                    for (int i = 0; i < commandList.Count; i++)
                    {
                        if (commandList[i] is not CommandInfo commandInfo)
                        {
                            continue;
                        }

                        commandInfoList.Add(commandInfo);
                        if (commandInfo.CommandType == CommandTypes.Application)
                        {
                            continue;
                        }

                        modulesWithCommand.Add(commandInfo.ModuleName);
                        if ((commandInfo.CommandType == CommandTypes.Cmdlet && commandInfo.CommandMetadata.CommandType is not null)
                            || (commandInfo.CommandType is CommandTypes.Function or CommandTypes.Filter && commandInfo.Definition != string.Empty)
                            || (commandInfo.CommandType == CommandTypes.Alias && commandInfo.Definition is not null))
                        {
                            // Checks if the command or source module has been imported.
                            _ = importedModules.Add(commandInfo.ModuleName);
                        }
                    }

                    if (commandInfoList.Count == 0)
                    {
                        continue;
                    }

                    int moduleCount = modulesWithCommand.Count;
                    modulesWithCommand.Clear();
                    int index;
                    if (commandInfoList[0].CommandType == CommandTypes.Application
                        || importedModules.Count == 1
                        || moduleCount < 2)
                    {