Using pattern matching for nulls where applicable, discarded unused lambda parameters, cleaned up some classes. Unignored ServerLog commands which was mistakenly ignored due to a .gitignore rule

This commit is contained in:
Kwoth
2022-01-01 08:44:51 +01:00
parent f81f9fadd3
commit 9b4eb21321
91 changed files with 1591 additions and 224 deletions

View File

@@ -700,7 +700,7 @@ public partial class Searches : NadekoModule<SearchesService>
{
}
if (obj.Error != null || obj.Verses is null || obj.Verses.Length == 0)
if (obj.Error is not null || obj.Verses is null || obj.Verses.Length == 0)
{
await SendErrorAsync(obj.Error ?? "No verse found.");
}

View File

@@ -72,13 +72,13 @@ public class AnimeSearchService : INService
var genres = document.QuerySelector("div#seriesgenre")
.Children.Select(x => x as IHtmlAnchorElement)
.Where(x => x != null)
.Where(x => x is not null)
.Select(x => $"[{x.InnerHtml}]({x.Href})")
.ToArray();
var authors = document.QuerySelector("div#showauthors")
.Children.Select(x => x as IHtmlAnchorElement)
.Where(x => x != null)
.Where(x => x is not null)
.Select(x => $"[{x.InnerHtml}]({x.Href})")
.ToArray();

View File

@@ -45,7 +45,7 @@ public class CryptoService : INService
crypto = nearest?.Elem;
}
if (nearest != null) return (null, crypto);
if (nearest is not null) return (null, crypto);
return (crypto, null);
}

View File

@@ -108,10 +108,10 @@ public class FeedsService : INService
previewElement = afi.Element.Elements()
.FirstOrDefault(x => x.Name.LocalName == "thumbnail");
if (previewElement != null)
if (previewElement is not null)
{
var urlAttribute = previewElement.Attribute("url");
if (urlAttribute != null
if (urlAttribute is not null
&& !string.IsNullOrWhiteSpace(urlAttribute.Value)
&& Uri.IsWellFormedUriString(urlAttribute.Value, UriKind.Absolute))
{
@@ -129,10 +129,10 @@ public class FeedsService : INService
embed.WithDescription(desc.TrimTo(2048));
//send the created embed to all subscribed channels
var feedSendTasks = kvp.Value.Where(x => x.GuildConfig != null)
var feedSendTasks = kvp.Value.Where(x => x.GuildConfig is not null)
.Select(x => _client.GetGuild(x.GuildConfig.GuildId)
?.GetTextChannel(x.ChannelId))
.Where(x => x != null)
.Where(x => x is not null)
.Select(x => x.EmbedAsync(embed));
allSendTasks.Add(feedSendTasks.WhenAll());
@@ -174,7 +174,7 @@ public class FeedsService : INService
foreach (var feed in gc.FeedSubs)
_subs.AddOrUpdate(feed.Url.ToLower(),
new HashSet<FeedSub> { feed },
(k, old) =>
(_, old) =>
{
old.Add(feed);
return old;
@@ -198,7 +198,7 @@ public class FeedsService : INService
var toRemove = items[index];
_subs.AddOrUpdate(toRemove.Url.ToLower(),
new HashSet<FeedSub>(),
(key, old) =>
(_, old) =>
{
old.Remove(toRemove);
return old;

View File

@@ -549,7 +549,7 @@ public class SearchesService : INService
return new GoogleSearchResult(name, href, txt);
})
.Where(x => x != null)
.Where(x => x is not null)
.ToList();
return new(results.AsReadOnly(), fullQueryLink, totalResults);
@@ -596,7 +596,7 @@ public class SearchesService : INService
return new GoogleSearchResult(name, href, txt);
})
.Where(x => x != null)
.Where(x => x is not null)
.ToList();
return new(results.AsReadOnly(), fullQueryLink, "0");