[CodeFactor] Apply fixes (#6005)

Co-authored-by: codefactor-io <support@codefactor.io>
pull/6016/head
DecorativeFamily 3 weeks ago committed by GitHub
parent 45febe3fff
commit c4b490e46d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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 @@ namespace ServiceLib.Common
totalRead += read;
if (read == 0) break;
await file.WriteAsync(buffer, 0, read, token);
await file.WriteAsync(buffer.AsMemory(0, read), token);
if (canReportProgress)
{

@ -1,4 +1,4 @@
using CliWrap;
using CliWrap;
using CliWrap.Buffered;
using System.Collections.Specialized;
using System.Diagnostics;
@ -185,7 +185,7 @@ namespace ServiceLib.Common
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);

@ -1,4 +1,4 @@
using System.Data;
using System.Data;
using System.Text.RegularExpressions;
namespace ServiceLib.Handler
@ -466,7 +466,7 @@ namespace ServiceLib.Handler
break;
}
case EMove.Position:
sort = pos * 10 + 1;
sort = (pos * 10) + 1;
break;
}

@ -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 @@ namespace ServiceLib.Handler.SysProxy
{
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 @@ namespace ServiceLib.Handler.SysProxy
//[MarshalAs(UnmanagedType.)]
public nint options;
};
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct InternetConnectionOption

@ -1,4 +1,4 @@
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;
namespace ServiceLib.Models
{
@ -50,7 +50,7 @@ namespace ServiceLib.Models
}
public class Stats4Ray
{ };
{ }
public class API4Ray
{

@ -1,4 +1,4 @@
namespace ServiceLib.Services.CoreConfig
namespace ServiceLib.Services.CoreConfig
{
/// <summary>
/// Core configuration file processing class
@ -66,7 +66,7 @@
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);
}

@ -1,4 +1,4 @@
using System.Data;
using System.Data;
using System.Net;
using System.Net.NetworkInformation;
@ -484,7 +484,7 @@ namespace ServiceLib.Services.CoreConfig
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()
{

@ -1,4 +1,4 @@
using System.Runtime.InteropServices;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
namespace ServiceLib.Services
@ -122,7 +122,7 @@ namespace ServiceLib.Services
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;

@ -1,4 +1,4 @@
using ReactiveUI;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using System.Reactive;
@ -105,7 +105,7 @@ namespace ServiceLib.ViewModels
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);

@ -1,4 +1,4 @@
using Avalonia;
using Avalonia;
using Avalonia.ReactiveUI;
using v2rayN.Desktop.Common;
@ -25,7 +25,7 @@ internal class Program
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)
{

@ -345,7 +345,7 @@ namespace v2rayN.Desktop.Views
}
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"))

@ -1,4 +1,4 @@
using System.Diagnostics;
using System.Diagnostics;
using System.Windows;
using System.Windows.Threading;
@ -28,7 +28,7 @@ namespace v2rayN
{
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)
{

Loading…
Cancel
Save