From acb904a502ce28d64e476334a860f130cf1b7df7 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Tue, 5 Nov 2024 21:31:23 +0000 Subject: [PATCH] [CodeFactor] Apply fixes --- v2rayN/ServiceLib/Common/HttpClientHelper.cs | 4 ++-- v2rayN/ServiceLib/Common/Utils.cs | 4 ++-- v2rayN/ServiceLib/Handler/ConfigHandler.cs | 4 ++-- v2rayN/ServiceLib/Handler/SysProxy/ProxySettingWindows.cs | 8 ++++---- v2rayN/ServiceLib/Models/V2rayConfig.cs | 4 ++-- .../Services/CoreConfig/CoreConfigClashService.cs | 4 ++-- .../Services/CoreConfig/CoreConfigSingboxService.cs | 4 ++-- v2rayN/ServiceLib/Services/UpdateService.cs | 4 ++-- v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs | 4 ++-- v2rayN/v2rayN.Desktop/Program.cs | 4 ++-- v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs | 2 +- v2rayN/v2rayN/App.xaml.cs | 4 ++-- 12 files changed, 25 insertions(+), 25 deletions(-) diff --git a/v2rayN/ServiceLib/Common/HttpClientHelper.cs b/v2rayN/ServiceLib/Common/HttpClientHelper.cs index cabc3f8529d..97df3af3cc9 100644 --- a/v2rayN/ServiceLib/Common/HttpClientHelper.cs +++ b/v2rayN/ServiceLib/Common/HttpClientHelper.cs @@ -1,4 +1,4 @@ -using System.Net.Http.Headers; +using System.Net.Http.Headers; using System.Net.Mime; using System.Text; @@ -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) { diff --git a/v2rayN/ServiceLib/Common/Utils.cs b/v2rayN/ServiceLib/Common/Utils.cs index 54183cc05c8..c5bf085a294 100644 --- a/v2rayN/ServiceLib/Common/Utils.cs +++ b/v2rayN/ServiceLib/Common/Utils.cs @@ -1,4 +1,4 @@ -using CliWrap; +using CliWrap; using CliWrap.Buffered; using System.Collections.Specialized; using System.Diagnostics; @@ -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); diff --git a/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayN/ServiceLib/Handler/ConfigHandler.cs index 87030e41fa7..17271c57be6 100644 --- a/v2rayN/ServiceLib/Handler/ConfigHandler.cs +++ b/v2rayN/ServiceLib/Handler/ConfigHandler.cs @@ -1,4 +1,4 @@ -using System.Data; +using System.Data; using System.Text.RegularExpressions; namespace ServiceLib.Handler @@ -466,7 +466,7 @@ public static async Task MoveServer(Config config, List lstPro break; } case EMove.Position: - sort = pos * 10 + 1; + sort = (pos * 10) + 1; break; } diff --git a/v2rayN/ServiceLib/Handler/SysProxy/ProxySettingWindows.cs b/v2rayN/ServiceLib/Handler/SysProxy/ProxySettingWindows.cs index 8ddd703f151..2662f959367 100644 --- a/v2rayN/ServiceLib/Handler/SysProxy/ProxySettingWindows.cs +++ b/v2rayN/ServiceLib/Handler/SysProxy/ProxySettingWindows.cs @@ -1,4 +1,4 @@ -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; using static ServiceLib.Handler.SysProxy.ProxySettingWindows.InternetConnectionOption; namespace ServiceLib.Handler.SysProxy @@ -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); } } @@ -247,7 +247,7 @@ public struct InternetPerConnOptionList //[MarshalAs(UnmanagedType.)] public nint options; - }; + } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct InternetConnectionOption diff --git a/v2rayN/ServiceLib/Models/V2rayConfig.cs b/v2rayN/ServiceLib/Models/V2rayConfig.cs index 4ea3c65135f..593e371002c 100644 --- a/v2rayN/ServiceLib/Models/V2rayConfig.cs +++ b/v2rayN/ServiceLib/Models/V2rayConfig.cs @@ -1,4 +1,4 @@ -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace ServiceLib.Models { @@ -50,7 +50,7 @@ public class V2rayConfig } public class Stats4Ray - { }; + { } public class API4Ray { diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigClashService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigClashService.cs index 109f1cc15e4..bb9e81d4c88 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigClashService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigClashService.cs @@ -1,4 +1,4 @@ -namespace ServiceLib.Services.CoreConfig +namespace ServiceLib.Services.CoreConfig { /// /// Core configuration file processing class @@ -66,7 +66,7 @@ public async Task 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); } diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs index b710ca25ace..58f913e52cf 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs @@ -1,4 +1,4 @@ -using System.Data; +using System.Data; using System.Net; using System.Net.NetworkInformation; @@ -484,7 +484,7 @@ private async Task 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() { diff --git a/v2rayN/ServiceLib/Services/UpdateService.cs b/v2rayN/ServiceLib/Services/UpdateService.cs index c02666140f0..4eafc5c4575 100644 --- a/v2rayN/ServiceLib/Services/UpdateService.cs +++ b/v2rayN/ServiceLib/Services/UpdateService.cs @@ -1,4 +1,4 @@ -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; using System.Text.RegularExpressions; namespace ServiceLib.Services @@ -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; diff --git a/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs index cef9900210f..703ee49b35d 100644 --- a/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs @@ -1,4 +1,4 @@ -using ReactiveUI; +using ReactiveUI; using ReactiveUI.Fody.Helpers; using System.Reactive; @@ -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); diff --git a/v2rayN/v2rayN.Desktop/Program.cs b/v2rayN/v2rayN.Desktop/Program.cs index a5eefe42f81..193731ffcb2 100644 --- a/v2rayN/v2rayN.Desktop/Program.cs +++ b/v2rayN/v2rayN.Desktop/Program.cs @@ -1,4 +1,4 @@ -using Avalonia; +using Avalonia; using Avalonia.ReactiveUI; namespace v2rayN.Desktop; @@ -24,7 +24,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()).Any(t => t == Global.RebootAs); ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, exePathKey, out bool bCreatedNew); if (!rebootas && !bCreatedNew) { diff --git a/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs b/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs index 83a5e32ab62..1ac0cad38c6 100644 --- a/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml.cs @@ -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")) diff --git a/v2rayN/v2rayN/App.xaml.cs b/v2rayN/v2rayN/App.xaml.cs index 89cd3467587..5b7377d8127 100644 --- a/v2rayN/v2rayN/App.xaml.cs +++ b/v2rayN/v2rayN/App.xaml.cs @@ -1,4 +1,4 @@ -using System.Diagnostics; +using System.Diagnostics; using System.Windows; using System.Windows.Threading; @@ -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()).Any(t => t == Global.RebootAs); ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, exePathKey, out bool bCreatedNew); if (!rebootas && !bCreatedNew) {