Skip to content

Commit

Permalink
Merge pull request #26956 from smoogipoo/update-inspectcode
Browse files Browse the repository at this point in the history
Update inspectcode to 2023.3.3
  • Loading branch information
bdach authored Feb 2, 2024
2 parents 8c107b4 + 50f9c61 commit ef2e230
Show file tree
Hide file tree
Showing 40 changed files with 83 additions and 73 deletions.
4 changes: 2 additions & 2 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"isRoot": true,
"tools": {
"jetbrains.resharper.globaltools": {
"version": "2022.2.3",
"version": "2023.3.3",
"commands": [
"jb"
]
},
"nvika": {
"version": "2.2.0",
"version": "3.0.0",
"commands": [
"nvika"
]
Expand Down
4 changes: 1 addition & 3 deletions .globalconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
is_global = true

# .NET Code Style
# IDE styles reference: https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/

Expand Down Expand Up @@ -56,4 +54,4 @@ dotnet_diagnostic.RS0030.severity = error

# Temporarily disable analysing CanBeNull = true in NRT contexts due to mobile issues.
# See: https://github.com/ppy/osu/pull/19677
dotnet_diagnostic.OSUF001.severity = none
dotnet_diagnostic.OSUF001.severity = none
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ private void addContextMenuItemStep(string contextMenuText)
{
AddStep($"click context menu item \"{contextMenuText}\"", () =>
{
MenuItem item = visualiser.ContextMenuItems.FirstOrDefault(menuItem => menuItem.Text.Value == "Curve type")?.Items.FirstOrDefault(menuItem => menuItem.Text.Value == contextMenuText);
MenuItem item = visualiser.ContextMenuItems!.FirstOrDefault(menuItem => menuItem.Text.Value == "Curve type")?.Items.FirstOrDefault(menuItem => menuItem.Text.Value == contextMenuText);
item?.Action.Value?.Invoke();
});
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Osu.Tests/TestSceneFollowPoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private void addObjectsStep(Func<OsuHitObject[]> ctorFunc)
break;
}
hitObjectContainer.Add(drawableObject);
hitObjectContainer.Add(drawableObject!);
followPointRenderer.AddFollowPoints(objects[i]);
}
});
Expand Down
2 changes: 2 additions & 0 deletions osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
Expand Down Expand Up @@ -173,6 +174,7 @@ public Drawable GetDrawableComponent(ISkinComponentLookup lookup)

public IEnumerable<ISkin> AllSources => new[] { this };

[CanBeNull]
public event Action SourceChanged;

private bool enabled = true;
Expand Down
3 changes: 1 addition & 2 deletions osu.Game.Rulesets.Taiko/UI/DrumTouchInputArea.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,9 @@ private void handleDown(object source, Vector2 position)
TaikoAction taikoAction = getTaikoActionFromPosition(position);

// Not too sure how this can happen, but let's avoid throwing.
if (trackedActions.ContainsKey(source))
if (!trackedActions.TryAdd(source, taikoAction))
return;

trackedActions.Add(source, taikoAction);
keyBindingContainer.TriggerPressed(taikoAction);
}

Expand Down
6 changes: 4 additions & 2 deletions osu.Game.Tests/Beatmaps/WorkingBeatmapTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Moq;
using NUnit.Framework;
using osu.Game.Beatmaps;
Expand Down Expand Up @@ -98,9 +99,10 @@ public TestConverter(IBeatmap beatmap, ManualResetEventSlim resetEvent)
Beatmap = beatmap;
}

#pragma warning disable CS0067
[CanBeNull]
public event Action<HitObject, IEnumerable<HitObject>> ObjectConverted;

protected virtual void OnObjectConverted(HitObject arg1, IEnumerable<HitObject> arg2) => ObjectConverted?.Invoke(arg1, arg2);
#pragma warning restore CS0067

public IBeatmap Beatmap { get; }

Expand Down
6 changes: 3 additions & 3 deletions osu.Game.Tests/Database/RulesetStoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void TestRulesetThrowingOnMethods()
Assert.That(realm.Run(r => r.Find<RulesetInfo>(rulesetShortName)!.Available), Is.True);
// Availability is updated on construction of a RealmRulesetStore
var _ = new RealmRulesetStore(realm, storage);
_ = new RealmRulesetStore(realm, storage);
Assert.That(realm.Run(r => r.Find<RulesetInfo>(rulesetShortName)!.Available), Is.False);
});
Expand All @@ -104,13 +104,13 @@ public void TestOutdatedRulesetNotAvailable()
Assert.That(realm.Run(r => r.Find<RulesetInfo>(rulesetShortName)!.Available), Is.True);
// Availability is updated on construction of a RealmRulesetStore
var _ = new RealmRulesetStore(realm, storage);
_ = new RealmRulesetStore(realm, storage);
Assert.That(realm.Run(r => r.Find<RulesetInfo>(rulesetShortName)!.Available), Is.False);
// Simulate the ruleset getting updated
LoadTestRuleset.Version = Ruleset.CURRENT_RULESET_API_VERSION;
var __ = new RealmRulesetStore(realm, storage);
_ = new RealmRulesetStore(realm, storage);
Assert.That(realm.Run(r => r.Find<RulesetInfo>(rulesetShortName)!.Available), Is.True);
});
Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Tests/Gameplay/TestSceneStoryboardSamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ public TestCustomSkinWorkingBeatmap(RulesetInfo ruleset, IStorageResourceProvide

public IRenderer Renderer => host.Renderer;
public AudioManager AudioManager => Audio;
public IResourceStore<byte[]> Files => null;
public IResourceStore<byte[]> Files => null!;
public new IResourceStore<byte[]> Resources => base.Resources;
public RealmAccess RealmAccess => null;
public RealmAccess RealmAccess => null!;
public IResourceStore<TextureUpload> CreateTextureLoaderStore(IResourceStore<byte[]> underlyingStore) => null;

#endregion
Expand Down
12 changes: 6 additions & 6 deletions osu.Game.Tests/Rulesets/TestSceneBrokenRulesetHandling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ private class TestRulesetWithNullMods : Ruleset

public override IEnumerable<Mod> GetModsFor(ModType type) => new Mod[] { null };

public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => null;
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => null;
public override DifficultyCalculator CreateDifficultyCalculator(IWorkingBeatmap beatmap) => null;
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => null!;
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => null!;
public override DifficultyCalculator CreateDifficultyCalculator(IWorkingBeatmap beatmap) => null!;
}

private class TestAPIIncompatibleRuleset : Ruleset
Expand All @@ -69,9 +69,9 @@ private class TestAPIIncompatibleRuleset : Ruleset
// simulate API incompatibility by throwing similar exceptions.
public override IEnumerable<Mod> GetModsFor(ModType type) => throw new MissingMethodException();

public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => null;
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => null;
public override DifficultyCalculator CreateDifficultyCalculator(IWorkingBeatmap beatmap) => null;
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => null!;
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => null!;
public override DifficultyCalculator CreateDifficultyCalculator(IWorkingBeatmap beatmap) => null!;
}
}
}
4 changes: 2 additions & 2 deletions osu.Game.Tests/Visual/Editing/TestSceneEditorTestGameplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void TestCancelGameplayTestWithUnsavedChanges()

AddStep("dismiss prompt", () =>
{
var button = DialogOverlay.CurrentDialog.Buttons.Last();
var button = DialogOverlay.CurrentDialog!.Buttons.Last();
InputManager.MoveMouseTo(button);
InputManager.Click(MouseButton.Left);
});
Expand All @@ -167,7 +167,7 @@ public void TestSaveChangesBeforeGameplayTest()
});
AddUntilStep("save prompt shown", () => DialogOverlay.CurrentDialog is SaveRequiredPopupDialog);

AddStep("save changes", () => DialogOverlay.CurrentDialog.PerformOkAction());
AddStep("save changes", () => DialogOverlay.CurrentDialog!.PerformOkAction());

EditorPlayer editorPlayer = null;
AddUntilStep("player pushed", () => (editorPlayer = Stack.CurrentScreen as EditorPlayer) != null);
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Tests/Visual/Gameplay/TestSceneReplayRecorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void TestLimitedFrameRateWithImportantFrames()
protected override void Update()
{
base.Update();
playbackManager?.ReplayInputHandler.SetFrameFromTime(Time.Current - 100);
playbackManager?.ReplayInputHandler?.SetFrameFromTime(Time.Current - 100);
}

[TearDownSteps]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ private void onNewFrames(int userId, FrameDataBundle frames)
foreach (var legacyFrame in frames.Frames)
{
var frame = new TestReplayFrame();
frame.FromLegacy(legacyFrame, null);
frame.FromLegacy(legacyFrame, null!);
playbackReplay.Frames.Add(frame);
}

Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Tests/Visual/Menus/TestSceneToolbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public virtual void Hide()
{
}

public virtual IBindable<int> UnreadCount => null;
public virtual IBindable<int> UnreadCount { get; } = new Bindable<int>();

public IEnumerable<Notification> AllNotifications => Enumerable.Empty<Notification>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void TestBasicListChanges()
.SkipWhile(r => r.Room.Category.Value == RoomCategory.Spotlight)
.All(r => r.Room.Category.Value == RoomCategory.Normal));

AddStep("remove first room", () => RoomManager.RemoveRoom(RoomManager.Rooms.FirstOrDefault(r => r.RoomID.Value == 0)));
AddStep("remove first room", () => RoomManager.RemoveRoom(RoomManager.Rooms.First(r => r.RoomID.Value == 0)));
AddAssert("has 4 rooms", () => container.Rooms.Count == 4);
AddAssert("first room removed", () => container.Rooms.All(r => r.Room.RoomID.Value != 0));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public event Action RoomsUpdated

public IBindable<bool> InitialRoomsReceived { get; } = new Bindable<bool>(true);

public IBindableList<Room> Rooms => null;
public IBindableList<Room> Rooms => null!;

public void AddOrUpdateRoom(Room room) => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ private void load(GameHost host, AudioManager audio)
[SetUpSteps]
public void SetupSteps()
{
AddStep("set room", () => SelectedRoom.Value = new Room());
AddStep("set room", () => SelectedRoom!.Value = new Room());

importBeatmap();

AddStep("load match", () => LoadScreen(match = new TestPlaylistsRoomSubScreen(SelectedRoom.Value)));
AddStep("load match", () => LoadScreen(match = new TestPlaylistsRoomSubScreen(SelectedRoom!.Value)));
AddUntilStep("wait for load", () => match.IsCurrentScreen());
}

Expand Down Expand Up @@ -115,7 +115,7 @@ public void TestPlaylistItemSelectedOnCreate()
});
});

AddAssert("first playlist item selected", () => match.SelectedItem.Value == SelectedRoom.Value.Playlist[0]);
AddAssert("first playlist item selected", () => match.SelectedItem.Value == SelectedRoom!.Value.Playlist[0]);
}

[Test]
Expand Down Expand Up @@ -201,7 +201,7 @@ public void TestBeatmapUpdatedOnReImport()

private void setupAndCreateRoom(Action<Room> room)
{
AddStep("setup room", () => room(SelectedRoom.Value));
AddStep("setup room", () => room(SelectedRoom!.Value));

AddStep("click create button", () =>
{
Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Tests/Visual/Ranking/TestSceneResultsScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ protected override void LoadComplete()

private class RulesetWithNoPerformanceCalculator : OsuRuleset
{
public override PerformanceCalculator CreatePerformanceCalculator() => null;
public override PerformanceCalculator CreatePerformanceCalculator() => null!;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public virtual void Hide()
{
}

public virtual IBindable<int> UnreadCount => null;
public virtual IBindable<int> UnreadCount { get; } = new Bindable<int>();

public IEnumerable<Notification> AllNotifications => Enumerable.Empty<Notification>();
}
Expand Down
3 changes: 1 addition & 2 deletions osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -567,10 +567,9 @@ private void flushPendingPoints()
for (int i = pendingControlPoints.Count - 1; i >= 0; i--)
{
var type = pendingControlPoints[i].GetType();
if (pendingControlPointTypes.Contains(type))
if (!pendingControlPointTypes.Add(type))
continue;

pendingControlPointTypes.Add(type);
beatmap.ControlPointInfo.Add(pendingControlPointsTime, pendingControlPoints[i]);
}

Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Beatmaps/WorkingBeatmapCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public virtual WorkingBeatmap GetWorkingBeatmap([CanBeNull] BeatmapInfo beatmapI
ITrackStore IBeatmapResourceProvider.Tracks => trackStore;
IRenderer IStorageResourceProvider.Renderer => host?.Renderer ?? new DummyRenderer();
AudioManager IStorageResourceProvider.AudioManager => audioManager;
RealmAccess IStorageResourceProvider.RealmAccess => null;
RealmAccess IStorageResourceProvider.RealmAccess => null!;
IResourceStore<byte[]> IStorageResourceProvider.Files => files;
IResourceStore<byte[]> IStorageResourceProvider.Resources => resources;
IResourceStore<TextureUpload> IStorageResourceProvider.CreateTextureLoaderStore(IResourceStore<byte[]> underlyingStore) => host?.CreateTextureLoaderStore(underlyingStore);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ public void Select(T item)

public override void Add(T drawable)
{
base.Add(drawable);

Debug.Assert(drawable != null);

base.Add(drawable);

drawable.StateChanged += state => selectionChanged(drawable, state);
}

Expand Down
2 changes: 2 additions & 0 deletions osu.Game/Graphics/UserInterface/BreadcrumbControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Graphics.Sprites;

namespace osu.Game.Graphics.UserInterface
Expand Down Expand Up @@ -48,6 +49,7 @@ public partial class BreadcrumbTabItem : OsuTabItem, IStateful<Visibility>
{
protected virtual float ChevronSize => 10;

[CanBeNull]
public event Action<Visibility> StateChanged;

public readonly SpriteIcon Chevron;
Expand Down
2 changes: 1 addition & 1 deletion osu.Game/IO/IStorageResourceProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ public interface IStorageResourceProvider
/// </summary>
/// <param name="underlyingStore">The underlying provider of texture data (in arbitrary image formats).</param>
/// <returns>A texture loader store.</returns>
IResourceStore<TextureUpload> CreateTextureLoaderStore(IResourceStore<byte[]> underlyingStore);
IResourceStore<TextureUpload>? CreateTextureLoaderStore(IResourceStore<byte[]> underlyingStore);
}
}
3 changes: 1 addition & 2 deletions osu.Game/Online/Spectator/SpectatorClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,12 @@ public virtual void WatchUser(int userId)
{
Debug.Assert(ThreadSafety.IsUpdateThread);

if (watchedUsersRefCounts.ContainsKey(userId))
if (!watchedUsersRefCounts.TryAdd(userId, 1))
{
watchedUsersRefCounts[userId]++;
return;
}

watchedUsersRefCounts.Add(userId, 1);
WatchUserInternal(userId);
}

Expand Down
2 changes: 1 addition & 1 deletion osu.Game/Overlays/Comments/VotePill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public partial class VotePill : LoadingButton, IHasAccentColour

public Color4 AccentColour { get; set; }

protected override IEnumerable<Drawable> EffectTargets => null;
protected override IEnumerable<Drawable> EffectTargets => Enumerable.Empty<Drawable>();

[Resolved]
private IAPIProvider api { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions osu.Game/Overlays/MedalSplash/DrawableMedal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#nullable disable

using System;
using JetBrains.Annotations;
using osu.Framework;
using osuTK;
using osu.Framework.Allocation;
Expand All @@ -24,6 +25,7 @@ public partial class DrawableMedal : Container, IStateful<DisplayState>
private const float scale_when_unlocked = 0.76f;
private const float scale_when_full = 0.6f;

[CanBeNull]
public event Action<DisplayState> StateChanged;

private readonly Medal medal;
Expand Down
2 changes: 2 additions & 0 deletions osu.Game/Overlays/Volume/VolumeMeter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

using System;
using System.Globalization;
using JetBrains.Annotations;
using osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
Expand Down Expand Up @@ -48,6 +49,7 @@ public partial class VolumeMeter : Container, IStateful<SelectionState>
private Sample notchSample;
private double sampleLastPlaybackTime;

[CanBeNull]
public event Action<SelectionState> StateChanged;

private SelectionState state;
Expand Down
Loading

0 comments on commit ef2e230

Please sign in to comment.