Skip to content

Commit

Permalink
Cleanup code warnings in Rider and SonarLint
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisyarbrough committed Feb 11, 2024
1 parent f1dfc7c commit 8a8c013
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 9 deletions.
2 changes: 1 addition & 1 deletion SharpShuffleBag.Tests/FixedSequenceSourceTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace SharpShuffleBag.Tests;

public class FixedSequenceSourceTests
public sealed class FixedSequenceSourceTests
{
[Fact]
public void SmokeTest()
Expand Down
4 changes: 2 additions & 2 deletions SharpShuffleBag.Unity/Assets/Editor/SampleDevelopment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public static void CopySamplesToPackage()
{
foreach (DirectoryInfo source in versionDirectory.EnumerateDirectories())
{
// Packages/com.xarbrough.sharp-shuffle-bag-unity/Samples~/Example1
// Packages/com.xarbrough.sharp-shuffle-bag-unity/Samples~/Example2
// Packages/com.chrisyarbrough.sharpshufflebag/Samples~/Example1
// Packages/com.chrisyarbrough.sharpshufflebag/Samples~/Example2
string dest = "Packages/com.chrisyarbrough.sharpshufflebag/Samples~/" + source.Name;
CopyDirectory(source, dest);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ReSharper disable UnusedMember.Global

namespace SharpShuffleBag
{
using System;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ReSharper disable UnusedMember.Global

namespace SharpShuffleBag
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace SharpShuffleBag
// ReSharper disable UnusedMember.Global

namespace SharpShuffleBag
{
using System;
using System.Collections;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ReSharper disable UnusedMember.Global

namespace SharpShuffleBag
{
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ and therefore avoids the larger performance spike of reshuffling/refilling the b
- Efficient implementation: The underlying collection is not resized, instead,
an index is used to perform the random selection.
- Set a custom `RandomSource` for fine-grained control (e.g. to make the bag deterministic or set a seed).
- `Shuffle.FisherYates(IList<T> list)` utility method to shuffle a list in-place.
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,23 @@ internal sealed class RandomSpawner : MonoBehaviour
[SerializeField]
private float spawnInterval = 0.5f;

private ShuffleBag<FadingTextMesh> shuffleBag;

private IEnumerator Start()
{
Application.targetFrameRate = 60;

shuffleBag = new ShuffleBag<FadingTextMesh>(SpawnTexts());
ShuffleBag<FadingTextMesh> shuffleBag = new(SpawnTexts());

int i = 0;
while (Application.isPlaying)
{
yield return new WaitForSeconds(spawnInterval);

FadingTextMesh text = shuffleBag.Next();
text.StartFade();

if (i++ % shuffleBag.Size == 0)
Debug.Log("----");
Debug.Log(text.Text);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal static class DefaultRandomSourceInitializer
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)]
private static void Initialize()
{
if (IRandomRangeSource.Default.GetType() != typeof(UnityRandomSource))
if (IRandomRangeSource.Default is UnityRandomSource)
{
IRandomRangeSource.Default = new UnityRandomSource();
}
Expand Down
2 changes: 2 additions & 0 deletions SharpShuffleBag/IRandomRangeSource.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ReSharper disable UnusedMember.Global

namespace SharpShuffleBag
{
using System;
Expand Down
2 changes: 2 additions & 0 deletions SharpShuffleBag/IRandomValueSource.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ReSharper disable UnusedMember.Global

namespace SharpShuffleBag
{
/// <summary>
Expand Down
4 changes: 3 additions & 1 deletion SharpShuffleBag/ShuffleBag.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace SharpShuffleBag
// ReSharper disable UnusedMember.Global

namespace SharpShuffleBag
{
using System;
using System.Collections;
Expand Down
2 changes: 2 additions & 0 deletions SharpShuffleBag/ShuffleBagInt.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ReSharper disable UnusedMember.Global

namespace SharpShuffleBag
{
using System.Collections.Generic;
Expand Down

0 comments on commit 8a8c013

Please sign in to comment.