- More code cleanup and codestyle updates

- Fixed some possible nullref exceptions
- Methods signatures now have up to 3 parameters before breakaing down each parameter in a separate line
- Method invocations have the same rule, except the first parameter will be in the same line as the invocation to prevent some ugliness when passing lambas as arguments
- Applied many more codestyles
- Extensions folder fully reformatted
This commit is contained in:
Kwoth
2021-12-26 17:28:39 +01:00
parent b85ba177cd
commit d5fd6aae8e
217 changed files with 1017 additions and 1494 deletions

View File

@@ -57,9 +57,7 @@ public class AntiSpamIgnore : DbEntity
public override int GetHashCode() => ChannelId.GetHashCode();
public override bool Equals(object obj)
{
return obj is AntiSpamIgnore inst
=> obj is AntiSpamIgnore inst
? inst.ChannelId == ChannelId
: false;
}
}

View File

@@ -23,9 +23,7 @@ public class ClubInfo : DbEntity
public string Description { get; set; }
public override string ToString()
{
return Name + "#" + Discrim;
}
=> Name + "#" + Discrim;
}
public class ClubApplicants

View File

@@ -17,7 +17,7 @@ public class CustomReaction : DbEntity
? Array.Empty<string>()
: Reactions.Split("@@@");
public bool IsGlobal() => GuildId is null || GuildId == 0;
public bool IsGlobal() => GuildId is null or 0;
}
public class ReactionResponse : DbEntity

View File

@@ -6,13 +6,9 @@ public class DelMsgOnCmdChannel : DbEntity
public bool State { get; set; }
public override int GetHashCode()
{
return ChannelId.GetHashCode();
}
=> ChannelId.GetHashCode();
public override bool Equals(object obj)
{
return obj is DelMsgOnCmdChannel x
&& x.ChannelId == ChannelId;
}
=> obj is DelMsgOnCmdChannel x
&& x.ChannelId == ChannelId;
}

View File

@@ -20,16 +20,12 @@ public class DiscordUser : DbEntity
public long CurrencyAmount { get; set; }
public override bool Equals(object obj)
{
return obj is DiscordUser du
=> obj is DiscordUser du
? du.UserId == UserId
: false;
}
public override int GetHashCode()
{
return UserId.GetHashCode();
}
=> UserId.GetHashCode();
public override string ToString() =>
Username + "#" + Discriminator;

View File

@@ -9,14 +9,10 @@ public class FeedSub : DbEntity
public string Url { get; set; }
public override int GetHashCode()
{
return Url.GetHashCode(StringComparison.InvariantCulture) ^ GuildConfigId.GetHashCode();
}
=> Url.GetHashCode(StringComparison.InvariantCulture) ^ GuildConfigId.GetHashCode();
public override bool Equals(object obj)
{
return obj is FeedSub s
&& s.Url.ToLower() == Url.ToLower()
&& s.GuildConfigId == GuildConfigId;
}
=> obj is FeedSub s
&& s.Url.ToLower() == Url.ToLower()
&& s.GuildConfigId == GuildConfigId;
}

View File

@@ -20,16 +20,12 @@ public class FollowedStream : DbEntity
}
protected bool Equals(FollowedStream other)
{
return ChannelId == other.ChannelId
&& Username.Trim().ToUpperInvariant() == other.Username.Trim().ToUpperInvariant()
&& Type == other.Type;
}
=> ChannelId == other.ChannelId
&& Username.Trim().ToUpperInvariant() == other.Username.Trim().ToUpperInvariant()
&& Type == other.Type;
public override int GetHashCode()
{
return HashCode.Combine(ChannelId, Username, (int) Type);
}
=> HashCode.Combine(ChannelId, Username, (int) Type);
public override bool Equals(object obj)
=> obj is FollowedStream fs && Equals(fs);

View File

@@ -6,11 +6,9 @@ public class GCChannelId : DbEntity
public ulong ChannelId { get; set; }
public override bool Equals(object obj)
{
return obj is GCChannelId gc
=> obj is GCChannelId gc
? gc.ChannelId == ChannelId
: false;
}
public override int GetHashCode() =>
this.ChannelId.GetHashCode();

View File

@@ -5,14 +5,10 @@ public class MutedUserId : DbEntity
public ulong UserId { get; set; }
public override int GetHashCode()
{
return UserId.GetHashCode();
}
=> UserId.GetHashCode();
public override bool Equals(object obj)
{
return obj is MutedUserId mui
=> obj is MutedUserId mui
? mui.UserId == UserId
: false;
}
}

View File

@@ -6,14 +6,10 @@ public class PollVote : DbEntity
public int VoteIndex { get; set; }
public override int GetHashCode()
{
return UserId.GetHashCode();
}
=> UserId.GetHashCode();
public override bool Equals(object obj)
{
return obj is PollVote p
=> obj is PollVote p
? p.UserId == UserId
: false;
}
}

View File

@@ -17,7 +17,5 @@ public class SlowmodeIgnoredRole : DbEntity
// override object.GetHashCode
public override int GetHashCode()
{
return RoleId.GetHashCode();
}
=> RoleId.GetHashCode();
}

View File

@@ -17,7 +17,5 @@ public class SlowmodeIgnoredUser : DbEntity
// override object.GetHashCode
public override int GetHashCode()
{
return UserId.GetHashCode();
}
=> UserId.GetHashCode();
}

View File

@@ -51,9 +51,7 @@ public class StreamRoleBlacklistedUser : DbEntity
}
public override int GetHashCode()
{
return UserId.GetHashCode();
}
=> UserId.GetHashCode();
}
public class StreamRoleWhitelistedUser : DbEntity
@@ -62,14 +60,10 @@ public class StreamRoleWhitelistedUser : DbEntity
public string Username { get; set; }
public override bool Equals(object obj)
{
return obj is StreamRoleWhitelistedUser x
=> obj is StreamRoleWhitelistedUser x
? x.UserId == UserId
: false;
}
public override int GetHashCode()
{
return UserId.GetHashCode();
}
=> UserId.GetHashCode();
}

View File

@@ -9,9 +9,7 @@ public class UnbanTimer : DbEntity
UserId.GetHashCode();
public override bool Equals(object obj)
{
return obj is UnbanTimer ut
=> obj is UnbanTimer ut
? ut.UserId == UserId
: false;
}
}

View File

@@ -9,9 +9,7 @@ public class UnmuteTimer : DbEntity
UserId.GetHashCode();
public override bool Equals(object obj)
{
return obj is UnmuteTimer ut
=> obj is UnmuteTimer ut
? ut.UserId == UserId
: false;
}
}

View File

@@ -10,9 +10,7 @@ public class UnroleTimer : DbEntity
UserId.GetHashCode() ^ RoleId.GetHashCode();
public override bool Equals(object obj)
{
return obj is UnroleTimer ut
=> obj is UnroleTimer ut
? ut.UserId == UserId && ut.RoleId == RoleId
: false;
}
}

View File

@@ -27,14 +27,10 @@ public class XpRoleReward : DbEntity
public bool Remove { get; set; }
public override int GetHashCode()
{
return Level.GetHashCode() ^ XpSettingsId.GetHashCode();
}
=> Level.GetHashCode() ^ XpSettingsId.GetHashCode();
public override bool Equals(object obj)
{
return obj is XpRoleReward xrr && xrr.Level == Level && xrr.XpSettingsId == XpSettingsId;
}
=> obj is XpRoleReward xrr && xrr.Level == Level && xrr.XpSettingsId == XpSettingsId;
}
public class XpCurrencyReward : DbEntity
@@ -46,14 +42,10 @@ public class XpCurrencyReward : DbEntity
public int Amount { get; set; }
public override int GetHashCode()
{
return Level.GetHashCode() ^ XpSettingsId.GetHashCode();
}
=> Level.GetHashCode() ^ XpSettingsId.GetHashCode();
public override bool Equals(object obj)
{
return obj is XpCurrencyReward xrr && xrr.Level == Level && xrr.XpSettingsId == XpSettingsId;
}
=> obj is XpCurrencyReward xrr && xrr.Level == Level && xrr.XpSettingsId == XpSettingsId;
}
public class ExcludedItem : DbEntity
@@ -62,12 +54,8 @@ public class ExcludedItem : DbEntity
public ExcludedItemType ItemType { get; set; }
public override int GetHashCode()
{
return ItemId.GetHashCode() ^ ItemType.GetHashCode();
}
=> ItemId.GetHashCode() ^ ItemType.GetHashCode();
public override bool Equals(object obj)
{
return obj is ExcludedItem ei && ei.ItemId == ItemId && ei.ItemType == ItemType;
}
=> obj is ExcludedItem ei && ei.ItemId == ItemId && ei.ItemType == ItemType;
}