-
-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve uninstaller check function #3197
Conversation
This comment has been minimized.
This comment has been minimized.
🥷 Code experts: no user matched threshold 10 VictoriousRaptor, jjw24 have most 🧠 knowledge in the files. See details
Knowledge based on git-blame: To learn more about /:\ gitStream - Visit our Docs |
Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX. |
📝 WalkthroughWalkthroughThe pull request enhances the uninstaller detection mechanism in the Flow Launcher Program Plugin. The changes introduce a more comprehensive approach to identifying uninstallers by expanding the filtering logic to support multiple languages and file types. The modifications include adding new static arrays for uninstaller prefixes, updating the suffix naming, and implementing a more robust checking mechanism for both executable and link files. Changes
Possibly related PRs
Suggested labels
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
Plugins/Flow.Launcher.Plugin.Program/Main.cs (2)
72-73
: Clarify “Ink” vs. “Lnk.”
InkUninstallerSuffix
is set to.lnk
. This might be confusing. If it represents the Windows shortcut extension, consider renaming the constant toLnkUninstallerSuffix
for clarity.
127-137
: Consolidate uninstaller name checks.
The logic is clear and understandable. However, the checks for uninstaller prefixes (StartsWith
+EndsWith
) could benefit from a small helper method to avoid repetition, enhance clarity, and reduce potential errors if this logic must be updated later.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
Plugins/Flow.Launcher.Plugin.Program/Main.cs
(2 hunks)
🧰 Additional context used
🪛 GitHub Check: Check Spelling
Plugins/Flow.Launcher.Plugin.Program/Main.cs
[notice] 51-51:
Line
matches candidate pattern [a-zA-Z]*[ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź][a-zA-Z]{3}[a-zA-ZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź]*
(candidate-pattern)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: gitStream.cm
🔇 Additional comments (3)
Plugins/Flow.Launcher.Plugin.Program/Main.cs (3)
44-71
: Use correct English plural and verify translations.
The field namecommonUninstallerPrefixs
is misspelled; consider renaming it tocommonUninstallerPrefixes
. Also, ensure that each localized prefix is accurately spelled and that language-specific characters are properly supported in file system operations.🧰 Tools
🪛 GitHub Check: Check Spelling
[notice] 51-51:
Line
matches candidate pattern[a-zA-Z]*[ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź][a-zA-Z]{3}[a-zA-ZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź]*
(candidate-pattern)
139-150
: Verify .lnk filename vs. resolved path usage.
The code checks the.lnk
filename itself rather than the target ofwin32.LnkResolvedPath
. If the intention is to hide uninstallers that are references to an EXE, you may need to check the resolved path’s filename. Otherwise, this logic is correct if you're strictly matching the.lnk
file’s own name.
152-152
: Looks good.
Returningtrue
at the end ensures all non-matching items are displayed. No concerns here.
@check-spelling-bot Report🔴 Please reviewSee the 📂 files view, the 📜action log, or 📝 job summary for details.
See ❌ Event descriptions for more information. Pattern suggestions ✂️ (1)You could add these patterns to
If the flagged items are 🤯 false positivesIf items relate to a ...
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
Plugins/Flow.Launcher.Plugin.Program/Main.cs (2)
44-71
: Fix spelling in array name and standardize language codes in comments.The array name has a spelling error and the language codes in comments could be more consistent.
Apply this diff to fix the spelling and standardize comments:
- private static readonly string[] commonUninstallerPrefixs = + private static readonly string[] commonUninstallerPrefixes = { - "uninstall",//en - "卸载",//zh-cn - "卸載",//zh-tw - "видалити",//uk-UA - "удалить",//ru - "désinstaller",//fr - "アンインストール",//ja - "deïnstalleren",//nl - "odinstaluj",//pl - "afinstallere",//da - "deinstallieren",//de - "삭제",//ko - "деинсталирај",//sr - "desinstalar",//pt-pt - "desinstalar",//pt-br - "desinstalar",//es - "desinstalar",//es-419 - "disinstallare",//it - "avinstallere",//nb-NO - "odinštalovať",//sk - "kaldır",//tr - "odinstalovat",//cs - "إلغاء التثبيت",//ar - "gỡ bỏ",//vi-vn - "הסרה"//he + "uninstall", // en-US + "卸载", // zh-CN + "卸載", // zh-TW + "видалити", // uk-UA + "удалить", // ru-RU + "désinstaller", // fr-FR + "アンインストール", // ja-JP + "deïnstalleren", // nl-NL + "odinstaluj", // pl-PL + "afinstallere", // da-DK + "deinstallieren",// de-DE + "삭제", // ko-KR + "деинсталирај", // sr-RS + "desinstalar", // pt-PT + "desinstalar", // pt-BR + "desinstalar", // es-ES + "desinstalar", // es-419 + "disinstallare", // it-IT + "avinstallere", // nb-NO + "odinštalovať", // sk-SK + "kaldır", // tr-TR + "odinstalovat", // cs-CZ + "إلغاء التثبيت", // ar-SA + "gỡ bỏ", // vi-VN + "הסרה" // he-IL };Consider adding support for additional languages like Swedish (sv-SE), Finnish (fi-FI), and Hungarian (hu-HU) to improve coverage.
🧰 Tools
🪛 GitHub Check: Check Spelling
[notice] 51-51:
Line
matches candidate pattern[a-zA-Z]*[ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź][a-zA-Z]{3}[a-zA-ZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź]*
(candidate-pattern)
126-152
: Improve method organization and performance.The method could benefit from better organization and performance optimizations:
- Split into smaller methods for better maintainability
- Use HashSet for faster lookups
- Add null check for ExecutablePath
Consider refactoring to:
private bool HideUninstallersFilter(IProgram program) { if (!_settings.HideUninstallers) return true; if (program is not Win32 win32) return true; + if (string.IsNullOrEmpty(win32.ExecutablePath)) return true; - // First check the executable path - var fileName = Path.GetFileName(win32.ExecutablePath); - // For cases when the uninstaller is named like "uninst.exe" - if (commonUninstallerNames.Contains(fileName, StringComparer.OrdinalIgnoreCase)) return false; - // For cases when the uninstaller is named like "Uninstall Program Name.exe" - foreach (var prefix in commonUninstallerPrefixs) - { - if (fileName.StartsWith(prefix, StringComparison.OrdinalIgnoreCase) && - fileName.EndsWith(ExeUninstallerSuffix, StringComparison.OrdinalIgnoreCase)) - return false; - } + if (IsUninstallerExecutable(win32.ExecutablePath)) return false; + if (IsUninstallerShortcut(win32.LnkResolvedPath, win32.FullPath)) return false; - // Second check the lnk path - if (!string.IsNullOrEmpty(win32.LnkResolvedPath)) + return true; + } + + private static readonly HashSet<string> _commonUninstallerNames = + new(commonUninstallerNames, StringComparer.OrdinalIgnoreCase); + + private bool IsUninstallerExecutable(string executablePath) + { + var fileName = Path.GetFileName(executablePath); + + // Check for exact matches like "uninst.exe" + if (_commonUninstallerNames.Contains(fileName)) + return true; + + // Check for prefixed names like "Uninstall Program Name.exe" + return commonUninstallerPrefixes.Any(prefix => + fileName.StartsWith(prefix, StringComparison.OrdinalIgnoreCase) && + fileName.EndsWith(ExeUninstallerSuffix, StringComparison.OrdinalIgnoreCase)); + } + + private bool IsUninstallerShortcut(string resolvedPath, string fullPath) + { + if (string.IsNullOrEmpty(resolvedPath)) + return false; + + var shortcutName = Path.GetFileName(fullPath); + return commonUninstallerPrefixes.Any(prefix => + shortcutName.StartsWith(prefix, StringComparison.OrdinalIgnoreCase) && + shortcutName.EndsWith(InkUninstallerSuffix, StringComparison.OrdinalIgnoreCase)); + }This refactoring:
- Improves readability by extracting logic into well-named methods
- Uses HashSet for O(1) lookups of exact matches
- Adds null check for ExecutablePath
- Uses LINQ for more concise prefix checking
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
Plugins/Flow.Launcher.Plugin.Program/Main.cs
(2 hunks)
🧰 Additional context used
🪛 GitHub Check: Check Spelling
Plugins/Flow.Launcher.Plugin.Program/Main.cs
[notice] 51-51:
Line
matches candidate pattern [a-zA-Z]*[ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź][a-zA-Z]{3}[a-zA-ZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿĀāŁłŃńŅņŒœŚśŠšŜŝŸŽžź]*
(candidate-pattern)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: gitStream.cm
- GitHub Check: gitStream.cm
- GitHub Check: gitStream.cm
Improve uninstaller check function