Skip to content

Commit

Permalink
Make CodeQA happy
Browse files Browse the repository at this point in the history
  • Loading branch information
neon-nyan committed Jan 5, 2025
1 parent 5663c80 commit 2d1ad71
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
21 changes: 10 additions & 11 deletions CollapseLauncher/Classes/Helper/HttpClientBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Hi3Helper.Shared.Region;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net;
using System.Net.Http;
using System.Net.Security;
Expand All @@ -15,23 +14,23 @@ public class HttpClientBuilder : HttpClientBuilder<SocketsHttpHandler>;

public class HttpClientBuilder<THandler> where THandler : HttpMessageHandler, new()
{
private const int _maxConnectionsDefault = 32;
private const double _httpTimeoutDefault = 90; // in Seconds
private const int MaxConnectionsDefault = 32;
private const double HttpTimeoutDefault = 90; // in Seconds

private bool IsUseProxy { get; set; } = true;
private bool IsUseSystemProxy { get; set; } = true;
private bool IsAllowHttpRedirections { get; set; }
private bool IsAllowHttpCookies { get; set; }
private bool IsAllowUntrustedCert { get; set; }

private int MaxConnections { get; set; } = _maxConnectionsDefault;
private int MaxConnections { get; set; } = MaxConnectionsDefault;
private DecompressionMethods DecompressionMethod { get; set; } = DecompressionMethods.All;
private WebProxy? ExternalProxy { get; set; }
private Version HttpProtocolVersion { get; set; } = HttpVersion.Version30;
private string? HttpUserAgent { get; set; } = GetDefaultUserAgent();
private string? HttpAuthHeader { get; set; }
private HttpVersionPolicy HttpProtocolVersionPolicy { get; set; } = HttpVersionPolicy.RequestVersionOrLower;
private TimeSpan HttpTimeout { get; set; } = TimeSpan.FromSeconds(_httpTimeoutDefault);
private TimeSpan HttpTimeout { get; set; } = TimeSpan.FromSeconds(HttpTimeoutDefault);
private Uri? HttpBaseUri { get; set; }
private Dictionary<string, string?> HttpHeaders { get; set; } = new(StringComparer.OrdinalIgnoreCase);

Expand Down Expand Up @@ -80,7 +79,7 @@ public HttpClientBuilder<THandler> UseExternalProxy(Uri hostUri, string? usernam
return this;
}

public HttpClientBuilder<THandler> UseLauncherConfig(int maxConnections = _maxConnectionsDefault)
public HttpClientBuilder<THandler> UseLauncherConfig(int maxConnections = MaxConnectionsDefault)
{
bool lIsUseProxy = LauncherConfig.GetAppConfigValue("IsUseProxy").ToBool();
bool lIsAllowHttpRedirections = LauncherConfig.GetAppConfigValue("IsAllowHttpRedirections").ToBool();
Expand Down Expand Up @@ -111,7 +110,7 @@ public HttpClientBuilder<THandler> UseLauncherConfig(int maxConnections = _maxCo
return this;
}

public HttpClientBuilder<THandler> SetMaxConnection(int maxConnections = _maxConnectionsDefault)
public HttpClientBuilder<THandler> SetMaxConnection(int maxConnections = MaxConnectionsDefault)
{
if (maxConnections < 2)
maxConnections = 2;
Expand Down Expand Up @@ -159,18 +158,18 @@ public HttpClientBuilder<THandler> SetHttpVersion(Version? version = null, HttpV
return this;
}

public HttpClientBuilder<THandler> SetTimeout(double fromSeconds = _httpTimeoutDefault)
public HttpClientBuilder<THandler> SetTimeout(double fromSeconds = HttpTimeoutDefault)
{
if (double.IsNaN(fromSeconds) || double.IsInfinity(fromSeconds))
fromSeconds = _httpTimeoutDefault;
fromSeconds = HttpTimeoutDefault;

return SetTimeout(TimeSpan.FromSeconds(fromSeconds));
}

public HttpClientBuilder<THandler> SetTimeout(TimeSpan? timeout = null)
{
timeout ??= TimeSpan.FromSeconds(_httpTimeoutDefault);
HttpTimeout = timeout.Value;
timeout ??= TimeSpan.FromSeconds(HttpTimeoutDefault);
HttpTimeout = timeout.Value;
return this;
}

Expand Down
1 change: 0 additions & 1 deletion CollapseLauncher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Hi3Helper.Http.Legacy;
using Hi3Helper.SentryHelper;
using Hi3Helper.Shared.ClassStruct;
using Hi3Helper.Shared.Region;
using Hi3Helper.Win32.Native.LibraryImport;
using Hi3Helper.Win32.Native.ManagedTools;
using Hi3Helper.Win32.ShellLinkCOM;
Expand Down
3 changes: 2 additions & 1 deletion Hi3Helper.Core/Classes/Logger/Type/LoggerNull.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text;
// ReSharper disable MethodOverloadWithOptionalParameter

namespace Hi3Helper
{
Expand All @@ -9,7 +10,7 @@ public class LoggerNull(string folderPath, Encoding encoding) : LoggerBase(folde
#region Methods
public void Dispose() => DisposeBase();
public override void LogWriteLine() { }
public override void LogWriteLine(string _ = null) { }
public override void LogWriteLine(string line = null) { }
public override void LogWriteLine(string line, LogType type) { }
public override void LogWriteLine(string line, LogType type, bool writeToLog)
{
Expand Down

0 comments on commit 2d1ad71

Please sign in to comment.