Skip to content

Commit bfd7cc4

Browse files
committed
Refactoring using Rider inspections.
1 parent de2faee commit bfd7cc4

34 files changed

+188
-190
lines changed

Leaf.xNet/Randomizer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ namespace Leaf.xNet
99
/// </summary>
1010
public static class Randomizer
1111
{
12-
private static readonly RNGCryptoServiceProvider generator = new RNGCryptoServiceProvider();
12+
private static readonly RNGCryptoServiceProvider Generator = new RNGCryptoServiceProvider();
1313

1414
private static Random Generate()
1515
{
16-
byte[] buffer = new byte[4];
17-
generator.GetBytes(buffer);
16+
var buffer = new byte[4];
17+
Generator.GetBytes(buffer);
1818
return new Random(BitConverter.ToInt32(buffer, 0));
1919
}
2020

Leaf.xNet/RequestParams.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ public class RequestParams : List<KeyValuePair<string,string>>
1717
/// <summary>
1818
/// Указывает, нужно ли пропустить кодирование значений параметров запроса.
1919
/// </summary>
20+
// ReSharper disable once MemberCanBePrivate.Global
2021
public readonly bool ValuesUnescaped;
2122

2223
/// <summary>
2324
/// Указывает, нужно ли пропустить кодирование имен параметров запроса.
2425
/// </summary>
26+
// ReSharper disable once MemberCanBePrivate.Global
2527
public readonly bool KeysUnescaped;
2628

2729
/// <inheritdoc />

Leaf.xNet/Services/Captcha/BaseCaptchaSolver.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
using System;
22
using System.IO;
3-
using System.Net;
43
using System.Threading;
54

5+
// ReSharper disable MemberCanBeProtected.Global
6+
// ReSharper disable MemberCanBePrivate.Global
7+
// ReSharper disable UnusedAutoPropertyAccessor.Global
8+
69
namespace Leaf.xNet.Services.Captcha
710
{
811
public abstract class BaseCaptchaSolver : ICaptchaSolver, IDisposable
912
{
1013
public string ApiKey { get; set; }
1114
public bool IsApiKeyRequired { get; protected set; } = true;
12-
public virtual bool IsApiKeyValid => !string.IsNullOrEmpty(ApiKey);
15+
public bool IsApiKeyValid => !string.IsNullOrEmpty(ApiKey);
1316

1417
public uint UploadRetries { get; set; } = 40;
1518
public uint StatusRetries { get; set; } = 80;
@@ -25,25 +28,25 @@ public abstract class BaseCaptchaSolver : ICaptchaSolver, IDisposable
2528
#region SolveImage : Generic
2629

2730
/// <exception cref="NotImplementedException">Throws when method isn't implemented by your class.</exception>
28-
public virtual string SolveImage(string imageUrl, CancellationToken cancelToken = default(CancellationToken))
31+
public virtual string SolveImage(string imageUrl, CancellationToken cancelToken = default)
2932
{
3033
throw NotImplemented(nameof(SolveImage), NameOfString);
3134
}
3235

3336
/// <exception cref="NotImplementedException">Throws when method isn't implemented by your class.</exception>
34-
public virtual string SolveImage(byte[] imageBytes, CancellationToken cancelToken = default(CancellationToken))
37+
public virtual string SolveImage(byte[] imageBytes, CancellationToken cancelToken = default)
3538
{
3639
throw NotImplemented(nameof(SolveImage), "byte[]");
3740
}
3841

3942
/// <exception cref="NotImplementedException">Throws when method isn't implemented by your class.</exception>
40-
public virtual string SolveImage(Stream imageStream, CancellationToken cancelToken = default(CancellationToken))
43+
public virtual string SolveImage(Stream imageStream, CancellationToken cancelToken = default)
4144
{
4245
throw NotImplemented(nameof(SolveImage), nameof(Stream));
4346
}
4447

4548
/// <exception cref="NotImplementedException">Throws when method isn't implemented by your class.</exception>
46-
public string SolveImageFromBase64(string imageBase64, CancellationToken cancelToken = default(CancellationToken))
49+
public string SolveImageFromBase64(string imageBase64, CancellationToken cancelToken = default)
4750
{
4851
throw NotImplemented(nameof(SolveImageFromBase64), NameOfString);
4952
}
@@ -54,7 +57,7 @@ public abstract class BaseCaptchaSolver : ICaptchaSolver, IDisposable
5457
#region SolveImage : Recaptcha
5558

5659
/// <exception cref="NotImplementedException">Throws when method isn't implemented by your class.</exception>
57-
public virtual string SolveRecaptcha(string pageUrl, string siteKey, CancellationToken cancelToken = default(CancellationToken))
60+
public virtual string SolveRecaptcha(string pageUrl, string siteKey, CancellationToken cancelToken = default)
5861
{
5962
throw NotImplemented(nameof(SolveRecaptcha), "string, string");
6063
}
@@ -67,6 +70,7 @@ protected void ThrowIfApiKeyRequiredAndInvalid()
6770
throw new CaptchaException(CaptchaError.InvalidApiKey);
6871
}
6972

73+
// ReSharper disable once UnusedParameter.Global
7074
protected void Delay(TimeSpan delay, CancellationToken cancelToken)
7175
{
7276
if (cancelToken != CancellationToken.None)

Leaf.xNet/Services/Captcha/CaptchaException.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
// ReSharper disable MemberCanBePrivate.Global
23

34
namespace Leaf.xNet.Services.Captcha
45
{

Leaf.xNet/Services/Captcha/CaptchaProxy.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ namespace Leaf.xNet.Services.Captcha
66
[SuppressMessage("ReSharper", "InconsistentNaming")]
77
public enum CaptchaProxyType
88
{
9+
// ReSharper disable UnusedMember.Global
910
HTTP,
1011
HTTPS,
1112
SOCKS4,
1213
SOCKS5
14+
// ReSharper restore UnusedMember.Global
1315
}
1416

1517
public struct CaptchaProxy
@@ -39,6 +41,7 @@ public CaptchaProxy(string type, string address)
3941
Address = address;
4042
}
4143

44+
// ReSharper disable once UnusedParameter.Local
4245
private static void Validate(CaptchaProxyType type, string address)
4346
{
4447
if (string.IsNullOrEmpty(address))

Leaf.xNet/Services/Captcha/ICaptchaSolver.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
using System.IO;
33
using System.Threading;
44

5+
// ReSharper disable UnusedMemberInSuper.Global
6+
// ReSharper disable UnusedMember.Global
7+
// ReSharper disable UnusedParameter.Global
8+
59
namespace Leaf.xNet.Services.Captcha
610
{
711
public interface ICaptchaSolver
@@ -12,12 +16,12 @@ public interface ICaptchaSolver
1216
TimeSpan UploadDelayOnNoSlotAvailable { get; set; }
1317
TimeSpan StatusDelayOnNotReady { get; set; }
1418
TimeSpan BeforeStatusCheckingDelay { get; set; }
19+
20+
string SolveImage(string imageUrl, CancellationToken cancelToken = default);
21+
string SolveImage(byte[] imageBytes, CancellationToken cancelToken = default);
22+
string SolveImage(Stream imageStream, CancellationToken cancelToken = default);
23+
string SolveImageFromBase64(string imageBase64, CancellationToken cancelToken = default);
1524

16-
string SolveImage(string imageUrl, CancellationToken cancelToken = default(CancellationToken));
17-
string SolveImage(byte[] imageBytes, CancellationToken cancelToken = default(CancellationToken));
18-
string SolveImage(Stream imageStream, CancellationToken cancelToken = default(CancellationToken));
19-
string SolveImageFromBase64(string imageBase64, CancellationToken cancelToken = default(CancellationToken));
20-
21-
string SolveRecaptcha(string pageUrl, string siteKey, CancellationToken cancelToken = default(CancellationToken));
25+
string SolveRecaptcha(string pageUrl, string siteKey, CancellationToken cancelToken = default);
2226
}
2327
}

Leaf.xNet/Services/Captcha/~Services/CapmonsterSolver.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
namespace Leaf.xNet.Services.Captcha
22
{
3+
/// <inheritdoc />
4+
// ReSharper disable once UnusedType.Global
35
public class CapmonsterSolver : RucaptchaSolver
46
{
57
public CapmonsterSolver(string host = "127.0.0.3:80")

Leaf.xNet/Services/Captcha/~Services/RucaptchaSolver.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ namespace Leaf.xNet.Services.Captcha
99
/// <inheritdoc />
1010
public class RucaptchaSolver : BaseCaptchaSolver
1111
{
12+
// ReSharper disable once MemberCanBeProtected.Global
1213
public string Host { get; protected set; } = "rucaptcha.com";
1314

15+
// ReSharper disable once UnusedAutoPropertyAccessor.Global
16+
// ReSharper disable once MemberCanBePrivate.Global
1417
public CaptchaProxy Proxy { get; set; }
1518

16-
public override string SolveRecaptcha(string pageUrl, string siteKey, CancellationToken cancelToken = default(CancellationToken))
19+
public override string SolveRecaptcha(string pageUrl, string siteKey, CancellationToken cancelToken = default)
1720
{
1821
// Validation
1922
ThrowIfApiKeyRequiredAndInvalid();
@@ -30,7 +33,7 @@ public class RucaptchaSolver : BaseCaptchaSolver
3033
{"key", ApiKey},
3134
{"method", "userrecaptcha"},
3235
{"googlekey", siteKey},
33-
{"pageurl", pageUrl},
36+
{"pageurl", pageUrl}
3437
};
3538

3639
if (Proxy.IsValid)

Leaf.xNet/Services/Captcha/~Services/TwoCaptchaSolver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace Leaf.xNet.Services.Captcha
22
{
3-
// ReSharper disable once UnusedMember.Global
43
/// <inheritdoc />
4+
// ReSharper disable once UnusedType.Global
55
public class TwoCaptchaSolver : RucaptchaSolver
66
{
77
public TwoCaptchaSolver()

Leaf.xNet/Services/Cloudflare/ChallengeSolution.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Globalization;
3+
// ReSharper disable MemberCanBePrivate.Global
34

45
namespace Leaf.xNet.Services.Cloudflare
56
{
@@ -37,12 +38,13 @@ public struct ChallengeSolution : IEquatable<ChallengeSolution>
3738
/// <summary>
3839
/// Вернет истину если испытание подсчитывается только типом <see cref="Int32"/>, а не <see cref="Double"/> с плавающей точкой.
3940
/// </summary>
41+
// ReSharper disable once UnusedAutoPropertyAccessor.Global
4042
public bool ContainsIntegerTag { get; }
4143

4244
/// <summary>
4345
/// Результирующий URL запроса который необходимо исполнить для прохождения JS испытания.
4446
/// </summary>
45-
public string ClearanceQuery => !(string.IsNullOrEmpty(S)) ?
47+
public string ClearanceQuery => !string.IsNullOrEmpty(S) ?
4648
$"{ClearancePage}?s={Uri.EscapeDataString(S)}&jschl_vc={VerificationCode}&pass={Pass}&jschl_answer={Answer.ToString("R", CultureInfo.InvariantCulture)}" :
4749
$"{ClearancePage}?jschl_vc={VerificationCode}&pass={Pass}&jschl_answer={Answer.ToString("R", CultureInfo.InvariantCulture)}";
4850

0 commit comments

Comments
 (0)