Skip to content

Commit

Permalink
[CodeFactor] Apply fixes (2dust#6005)
Browse files Browse the repository at this point in the history
Co-authored-by: codefactor-io <support@codefactor.io>
  • Loading branch information
DecorativeFamily and code-factor authored Nov 7, 2024
1 parent 45febe3 commit c4b490e
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions v2rayN/ServiceLib/Common/HttpClientHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Net.Http.Headers;
using System.Net.Http.Headers;
using System.Net.Mime;
using System.Text;

Expand Down Expand Up @@ -98,7 +98,7 @@ public static async Task DownloadFileAsync(HttpClient client, string url, string
totalRead += read;

if (read == 0) break;
await file.WriteAsync(buffer, 0, read, token);
await file.WriteAsync(buffer.AsMemory(0, read), token);

if (canReportProgress)
{
Expand Down
4 changes: 2 additions & 2 deletions v2rayN/ServiceLib/Common/Utils.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using CliWrap;
using CliWrap;
using CliWrap.Buffered;
using System.Collections.Specialized;
using System.Diagnostics;
Expand Down Expand Up @@ -185,7 +185,7 @@ public static string Base64Decode(string? plainText)

if (plainText.Length % 4 > 0)
{
plainText = plainText.PadRight(plainText.Length + 4 - plainText.Length % 4, '=');
plainText = plainText.PadRight(plainText.Length + 4 - (plainText.Length % 4), '=');
}

var data = Convert.FromBase64String(plainText);
Expand Down
4 changes: 2 additions & 2 deletions v2rayN/ServiceLib/Handler/ConfigHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Data;
using System.Data;
using System.Text.RegularExpressions;

namespace ServiceLib.Handler
Expand Down Expand Up @@ -466,7 +466,7 @@ public static async Task<int> MoveServer(Config config, List<ProfileItem> lstPro
break;
}
case EMove.Position:
sort = pos * 10 + 1;
sort = (pos * 10) + 1;
break;
}

Expand Down
8 changes: 4 additions & 4 deletions v2rayN/ServiceLib/Handler/SysProxy/ProxySettingWindows.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Runtime.InteropServices;
using System.Runtime.InteropServices;
using static ServiceLib.Handler.SysProxy.ProxySettingWindows.InternetConnectionOption;

namespace ServiceLib.Handler.SysProxy
Expand Down Expand Up @@ -144,12 +144,12 @@ private static bool SetConnectionProxy(string? connectionName, string? strProxy,
{
if (Environment.Is64BitOperatingSystem)
{
nint opt = new(optionsPtr.ToInt64() + i * optSize);
nint opt = new(optionsPtr.ToInt64() + (i * optSize));
Marshal.StructureToPtr(options[i], opt, false);
}
else
{
nint opt = new(optionsPtr.ToInt32() + i * optSize);
nint opt = new(optionsPtr.ToInt32() + (i * optSize));
Marshal.StructureToPtr(options[i], opt, false);
}
}
Expand Down Expand Up @@ -247,7 +247,7 @@ public struct InternetPerConnOptionList

//[MarshalAs(UnmanagedType.)]
public nint options;
};
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct InternetConnectionOption
Expand Down
4 changes: 2 additions & 2 deletions v2rayN/ServiceLib/Models/V2rayConfig.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;

namespace ServiceLib.Models
{
Expand Down Expand Up @@ -50,7 +50,7 @@ public class V2rayConfig
}

public class Stats4Ray
{ };
{ }

public class API4Ray
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace ServiceLib.Services.CoreConfig
namespace ServiceLib.Services.CoreConfig
{
/// <summary>
/// Core configuration file processing class
Expand Down Expand Up @@ -66,7 +66,7 @@ public async Task<RetResult> GenerateClientCustomConfig(ProfileItem node, string
txtFile = txtFile.Replace(tagYamlStr1, tagYamlStr2);

//YAML anchors
if (txtFile.Contains("<<:") && txtFile.Contains("*") && txtFile.Contains("&"))
if (txtFile.Contains("<<:") && txtFile.Contains('*') && txtFile.Contains('&'))
{
txtFile = YamlUtils.PreprocessYaml(txtFile);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Data;
using System.Data;
using System.Net;
using System.Net.NetworkInformation;

Expand Down Expand Up @@ -484,7 +484,7 @@ private async Task<int> GenInbounds(SingboxConfig singboxConfig)
singboxConfig.inbounds = [];

if (!_config.TunModeItem.EnableTun
|| _config.TunModeItem.EnableTun && _config.TunModeItem.EnableExInbound && _config.RunningCoreType == ECoreType.sing_box)
|| (_config.TunModeItem.EnableTun && _config.TunModeItem.EnableExInbound && _config.RunningCoreType == ECoreType.sing_box))
{
var inbound = new Inbound4Sbox()
{
Expand Down
4 changes: 2 additions & 2 deletions v2rayN/ServiceLib/Services/UpdateService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Runtime.InteropServices;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;

namespace ServiceLib.Services
Expand Down Expand Up @@ -122,7 +122,7 @@ public async Task UpdateSubscriptionProcess(Config config, string subId, bool bl
var url = item.Url.TrimEx();
var userAgent = item.UserAgent.TrimEx();
var hashCode = $"{item.Remarks}->";
if (Utils.IsNullOrEmpty(id) || Utils.IsNullOrEmpty(url) || Utils.IsNotEmpty(subId) && item.Id != subId)
if (Utils.IsNullOrEmpty(id) || Utils.IsNullOrEmpty(url) || (Utils.IsNotEmpty(subId) && item.Id != subId))
{
//_updateFunc?.Invoke(false, $"{hashCode}{ResUI.MsgNoValidSubscription}");
continue;
Expand Down
4 changes: 2 additions & 2 deletions v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using ReactiveUI;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using System.Reactive;

Expand Down Expand Up @@ -105,7 +105,7 @@ private async Task SaveSettingAsync()
item2.DomainStrategy4Freedom = domainStrategy4Freedom2;
item2.DomainDNSAddress = domainDNSAddress2;
item2.NormalDNS = JsonUtils.Serialize(JsonUtils.ParseJson(normalDNS2));
item2.TunDNS = JsonUtils.Serialize(JsonUtils.ParseJson(tunDNS2)); ;
item2.TunDNS = JsonUtils.Serialize(JsonUtils.ParseJson(tunDNS2));
await ConfigHandler.SaveDNSItems(_config, item2);

NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
Expand Down
4 changes: 2 additions & 2 deletions v2rayN/v2rayN.Desktop/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Avalonia;
using Avalonia;
using Avalonia.ReactiveUI;
using v2rayN.Desktop.Common;

Expand All @@ -25,7 +25,7 @@ private static void OnStartup(string[]? Args)
if (Utils.IsWindows())
{
var exePathKey = Utils.GetMd5(Utils.GetExePath());
var rebootas = (Args ?? new string[] { }).Any(t => t == Global.RebootAs);
var rebootas = (Args ?? Array.Empty<string>()).Any(t => t == Global.RebootAs);
ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, exePathKey, out bool bCreatedNew);
if (!rebootas && !bCreatedNew)
{
Expand Down
2 changes: 1 addition & 1 deletion v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ private void RestoreUI()
}
else
{
item2.Width = new DataGridLength(item.Width, DataGridLengthUnitType.Pixel); ;
item2.Width = new DataGridLength(item.Width, DataGridLengthUnitType.Pixel);
item2.DisplayIndex = displayIndex++;
}
if (item.Name.StartsWith("to"))
Expand Down
4 changes: 2 additions & 2 deletions v2rayN/v2rayN/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Diagnostics;
using System.Diagnostics;
using System.Windows;
using System.Windows.Threading;

Expand Down Expand Up @@ -28,7 +28,7 @@ protected override void OnStartup(StartupEventArgs e)
{
var exePathKey = Utils.GetMd5(Utils.GetExePath());

var rebootas = (e.Args ?? new string[] { }).Any(t => t == Global.RebootAs);
var rebootas = (e.Args ?? Array.Empty<string>()).Any(t => t == Global.RebootAs);
ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, exePathKey, out bool bCreatedNew);
if (!rebootas && !bCreatedNew)
{
Expand Down

0 comments on commit c4b490e

Please sign in to comment.