mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-04-29 10:39:53 +03:00
Force maximum Cognitive Complexity via InspectCode (#60)
This PR uses a new feature of the InspectCode action: extensions. By adding the `Cognitive Complexity` extension, InspectCode can provide warnings and force the contributors to follow standards regarding complex methods. This functionality was previously provided by CodeFactor, but it is no longer used. Here's the full changelog of this PR: - Allowed Actions to run on push for any branch, not just `master`; - Added `Cognitive Complexity` plugin for InspectCode; - Significantly reduced complexity of KickCommandGroup, MuteCommandGroup and GuildUpdateService --------- Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
8c72dc663e
commit
27b8f15e3b
11 changed files with 476 additions and 421 deletions
|
@ -5,6 +5,7 @@ using Boyfriend.Services;
|
|||
using JetBrains.Annotations;
|
||||
using Remora.Commands.Attributes;
|
||||
using Remora.Commands.Groups;
|
||||
using Remora.Discord.API.Abstractions.Objects;
|
||||
using Remora.Discord.API.Abstractions.Rest;
|
||||
using Remora.Discord.Commands.Attributes;
|
||||
using Remora.Discord.Commands.Conditions;
|
||||
|
@ -47,7 +48,7 @@ public class AboutCommandGroup : CommandGroup {
|
|||
[RequireContext(ChannelContext.Guild)]
|
||||
[Description("Shows Boyfriend's developers")]
|
||||
[UsedImplicitly]
|
||||
public async Task<Result> SendAboutBotAsync() {
|
||||
public async Task<Result> ExecuteAboutAsync() {
|
||||
if (!_context.TryGetContextIDs(out var guildId, out _, out _))
|
||||
return Result.FromError(
|
||||
new ArgumentNullError(nameof(_context), "Unable to retrieve necessary IDs from command context"));
|
||||
|
@ -59,6 +60,10 @@ public class AboutCommandGroup : CommandGroup {
|
|||
var cfg = await _dataService.GetSettings(guildId.Value, CancellationToken);
|
||||
Messages.Culture = GuildSettings.Language.Get(cfg);
|
||||
|
||||
return await SendAboutBotAsync(currentUser, CancellationToken);
|
||||
}
|
||||
|
||||
private async Task<Result> SendAboutBotAsync(IUser currentUser, CancellationToken ct = default) {
|
||||
var builder = new StringBuilder().AppendLine(Markdown.Bold(Messages.AboutTitleDevelopers));
|
||||
foreach (var dev in Developers)
|
||||
builder.AppendLine($"@{dev} — {$"AboutDeveloper@{dev}".Localized()}");
|
||||
|
@ -73,6 +78,6 @@ public class AboutCommandGroup : CommandGroup {
|
|||
.WithImageUrl("https://cdn.upload.systems/uploads/JFAaX5vr.png")
|
||||
.Build();
|
||||
|
||||
return await _feedbackService.SendContextualEmbedResultAsync(embed, CancellationToken);
|
||||
return await _feedbackService.SendContextualEmbedResultAsync(embed, ct);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue