Updated editorconfig to (mostly?) require braces around if/else statements, and applied the new formatting rules

This commit is contained in:
Kwoth
2022-02-02 01:44:45 +01:00
parent b22cd5a81e
commit ffa2c3f119
202 changed files with 2108 additions and 920 deletions

View File

@@ -239,7 +239,8 @@ public sealed partial class Music : NadekoModule<IMusicService>
return;
var success = await _service.PlayAsync(ctx.Guild.Id, ((IGuildUser)ctx.User).VoiceChannel.Id);
if (!success) await ReplyErrorLocalizedAsync(strs.no_player);
if (!success)
await ReplyErrorLocalizedAsync(strs.no_player);
}
// list queue, relevant page
@@ -276,7 +277,8 @@ public sealed partial class Music : NadekoModule<IMusicService>
{
var desc = string.Empty;
var current = mp.GetCurrentTrack(out var currentIndex);
if (current is not null) desc = $"`🔊` {current.PrettyFullName()}\n\n" + desc;
if (current is not null)
desc = $"`🔊` {current.PrettyFullName()}\n\n" + desc;
var repeatType = mp.Repeat;
var add = string.Empty;

View File

@@ -139,7 +139,10 @@ public sealed partial class Music
{
playlist = new()
{
Name = name, Author = ctx.User.Username, AuthorId = ctx.User.Id, Songs = songs.ToList()
Name = name,
Author = ctx.User.Username,
AuthorId = ctx.User.Id,
Songs = songs.ToList()
};
uow.MusicPlaylists.Add(playlist);
await uow.SaveChangesAsync();
@@ -212,7 +215,8 @@ public sealed partial class Music
await mp.EnqueueManyAsync(mpl.Songs.Select(x => (x.Query, (MusicPlatform)x.ProviderType)),
ctx.User.ToString());
if (msg is not null) await msg.ModifyAsync(m => m.Content = GetText(strs.playlist_queue_complete));
if (msg is not null)
await msg.ModifyAsync(m => m.Content = GetText(strs.playlist_queue_complete));
}
finally
{

View File

@@ -133,7 +133,8 @@ public sealed class AyuVoiceStateService : INService
Task OnVoiceServerUpdated(SocketVoiceServer data)
{
if (data.Guild.Id == guildId) voiceServerUpdatedSource.TrySetResult(data);
if (data.Guild.Id == guildId)
voiceServerUpdatedSource.TrySetResult(data);
return Task.CompletedTask;
}
@@ -157,14 +158,10 @@ public sealed class AyuVoiceStateService : INService
// wait for both to end (max 1s) and check if either of them is a delay task
var results = await Task.WhenAll(maybeUpdateTask, maybeServerTask);
if (results[0] == delayTask || results[1] == delayTask)
{
// if either is delay, return null - connection unsuccessful
return null;
}
else
{
cts.Cancel();
}
// if both are succesful, that means we can safely get
// the values from completion sources

View File

@@ -63,7 +63,8 @@ public sealed class MusicService : IMusicService
private void RemoveMusicPlayer(ulong guildId)
{
_outputChannels.TryRemove(guildId, out _);
if (_players.TryRemove(guildId, out var mp)) DisposeMusicPlayer(mp);
if (_players.TryRemove(guildId, out var mp))
DisposeMusicPlayer(mp);
}
private Task ClientOnLeftGuild(SocketGuild guild)
@@ -139,7 +140,8 @@ public sealed class MusicService : IMusicService
var queue = new MusicQueue();
var resolver = _trackResolveProvider;
if (!_voiceStateService.TryGetProxy(guildId, out var proxy)) return null;
if (!_voiceStateService.TryGetProxy(guildId, out var proxy))
return null;
var settings = await GetSettingsInternalAsync(guildId);
@@ -226,7 +228,8 @@ public sealed class MusicService : IMusicService
// this has to be done because dragging bot to another vc isn't supported yet
public async Task<bool> PlayAsync(ulong guildId, ulong voiceChannelId)
{
if (!TryGetMusicPlayer(guildId, out var mp)) return false;
if (!TryGetMusicPlayer(guildId, out var mp))
return false;
if (mp.IsStopped)
if (!_voiceStateService.TryGetProxy(guildId, out var proxy)
@@ -254,7 +257,8 @@ public sealed class MusicService : IMusicService
try
{
IList<(string, string)> videos = await SearchYtLoaderVideosAsync(query);
if (videos.Count > 0) return videos;
if (videos.Count > 0)
return videos;
}
catch (Exception ex)
{

View File

@@ -54,7 +54,7 @@ public sealed class MusicPlayer : IMusicPlayer
_songBuffer = new PoopyBufferImmortalized(_vc.InputLength);
_thread = new(async() =>
_thread = new(async () =>
{
await PlayLoop();
});
@@ -282,7 +282,8 @@ public sealed class MusicPlayer : IMusicPlayer
var data = sb.Read(vc.InputLength, out var length);
// if nothing is read from the buffer, song is finished
if (data.Length == 0) return null;
if (data.Length == 0)
return null;
_adjustVolume(data, Volume);
return _proxy.SendPcmFrame(vc, data, length);
@@ -325,7 +326,8 @@ public sealed class MusicPlayer : IMusicPlayer
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void AdjustVolumeInt16(Span<byte> audioSamples, float volume)
{
if (Math.Abs(volume - 1f) < 0.0001f) return;
if (Math.Abs(volume - 1f) < 0.0001f)
return;
var samples = MemoryMarshal.Cast<byte, short>(audioSamples);
@@ -339,7 +341,8 @@ public sealed class MusicPlayer : IMusicPlayer
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void AdjustVolumeFloat32(Span<byte> audioSamples, float volume)
{
if (Math.Abs(volume - 1f) < 0.0001f) return;
if (Math.Abs(volume - 1f) < 0.0001f)
return;
var samples = MemoryMarshal.Cast<byte, float>(audioSamples);

View File

@@ -87,7 +87,8 @@ public sealed partial class MusicQueue : IMusicQueue
{
lock (_locker)
{
if (tracks.Count == 0) return Enqueue(trackInfo, queuer, out trackIndex);
if (tracks.Count == 0)
return Enqueue(trackInfo, queuer, out trackIndex);
var currentNode = tracks.First!;
int i;
@@ -165,7 +166,8 @@ public sealed partial class MusicQueue : IMusicQueue
{
var removedNode = tracks.First!;
int i;
for (i = 0; i < remoteAtIndex; i++) removedNode = removedNode.Next!;
for (i = 0; i < remoteAtIndex; i++)
removedNode = removedNode.Next!;
trackInfo = removedNode.Value;
tracks.Remove(removedNode);
@@ -303,7 +305,8 @@ public sealed partial class MusicQueue : IMusicQueue
if (remoteAt < 0 || remoteAt >= tracks.Count)
return false;
if (remoteAt == index) isCurrent = true;
if (remoteAt == index)
isCurrent = true;
RemoveAtInternal(remoteAt, out trackInfo);

View File

@@ -35,7 +35,8 @@ public sealed class VoiceProxy : IVoiceProxy
try
{
var gw = gateway;
if (gw is null || gw.Stopped || !gw.Started) return false;
if (gw is null || gw.Stopped || !gw.Started)
return false;
vc.SendPcmFrame(gw, data, 0, length);
return true;
@@ -51,7 +52,8 @@ public sealed class VoiceProxy : IVoiceProxy
var errorCount = 0;
do
{
if (State == VoiceProxyState.Stopped) break;
if (State == VoiceProxyState.Stopped)
break;
try
{

View File

@@ -43,7 +43,8 @@ public sealed class LocalTrackResolver : ILocalTrackResolver
.Where(x =>
{
if (!x.Attributes.HasFlag(FileAttributes.Hidden | FileAttributes.System)
&& _musicExtensions.Contains(x.Extension.ToUpperInvariant())) return true;
&& _musicExtensions.Contains(x.Extension.ToUpperInvariant()))
return true;
return false;
})
.ToList();

View File

@@ -27,14 +27,16 @@ public sealed class SoundcloudResolver : ISoundcloudResolver
using var http = _httpFactory.CreateClient();
var responseString = await http.GetStringAsync($"https://scapi.nadeko.bot/resolve?url={playlist}");
var scvids = JObject.Parse(responseString)["tracks"]?.ToObject<SoundCloudVideo[]>();
if (scvids is null) yield break;
if (scvids is null)
yield break;
foreach (var videosChunk in scvids.Where(x => x.Streamable is true).Chunk(5))
{
var cachableTracks = videosChunk.Select(VideoModelToCachedData).ToList();
await cachableTracks.Select(_trackCacher.CacheTrackDataAsync).WhenAll();
foreach (var info in cachableTracks.Select(CachableDataToTrackInfo)) yield return info;
foreach (var info in cachableTracks.Select(CachableDataToTrackInfo))
yield return info;
}
}