1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 15:27:30 +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);
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();
@ -198,7 +198,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
});
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();
AddAssert("circles not merged", () => circle1 is not null && circle2 is not null
&& EditorBeatmap.HitObjects.Contains(circle1) && EditorBeatmap.HitObjects.Contains(circle2));
@ -222,7 +222,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
});
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();

View File

@ -241,7 +241,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
{
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();
});

View File

@ -182,7 +182,7 @@ namespace osu.Game.Tests.Visual.Editing
if (sameRuleset)
{
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", () =>
@ -269,7 +269,7 @@ namespace osu.Game.Tests.Visual.Editing
AddStep("create new difficulty", () => Editor.CreateNewDifficulty(new OsuRuleset().RulesetInfo));
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", () =>
{
@ -342,7 +342,7 @@ namespace osu.Game.Tests.Visual.Editing
AddStep("create new difficulty", () => Editor.CreateNewDifficulty(new OsuRuleset().RulesetInfo));
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", () =>
{
@ -380,7 +380,7 @@ namespace osu.Game.Tests.Visual.Editing
AddStep("try to create new difficulty", () => Editor.CreateNewDifficulty(new OsuRuleset().RulesetInfo));
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", () =>
{
@ -415,7 +415,7 @@ namespace osu.Game.Tests.Visual.Editing
if (sameRuleset)
{
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", () =>
@ -476,7 +476,7 @@ namespace osu.Game.Tests.Visual.Editing
AddStep("exit", () => Editor.Exit());
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());
}

View File

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

View File

@ -70,9 +70,9 @@ namespace osu.Game.Beatmaps
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";
@ -80,9 +80,15 @@ namespace osu.Game.Beatmaps
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;

View File

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

View File

@ -22,7 +22,7 @@ namespace osu.Game.Graphics.Backgrounds
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(this, other)) return true;

View File

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

View File

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

View File

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

View File

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

View File

@ -22,6 +22,6 @@ namespace osu.Game.Online.Placeholders
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
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 Description => Header.Title.Description;

View File

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

View File

@ -186,7 +186,7 @@ namespace osu.Game.Rulesets.UI
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);
protected override void Dispose(bool disposing)

View File

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

View File

@ -89,9 +89,9 @@ namespace osu.Game.Screens
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; }

View File

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

View File

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