1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 15:17:27 +08:00

Fix various other inspections

This commit is contained in:
Dean Herbert 2023-10-17 17:48:51 +09:00
parent 5341a335a6
commit e081fa48a2
No known key found for this signature in database
19 changed files with 43 additions and 34 deletions

View File

@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
}); });
moveMouseToHitObject(1); moveMouseToHitObject(1);
AddAssert("merge option available", () => selectionHandler.ContextMenuItems.Any(o => o.Text.Value == "Merge selection")); AddAssert("merge option available", () => selectionHandler.ContextMenuItems?.Any(o => o.Text.Value == "Merge selection") == true);
mergeSelection(); mergeSelection();
@ -198,7 +198,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
}); });
moveMouseToHitObject(1); moveMouseToHitObject(1);
AddAssert("merge option not available", () => selectionHandler.ContextMenuItems.Length > 0 && selectionHandler.ContextMenuItems.All(o => o.Text.Value != "Merge selection")); AddAssert("merge option not available", () => selectionHandler.ContextMenuItems?.Length > 0 && selectionHandler.ContextMenuItems.All(o => o.Text.Value != "Merge selection"));
mergeSelection(); mergeSelection();
AddAssert("circles not merged", () => circle1 is not null && circle2 is not null AddAssert("circles not merged", () => circle1 is not null && circle2 is not null
&& EditorBeatmap.HitObjects.Contains(circle1) && EditorBeatmap.HitObjects.Contains(circle2)); && EditorBeatmap.HitObjects.Contains(circle1) && EditorBeatmap.HitObjects.Contains(circle2));
@ -222,7 +222,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
}); });
moveMouseToHitObject(1); moveMouseToHitObject(1);
AddAssert("merge option available", () => selectionHandler.ContextMenuItems.Any(o => o.Text.Value == "Merge selection")); AddAssert("merge option available", () => selectionHandler.ContextMenuItems?.Any(o => o.Text.Value == "Merge selection") == true);
mergeSelection(); mergeSelection();

View File

@ -241,7 +241,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
{ {
if (visualiser is null) return; if (visualiser is null) return;
MenuItem? item = visualiser.ContextMenuItems.FirstOrDefault(menuItem => menuItem.Text.Value == contextMenuText); MenuItem? item = visualiser.ContextMenuItems?.FirstOrDefault(menuItem => menuItem.Text.Value == contextMenuText);
item?.Action.Value?.Invoke(); item?.Action.Value?.Invoke();
}); });

View File

@ -182,7 +182,7 @@ namespace osu.Game.Tests.Visual.Editing
if (sameRuleset) if (sameRuleset)
{ {
AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog); AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog);
AddStep("confirm creation with no objects", () => DialogOverlay.CurrentDialog.PerformOkAction()); AddStep("confirm creation with no objects", () => DialogOverlay.CurrentDialog!.PerformOkAction());
} }
AddUntilStep("wait for created", () => AddUntilStep("wait for created", () =>
@ -269,7 +269,7 @@ namespace osu.Game.Tests.Visual.Editing
AddStep("create new difficulty", () => Editor.CreateNewDifficulty(new OsuRuleset().RulesetInfo)); AddStep("create new difficulty", () => Editor.CreateNewDifficulty(new OsuRuleset().RulesetInfo));
AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog); AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog);
AddStep("confirm creation as a copy", () => DialogOverlay.CurrentDialog.Buttons.ElementAt(1).TriggerClick()); AddStep("confirm creation as a copy", () => DialogOverlay.CurrentDialog!.Buttons.ElementAt(1).TriggerClick());
AddUntilStep("wait for created", () => AddUntilStep("wait for created", () =>
{ {
@ -342,7 +342,7 @@ namespace osu.Game.Tests.Visual.Editing
AddStep("create new difficulty", () => Editor.CreateNewDifficulty(new OsuRuleset().RulesetInfo)); AddStep("create new difficulty", () => Editor.CreateNewDifficulty(new OsuRuleset().RulesetInfo));
AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog); AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog);
AddStep("confirm creation as a copy", () => DialogOverlay.CurrentDialog.Buttons.ElementAt(1).TriggerClick()); AddStep("confirm creation as a copy", () => DialogOverlay.CurrentDialog!.Buttons.ElementAt(1).TriggerClick());
AddUntilStep("wait for created", () => AddUntilStep("wait for created", () =>
{ {
@ -380,7 +380,7 @@ namespace osu.Game.Tests.Visual.Editing
AddStep("try to create new difficulty", () => Editor.CreateNewDifficulty(new OsuRuleset().RulesetInfo)); AddStep("try to create new difficulty", () => Editor.CreateNewDifficulty(new OsuRuleset().RulesetInfo));
AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog); AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog);
AddStep("confirm creation with no objects", () => DialogOverlay.CurrentDialog.PerformOkAction()); AddStep("confirm creation with no objects", () => DialogOverlay.CurrentDialog!.PerformOkAction());
AddUntilStep("wait for created", () => AddUntilStep("wait for created", () =>
{ {
@ -415,7 +415,7 @@ namespace osu.Game.Tests.Visual.Editing
if (sameRuleset) if (sameRuleset)
{ {
AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog); AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is CreateNewDifficultyDialog);
AddStep("confirm creation with no objects", () => DialogOverlay.CurrentDialog.PerformOkAction()); AddStep("confirm creation with no objects", () => DialogOverlay.CurrentDialog!.PerformOkAction());
} }
AddUntilStep("wait for created", () => AddUntilStep("wait for created", () =>
@ -476,7 +476,7 @@ namespace osu.Game.Tests.Visual.Editing
AddStep("exit", () => Editor.Exit()); AddStep("exit", () => Editor.Exit());
AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is PromptForSaveDialog); AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog is PromptForSaveDialog);
AddStep("attempt to save", () => DialogOverlay.CurrentDialog.PerformOkAction()); AddStep("attempt to save", () => DialogOverlay.CurrentDialog!.PerformOkAction());
AddAssert("editor is still current", () => Editor.IsCurrentScreen()); AddAssert("editor is still current", () => Editor.IsCurrentScreen());
} }

View File

@ -15,7 +15,7 @@ namespace osu.Game.Tournament.Components
public new Bindable<DateTimeOffset>? Current public new Bindable<DateTimeOffset>? Current
{ {
get => current; get => current;
set => current.Current = value; set => current.Current = value!;
} }
public DateTextBox() public DateTextBox()

View File

@ -70,9 +70,9 @@ namespace osu.Game.Beatmaps
throw new NotImplementedException(); throw new NotImplementedException();
} }
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new DummyBeatmapConverter { Beatmap = beatmap }; public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new DummyBeatmapConverter(beatmap);
public override DifficultyCalculator CreateDifficultyCalculator(IWorkingBeatmap beatmap) => null; public override DifficultyCalculator CreateDifficultyCalculator(IWorkingBeatmap beatmap) => throw new NotImplementedException();
public override string Description => "dummy"; public override string Description => "dummy";
@ -80,9 +80,15 @@ namespace osu.Game.Beatmaps
private class DummyBeatmapConverter : IBeatmapConverter private class DummyBeatmapConverter : IBeatmapConverter
{ {
public event Action<HitObject, IEnumerable<HitObject>> ObjectConverted; public IBeatmap Beatmap { get; }
public IBeatmap Beatmap { get; set; } public DummyBeatmapConverter(IBeatmap beatmap)
{
Beatmap = beatmap;
}
[CanBeNull]
public event Action<HitObject, IEnumerable<HitObject>> ObjectConverted;
public bool CanConvert() => true; public bool CanConvert() => true;

View File

@ -86,7 +86,7 @@ namespace osu.Game.Beatmaps
public event Action<WorkingBeatmap> OnInvalidated; public event Action<WorkingBeatmap> OnInvalidated;
public virtual WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo) public virtual WorkingBeatmap GetWorkingBeatmap([CanBeNull] BeatmapInfo beatmapInfo)
{ {
if (beatmapInfo?.BeatmapSet == null) if (beatmapInfo?.BeatmapSet == null)
return DefaultBeatmap; return DefaultBeatmap;

View File

@ -22,7 +22,7 @@ namespace osu.Game.Graphics.Backgrounds
Sprite.Texture = skin.GetTexture("menu-background") ?? Sprite.Texture; Sprite.Texture = skin.GetTexture("menu-background") ?? Sprite.Texture;
} }
public override bool Equals(Background other) public override bool Equals(Background? other)
{ {
if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true; if (ReferenceEquals(this, other)) return true;

View File

@ -119,11 +119,11 @@ namespace osu.Game.Graphics.Containers
headerBackgroundContainer.Clear(); headerBackgroundContainer.Clear();
headerBackground = value; headerBackground = value;
if (value == null) return; if (headerBackground != null)
{
headerBackgroundContainer.Add(headerBackground); headerBackgroundContainer.Add(headerBackground);
lastKnownScroll = null;
lastKnownScroll = null; }
} }
} }

View File

@ -62,7 +62,7 @@ namespace osu.Game.Graphics.UserInterface
if (!PlaySamplesOnAdjust) if (!PlaySamplesOnAdjust)
return; return;
if (Clock == null || Clock.CurrentTime - lastSampleTime <= 30) if (Clock.CurrentTime - lastSampleTime <= 30)
return; return;
if (value.Equals(lastSampleValue)) if (value.Equals(lastSampleValue))

View File

@ -13,7 +13,7 @@ namespace osu.Game.IO
public bool IsManaged => ID > 0; public bool IsManaged => ID > 0;
public string Hash { get; set; } public string Hash { get; set; } = string.Empty;
public int ReferenceCount { get; set; } public int ReferenceCount { get; set; }
} }

View File

@ -29,7 +29,7 @@ namespace osu.Game.Online.API.Requests.Responses
public DateTimeOffset JoinDate; public DateTimeOffset JoinDate;
[JsonProperty(@"username")] [JsonProperty(@"username")]
public string Username { get; set; } public string Username { get; set; } = string.Empty;
[JsonProperty(@"previous_usernames")] [JsonProperty(@"previous_usernames")]
public string[] PreviousUsernames; public string[] PreviousUsernames;

View File

@ -22,6 +22,6 @@ namespace osu.Game.Online.Placeholders
AddText(this.message = message); AddText(this.message = message);
} }
public override bool Equals(Placeholder other) => (other as MessagePlaceholder)?.message == message; public override bool Equals(Placeholder? other) => (other as MessagePlaceholder)?.message == message;
} }
} }

View File

@ -17,7 +17,7 @@ namespace osu.Game.Overlays
public abstract partial class FullscreenOverlay<T> : WaveOverlayContainer, INamedOverlayComponent public abstract partial class FullscreenOverlay<T> : WaveOverlayContainer, INamedOverlayComponent
where T : OverlayHeader where T : OverlayHeader
{ {
public virtual string IconTexture => Header.Title.IconTexture ?? string.Empty; public virtual string IconTexture => Header.Title.IconTexture;
public virtual LocalisableString Title => Header.Title.Title; public virtual LocalisableString Title => Header.Title.Title;
public virtual LocalisableString Description => Header.Title.Description; public virtual LocalisableString Description => Header.Title.Description;

View File

@ -23,11 +23,12 @@ namespace osu.Game.Rulesets.Objects.Legacy
/// <summary> /// <summary>
/// <see cref="ConvertSlider"/>s don't need a curve since they're converted to ruleset-specific hitobjects. /// <see cref="ConvertSlider"/>s don't need a curve since they're converted to ruleset-specific hitobjects.
/// </summary> /// </summary>
public SliderPath Path { get; set; } public SliderPath Path { get; set; } = null!;
public double Distance => Path.Distance; public double Distance => Path.Distance;
public IList<IList<HitSampleInfo>> NodeSamples { get; set; } public IList<IList<HitSampleInfo>> NodeSamples { get; set; } = null!;
public int RepeatCount { get; set; } public int RepeatCount { get; set; }
[JsonIgnore] [JsonIgnore]

View File

@ -186,7 +186,7 @@ namespace osu.Game.Rulesets.UI
this.fallback = fallback; this.fallback = fallback;
} }
public override Texture Get(string name, WrapMode wrapModeS, WrapMode wrapModeT) public override Texture? Get(string name, WrapMode wrapModeS, WrapMode wrapModeT)
=> primary.Get(name, wrapModeS, wrapModeT) ?? fallback.Get(name, wrapModeS, wrapModeT); => primary.Get(name, wrapModeS, wrapModeT) ?? fallback.Get(name, wrapModeS, wrapModeT);
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)

View File

@ -15,7 +15,7 @@ namespace osu.Game.Screens.Backgrounds
AddInternal(new Background(textureName)); AddInternal(new Background(textureName));
} }
public override bool Equals(BackgroundScreen other) public override bool Equals(BackgroundScreen? other)
{ {
if (other is BackgroundScreenCustom backgroundScreenCustom) if (other is BackgroundScreenCustom backgroundScreenCustom)
return base.Equals(other) && textureName == backgroundScreenCustom.textureName; return base.Equals(other) && textureName == backgroundScreenCustom.textureName;

View File

@ -89,9 +89,9 @@ namespace osu.Game.Screens
public virtual bool? AllowGlobalTrackControl => null; public virtual bool? AllowGlobalTrackControl => null;
public Bindable<WorkingBeatmap> Beatmap { get; private set; } public Bindable<WorkingBeatmap> Beatmap { get; private set; } = null!;
public Bindable<RulesetInfo> Ruleset { get; private set; } public Bindable<RulesetInfo> Ruleset { get; private set; } = null!;
public Bindable<IReadOnlyList<Mod>> Mods { get; private set; } public Bindable<IReadOnlyList<Mod>> Mods { get; private set; }

View File

@ -4,6 +4,7 @@
#nullable disable #nullable disable
using System; using System;
using JetBrains.Annotations;
using osu.Framework; using osu.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
@ -211,6 +212,7 @@ namespace osu.Game.Screens.Play
public partial class FadeContainer : Container, IStateful<Visibility> public partial class FadeContainer : Container, IStateful<Visibility>
{ {
[CanBeNull]
public event Action<Visibility> StateChanged; public event Action<Visibility> StateChanged;
private Visibility state; private Visibility state;

View File

@ -647,7 +647,7 @@ namespace osu.Game.Screens.Select
beginLooping(); beginLooping();
if (Beatmap != null && !Beatmap.Value.BeatmapSetInfo.DeletePending) if (!Beatmap.Value.BeatmapSetInfo.DeletePending)
{ {
updateCarouselSelection(); updateCarouselSelection();