diff --git a/Bot/.editorconfig b/Bot/.editorconfig index 07b7ab7..c20e04a 100644 --- a/Bot/.editorconfig +++ b/Bot/.editorconfig @@ -30,6 +30,9 @@ dotnet_style_prefer_conditional_expression_over_assignment = true:silent # C# files [*.cs] +# ReSharper +resharper_function_never_returns_highlighting = none + # New line preferences csharp_new_line_before_open_brace = all csharp_new_line_before_else = true diff --git a/Bot/Coc.cs b/Bot/Coc.cs index 50f0f12..3cd85d6 100644 --- a/Bot/Coc.cs +++ b/Bot/Coc.cs @@ -9,11 +9,11 @@ internal static class Coc { private sealed class ClanUtil { - internal Clan _clan; + internal readonly Clan _clan; internal readonly Dictionary _members = []; internal readonly Dictionary _existingMembers = []; internal readonly Dictionary _joiningMembers = []; - internal Dictionary _leavingMembers; + internal readonly Dictionary _leavingMembers; private ClanUtil(Clan clan, Dictionary leavingMembers) { @@ -82,37 +82,41 @@ internal readonly struct DonationTuple(int donated, int received) private static void CheckMembersJoined(ClanUtil clan) { - if (clan._joiningMembers.Count > 0) + if (clan._joiningMembers.Count == 0) { - string[] members = [.. clan._joiningMembers.Keys]; - bool isSuccess = Db.AddMembers(members); - string membersMsg = string.Join(", ", members); - if (isSuccess) - { - Console.WriteLine($"{membersMsg} joined"); - } - else - { - Console.Error.WriteLine($"ERROR MembersJoined {membersMsg}"); - } + return; + } + + string[] members = [.. clan._joiningMembers.Keys]; + bool isSuccess = Db.AddMembers(members); + string membersMsg = string.Join(", ", members); + if (isSuccess) + { + Console.WriteLine($"{membersMsg} joined"); + } + else + { + Console.Error.WriteLine($"ERROR MembersJoined {membersMsg}"); } } private static void CheckMembersLeft(ClanUtil clan) { - if (clan._leavingMembers.Count > 0) + if (clan._leavingMembers.Count == 0) { - string[] members = [.. clan._leavingMembers.Keys]; - bool isSuccess = Db.RemoveMembers(members); - string membersMsg = string.Join(", ", members); - if (isSuccess) - { - Console.WriteLine($"{membersMsg} left"); - } - else - { - Console.Error.WriteLine($"ERROR MembersLeft {membersMsg}"); - } + return; + } + + string[] members = [.. clan._leavingMembers.Keys]; + bool isSuccess = Db.RemoveMembers(members); + string membersMsg = string.Join(", ", members); + if (isSuccess) + { + Console.WriteLine($"{membersMsg} left"); + } + else + { + Console.Error.WriteLine($"ERROR MembersLeft {membersMsg}"); } } diff --git a/Bot/Dc/Attr/RequireAdmin.cs b/Bot/Dc/Attr/RequireAdmin.cs index 42cf983..6bc0423 100644 --- a/Bot/Dc/Attr/RequireAdmin.cs +++ b/Bot/Dc/Attr/RequireAdmin.cs @@ -4,7 +4,7 @@ namespace Hyperstellar.Dc.Attr; -internal class RequireAdmin : PreconditionAttribute +internal sealed class RequireAdmin : PreconditionAttribute { public override Task CheckRequirementsAsync(IInteractionContext context, ICommandInfo commandInfo, IServiceProvider services) => Db.s_admins.Contains(context.User.Id) ? Task.FromResult(PreconditionResult.FromSuccess()) diff --git a/Bot/Dc/MemberConverter.cs b/Bot/Dc/MemberConverter.cs index 1535763..e0325cc 100644 --- a/Bot/Dc/MemberConverter.cs +++ b/Bot/Dc/MemberConverter.cs @@ -1,11 +1,10 @@ -using ClashOfClans.Models; -using Discord; +using Discord; using Discord.Interactions; using Hyperstellar.Sql; namespace Hyperstellar.Dc; -internal class MemberConverter : TypeConverter +internal sealed class MemberConverter : TypeConverter { public override bool CanConvertTo(System.Type type) => typeof(Member).IsAssignableFrom(type); public override ApplicationCommandOptionType GetDiscordType() => ApplicationCommandOptionType.String; diff --git a/Bot/Secrets.cs b/Bot/Secrets.cs index a3122a4..ee247c3 100644 --- a/Bot/Secrets.cs +++ b/Bot/Secrets.cs @@ -1,5 +1,7 @@ using Newtonsoft.Json; +namespace Hyperstellar; + internal sealed class Secrets { internal static readonly string s_discord; // Your Discord bot token diff --git a/Bot/Sql/Donation.cs b/Bot/Sql/Donation.cs index 6eced96..7223a4b 100644 --- a/Bot/Sql/Donation.cs +++ b/Bot/Sql/Donation.cs @@ -2,7 +2,7 @@ namespace Hyperstellar.Sql; -internal class Donation(string id) +internal sealed class Donation(string id) { [PrimaryKey, NotNull] public string Id { get; set; } = id;