Changed all == null to is null and all !(* == null) to * is not null

This commit is contained in:
Kwoth
2021-06-19 08:24:09 +02:00
parent 81406cb46a
commit d8c7cdc7f4
125 changed files with 367 additions and 366 deletions

View File

@@ -28,7 +28,7 @@ namespace NadekoBot.Db
.Include(y => y.StreamRole.Whitelist)
.Include(y => y.StreamRole.Blacklist));
if (conf.StreamRole == null)
if (conf.StreamRole is null)
conf.StreamRole = new StreamRoleSettings();
return conf.StreamRole;
@@ -79,7 +79,7 @@ namespace NadekoBot.Db
{
GuildConfig config;
if (includes == null)
if (includes is null)
{
config = ctx
.GuildConfigs
@@ -92,7 +92,7 @@ namespace NadekoBot.Db
config = set.FirstOrDefault(c => c.GuildId == guildId);
}
if (config == null)
if (config is null)
{
ctx.GuildConfigs.Add((config = new GuildConfig
{
@@ -122,7 +122,7 @@ namespace NadekoBot.Db
.ThenInclude(gc => gc.IgnoredChannels)
.FirstOrDefault(x => x.GuildId == guildId);
if (config == null)
if (config is null)
{
ctx.GuildConfigs.Add((config = new GuildConfig
{
@@ -160,7 +160,7 @@ namespace NadekoBot.Db
.Include(gc => gc.Permissions)
.FirstOrDefault();
if (config == null) // if there is no guildconfig, create new one
if (config is null) // if there is no guildconfig, create new one
{
ctx.GuildConfigs.Add((config = new GuildConfig
{
@@ -169,7 +169,7 @@ namespace NadekoBot.Db
}));
ctx.SaveChanges();
}
else if (config.Permissions == null || !config.Permissions.Any()) // if no perms, add default ones
else if (config.Permissions is null || !config.Permissions.Any()) // if no perms, add default ones
{
config.Permissions = Permissionv2.GetDefaultPermlist;
ctx.SaveChanges();
@@ -200,7 +200,7 @@ namespace NadekoBot.Db
{
var conf = configs.FirstOrDefault(gc => gc.GuildId == id);
if (conf == null)
if (conf is null)
return;
conf.CleverbotEnabled = cleverbotEnabled;
@@ -216,7 +216,7 @@ namespace NadekoBot.Db
.Include(x => x.XpSettings)
.ThenInclude(x => x.ExclusionList));
if (gc.XpSettings == null)
if (gc.XpSettings is null)
gc.XpSettings = new XpSettings();
return gc.XpSettings;

View File

@@ -11,7 +11,7 @@ namespace NadekoBot.Db
{
var role = roles.FirstOrDefault(s => s.GuildId == guildId && s.RoleId == roleId);
if (role == null)
if (role is null)
return false;
roles.Remove(role);

View File

@@ -13,7 +13,7 @@ namespace NadekoBot.Db
{
var usr = ctx.UserXpStats.FirstOrDefault(x => x.UserId == userId && x.GuildId == guildId);
if (usr == null)
if (usr is null)
{
ctx.Add(usr = new UserXpStats()
{

View File

@@ -28,7 +28,7 @@ namespace NadekoBot.Db
{
public static WaifuInfo ByWaifuUserId(this DbSet<WaifuInfo> waifus, ulong userId, Func<DbSet<WaifuInfo>, IQueryable<WaifuInfo>> includes = null)
{
if (includes == null)
if (includes is null)
{
return waifus.Include(wi => wi.Waifu)
.Include(wi => wi.Affinity)

View File

@@ -27,7 +27,7 @@ namespace NadekoBot.Db
.Skip(index)
.FirstOrDefault();
if (warn == null || warn.Forgiven)
if (warn is null || warn.Forgiven)
return false;
warn.Forgiven = true;

View File

@@ -8,7 +8,7 @@
//// override object.Equals
//public override bool Equals(object obj)
//{
// if (obj == null || GetType() != obj.GetType())
// if (obj is null || GetType() != obj.GetType())
// {
// return false;
// }

View File

@@ -33,7 +33,7 @@ namespace NadekoBot.Core.Services.Database.Models
public override bool Equals(object obj)
{
if (obj == null || GetType() != obj.GetType())
if (obj is null || GetType() != obj.GetType())
{
return false;
}

View File

@@ -7,7 +7,7 @@
// override object.Equals
public override bool Equals(object obj)
{
if (obj == null || GetType() != obj.GetType())
if (obj is null || GetType() != obj.GetType())
{
return false;
}

View File

@@ -7,7 +7,7 @@
// override object.Equals
public override bool Equals(object obj)
{
if (obj == null || GetType() != obj.GetType())
if (obj is null || GetType() != obj.GetType())
{
return false;
}

View File

@@ -31,7 +31,7 @@ namespace NadekoBot.Core.Services.Database.Models
{
claimer = $"{ claimerUsername }#{Claimer.Discriminator}";
}
if (AffinityId == null)
if (AffinityId is null)
{
status = $"... but {waifuUsername}'s heart is empty";
}
@@ -72,7 +72,7 @@ namespace NadekoBot.Core.Services.Database.Models
{
claimer = $"{ claimerUsername }#{ClaimerDiscrim}";
}
if (Affinity == null)
if (Affinity is null)
{
status = $"... but {waifuUsername}'s heart is empty";
}