Skip to content

Commit

Permalink
clean up compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
13xforever authored and clienthax committed Jun 20, 2024
1 parent 7d4d3ed commit d6688fd
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CompatBot/Commands/Sudo.Bot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using Microsoft.EntityFrameworkCore;
using NLog;

namespace CompatBot.Commands;

Expand Down Expand Up @@ -248,7 +249,7 @@ internal static void RestartNoSaving()
if (SandboxDetector.Detect() != SandboxType.Docker)
{
Config.Log.Info("Restarting...");
Config.Log.Factory.Flush();
LogManager.LogFactory.Flush();
using var self = new Process {StartInfo = RestartInfo};
self.Start();
Config.InMemorySettings["shutdown"] = "true";
Expand Down
3 changes: 2 additions & 1 deletion CompatBot/Commands/Sudo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using DSharpPlus.Entities;
using DSharpPlus.Interactivity.Extensions;
using Microsoft.EntityFrameworkCore;
using NLog;
using SharpCompress.Common;
using SharpCompress.Compressors;
using SharpCompress.Compressors.Deflate;
Expand Down Expand Up @@ -134,7 +135,7 @@ public async Task Log(CommandContext ctx, [Description("Specific date")]string d
{
try
{
Config.Log.Factory.Flush();
LogManager.LogFactory.Flush();
string[] logPaths = [Config.CurrentLogPath];
if (DateTime.TryParse(date, CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out var logDate))
{
Expand Down
2 changes: 2 additions & 0 deletions CompatBot/Database/DbImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ private static async Task ImportAsync(BotDb dbContext, CancellationToken cancell
{
// __EFMigrationsHistory table will be already created by the failed migration attempt
#pragma warning disable EF1001 // Internal EF Core API usage.
#pragma warning disable EF1002 // Using raw sql
await db.ExecuteSqlRawAsync($"INSERT INTO `__EFMigrationsHistory`(`MigrationId`,`ProductVersion`) VALUES ({new InitialCreate().GetId()},'manual')", cancellationToken);
await db.ExecuteSqlRawAsync($"INSERT INTO `__EFMigrationsHistory`(`MigrationId`,`ProductVersion`) VALUES ({new Explanations().GetId()},'manual')", cancellationToken);
#pragma warning restore EF1002
#pragma warning restore EF1001 // Internal EF Core API usage.
// create constraints on moderator
await db.ExecuteSqlRawAsync(@"CREATE TABLE `temp_new_moderator` (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public async Task FillPipeAsync(Stream sourceStream, PipeWriter writer, Cancella
while (rarReader.MoveToNextEntry())
{
if (!rarReader.Entry.IsDirectory
&& rarReader.Entry.Key.EndsWith(".log", StringComparison.InvariantCultureIgnoreCase)
&& rarReader.Entry.Key!.EndsWith(".log", StringComparison.InvariantCultureIgnoreCase)
&& !rarReader.Entry.Key.Contains("tty.log", StringComparison.InvariantCultureIgnoreCase))
{
LogSize = rarReader.Entry.Size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public async Task FillPipeAsync(Stream sourceStream, PipeWriter writer, Cancella
using var zipReader = zipArchive.ExtractAllEntries();
while (zipReader.MoveToNextEntry())
if (!zipReader.Entry.IsDirectory
&& zipReader.Entry.Key.EndsWith(".log", StringComparison.InvariantCultureIgnoreCase)
&& zipReader.Entry.Key!.EndsWith(".log", StringComparison.InvariantCultureIgnoreCase)
&& !zipReader.Entry.Key.Contains("tty.log", StringComparison.InvariantCultureIgnoreCase))
{
LogSize = zipReader.Entry.Size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public async Task FillPipeAsync(Stream sourceStream, PipeWriter writer, Cancella
while (zipReader.MoveToNextEntry())
{
if (!zipReader.Entry.IsDirectory
&& zipReader.Entry.Key.EndsWith(".log", StringComparison.InvariantCultureIgnoreCase)
&& zipReader.Entry.Key!.EndsWith(".log", StringComparison.InvariantCultureIgnoreCase)
&& !zipReader.Entry.Key.Contains("tty.log", StringComparison.InvariantCultureIgnoreCase))
{
LogSize = zipReader.Entry.Size;
Expand Down
2 changes: 1 addition & 1 deletion CompatBot/Utils/ColorGetter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static SixLabors.ImageSharp.Color GetDominentColor(SixLabors.ImageSharp.I
return defaultColor;

// TODO .net6 breaks this for linux
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
if (!OperatingSystem.IsWindowsVersionAtLeast(6, 1))
return defaultColor;

var analyzer = new ColorThief();
Expand Down
6 changes: 3 additions & 3 deletions CompatBot/Utils/Extensions/AzureDevOpsClientExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public static async Task<BuildInfo> GetArtifactsInfoAsync(this BuildHttpClient a
using var zipStream = ReaderFactory.Open(stream);
while (zipStream.MoveToNextEntry() && !cancellationToken.IsCancellationRequested)
{
if (zipStream.Entry.Key.EndsWith(".7z", StringComparison.InvariantCultureIgnoreCase))
if (zipStream.Entry.Key?.EndsWith(".7z", StringComparison.InvariantCultureIgnoreCase) is true)
{
result = result with {WindowsFilename = Path.GetFileName(zipStream.Entry.Key)};
break;
Expand Down Expand Up @@ -248,7 +248,7 @@ public static async Task<BuildInfo> GetArtifactsInfoAsync(this BuildHttpClient a
using var zipStream = ReaderFactory.Open(stream);
while (zipStream.MoveToNextEntry() && !cancellationToken.IsCancellationRequested)
{
if (zipStream.Entry.Key.EndsWith(".AppImage", StringComparison.InvariantCultureIgnoreCase))
if (zipStream.Entry.Key?.EndsWith(".AppImage", StringComparison.InvariantCultureIgnoreCase) is true)
{
result = result with {LinuxFilename = Path.GetFileName(zipStream.Entry.Key)};
break;
Expand All @@ -275,7 +275,7 @@ public static async Task<BuildInfo> GetArtifactsInfoAsync(this BuildHttpClient a
using var zipStream = ReaderFactory.Open(stream);
while (zipStream.MoveToNextEntry() && !cancellationToken.IsCancellationRequested)
{
if (zipStream.Entry.Key.EndsWith(".dmg", StringComparison.InvariantCultureIgnoreCase))
if (zipStream.Entry.Key?.EndsWith(".dmg", StringComparison.InvariantCultureIgnoreCase) is true)
{
result = result with { MacFilename = Path.GetFileName(zipStream.Entry.Key) };
break;
Expand Down

0 comments on commit d6688fd

Please sign in to comment.