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

Code before:
        /// <summary>
        /// Gets the help message text for the parameter attribute.
        /// </summary>
        /// <param name="attr">The attribute to check for the help message.</param>
        /// <param name="assembly">The assembly to lookup resources messages, this should be the assembly the cmdlet is defined in.</param>
        /// <returns>The help message of the parameter or <c>null</c> if none is defined.></returns>
        private static string? GetParameterHelpMessage(
            ParameterAttribute attr,
            Assembly? assembly = null)
        {
            if (!string.IsNullOrWhiteSpace(attr.HelpMessage))
            {
                return attr.HelpMessage.Trim();
            }

            if (assembly is null || string.IsNullOrWhiteSpace(attr.HelpMessageBaseName) || string.IsNullOrWhiteSpace(attr.HelpMessageResourceId))
            {
                return null;
            }

            try
            {
                return ResourceManagerCache.GetResourceString(assembly, attr.HelpMessageBaseName, attr.HelpMessageResourceId)?.Trim();
            }
            catch (Exception)
            {
                return null;
            }
        }
#nullable disable

        /// <summary>
        /// Get the parameter completion results by using the given valid parameter sets and available parameters.
        /// </summary>
        /// <param name="parameterName"></param>
        /// <param name="validParameterSetFlags"></param>
        /// <param name="parameters"></param>
        /// <param name="withColon"></param>
        /// <param name="commandAssembly">Optional assembly used to lookup parameter help messages.</param>
        /// <returns></returns>
        private static List<CompletionResult> GetParameterCompletionResults(
            string parameterName,
            uint validParameterSetFlags,
            IEnumerable<MergedCompiledCommandParameter> parameters,
            bool withColon,
            Assembly commandAssembly = null)
        {
            var result = new List<CompletionResult>();
            var commonParamResult = new List<CompletionResult>();
            var pattern = WildcardPattern.Get(parameterName + "*", WildcardOptions.IgnoreCase);
            var colonSuffix = withColon ? ":" : string.Empty;

Review comment (bug):
HelpMessage, HelpMessageBaseName and HelpMessageResourceId are checked for null or empty in Attribute code. So we can check only for null. 
Trim() assume there is a bug in the values. We shouldn't hide bugs.
 ```suggestion
             if (attr.HelpMessage is not null)
             {
                 return attr.HelpMessage;
             }
```

Code after:
                }
            }

            return result;
        }

#nullable enable
        /// <summary>
        /// Try and get the help message text for the parameter attribute.
        /// </summary>
        /// <param name="attr">The attribute to check for the help message.</param>
        /// <param name="assembly">The assembly to lookup resources messages, this should be the assembly the cmdlet is defined in.</param>
        /// <param name="message">The help message if it was found otherwise null.</param>
        /// <returns>True if the help message was set or false if not.></returns>
        private static bool TryGetParameterHelpMessage(
            ParameterAttribute attr,
            Assembly? assembly,
            [NotNullWhen(true)] out string? message)
        {
            message = null;
            
            if (attr.HelpMessage is not null)
            {
                message = attr.HelpMessage;
                return true;
            }

            if (assembly is null || attr.HelpMessageBaseName is null || attr.HelpMessageResourceId is null)
            {
                return false;
            }

            try
            {
                message = ResourceManagerCache.GetResourceString(assembly, attr.HelpMessageBaseName, attr.HelpMessageResourceId);
                return message is not null;
            }
            catch (Exception)
            {
                return false;
            }
        }
#nullable disable

        /// <summary>
        /// Get the parameter completion results by using the given valid parameter sets and available parameters.
        /// </summary>
        /// <param name="parameterName"></param>
        /// <param name="validParameterSetFlags"></param>
        /// <param name="parameters"></param>
        /// <param name="withColon"></param>