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

@@ -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;
}
}