Skip to content

Add localizations#152

Draft
Sella-GH wants to merge 35 commits into
mainfrom
dev/LocalizationSystem
Draft

Add localizations#152
Sella-GH wants to merge 35 commits into
mainfrom
dev/LocalizationSystem

Conversation

@Sella-GH

@Sella-GH Sella-GH commented Aug 8, 2024

Copy link
Copy Markdown
Owner

No description provided.

@Sella-GH Sella-GH added enhancement New feature or request dev-next labels Aug 8, 2024
@Sella-GH Sella-GH added this to the 2.0 Rewrite milestone Aug 8, 2024
@Sella-GH Sella-GH self-assigned this Aug 8, 2024
@Sella-GH Sella-GH changed the title Dev/localization system Add localizations Aug 8, 2024
@Sella-GH Sella-GH marked this pull request as draft August 8, 2024 08:29
Signed-off-by: Sellara <147769367+Sella-GH@users.noreply.github.com>
@Sella-GH Sella-GH modified the milestones: 2.0.0 Rewrite, 2.1.0 Aug 10, 2024
Signed-off-by: Sellara <147769367+Sella-GH@users.noreply.github.com>
@Sella-GH Sella-GH added area-bot Stuff which is related to the bot area-core Stuff which is related to the core library and removed 2.0.0 (Rewrite) labels Aug 16, 2024
Comment on lines +85 to +89
foreach (string excluded in excludedCommands)
{
if (fullSymbolName.EndsWith($"{excluded}.description", StringComparison.OrdinalIgnoreCase))
return true;
}

Check notice

Code scanning / CodeQL

Missed opportunity to use Where Note

This foreach loop
implicitly filters its target sequence
- consider filtering the sequence explicitly using '.Where(...)'.

Copilot Autofix

AI 6 months ago

To fix the issue, replace the foreach loop that checks for a matching excluded entry with a single LINQ expression using .Any(). Specifically, change:

foreach (string excluded in excludedCommands)
{
    if (fullSymbolName.EndsWith($"{excluded}.description", StringComparison.OrdinalIgnoreCase))
        return true;
}

to:

if (excludedCommands.Any(excluded => fullSymbolName.EndsWith($"{excluded}.description", StringComparison.OrdinalIgnoreCase)))
    return true;

You may need to ensure that System.Linq is imported at the top of the file to allow usage of .Any(). No other logic or structure in the file needs to be changed.


Suggested changeset 1
src/AzzyBot.Bot/Localization/CommandLocalizer.cs

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/AzzyBot.Bot/Localization/CommandLocalizer.cs b/src/AzzyBot.Bot/Localization/CommandLocalizer.cs
--- a/src/AzzyBot.Bot/Localization/CommandLocalizer.cs
+++ b/src/AzzyBot.Bot/Localization/CommandLocalizer.cs
@@ -5,6 +5,7 @@
 using System.Globalization;
 using System.Resources;
 using System.Threading.Tasks;
+using System.Linq;
 using DSharpPlus.Commands.Processors.SlashCommands.Localization;
 using Microsoft.Extensions.Logging;
 
@@ -82,11 +83,8 @@
         ArgumentException.ThrowIfNullOrWhiteSpace(fullSymbolName);
 
         string[] excludedCommands = ["core.stats"];
-        foreach (string excluded in excludedCommands)
-        {
-            if (fullSymbolName.EndsWith($"{excluded}.description", StringComparison.OrdinalIgnoreCase))
-                return true;
-        }
+        if (excludedCommands.Any(excluded => fullSymbolName.EndsWith($"{excluded}.description", StringComparison.OrdinalIgnoreCase)))
+            return true;
 
         return false;
     }
EOF
@@ -5,6 +5,7 @@
using System.Globalization;
using System.Resources;
using System.Threading.Tasks;
using System.Linq;
using DSharpPlus.Commands.Processors.SlashCommands.Localization;
using Microsoft.Extensions.Logging;

@@ -82,11 +83,8 @@
ArgumentException.ThrowIfNullOrWhiteSpace(fullSymbolName);

string[] excludedCommands = ["core.stats"];
foreach (string excluded in excludedCommands)
{
if (fullSymbolName.EndsWith($"{excluded}.description", StringComparison.OrdinalIgnoreCase))
return true;
}
if (excludedCommands.Any(excluded => fullSymbolName.EndsWith($"{excluded}.description", StringComparison.OrdinalIgnoreCase)))
return true;

return false;
}
Copilot is powered by AI and may make mistakes. Always verify output.
@Sella-GH Sella-GH modified the milestones: 2.1.0, Backlog Nov 20, 2024
Signed-off-by: Sella-GH <147769367+Sella-GH@users.noreply.github.com>
Signed-off-by: Sella-GH <147769367+Sella-GH@users.noreply.github.com>
Signed-off-by: Sella-GH <147769367+Sella-GH@users.noreply.github.com>
@sonarqubecloud

sonarqubecloud Bot commented May 6, 2025

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
B Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-bot Stuff which is related to the bot area-core Stuff which is related to the core library enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants