Skip to content

Commit

Permalink
The R# issues fixed in the source code
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegRa committed Nov 10, 2024
1 parent 55a70c8 commit d7d2d43
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 45 deletions.
4 changes: 2 additions & 2 deletions Alpaca.Markets.Tests/AlpacaTradingClientTest.Watchlists.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public async Task CreateWatchListAsyncWorks()
mock.AddPost(WatchlistsUrl, createWatchList());

var watchList = await mock.Client.CreateWatchListAsync(new NewWatchListRequest(
Guid.NewGuid().ToString("D"), new [] { Stock, Crypto }));
Guid.NewGuid().ToString("D"), [Stock, Crypto]));

validateWatchList(watchList);
}
Expand All @@ -68,7 +68,7 @@ public async Task UpdateWatchListByIdAsyncWorks()
mock.AddPut(WatchListsWildcardUrl, createWatchList());

var watchList = await mock.Client.UpdateWatchListByIdAsync(new UpdateWatchListRequest(
Guid.NewGuid(), Guid.NewGuid().ToString("D"), new [] { Stock, Crypto }));
Guid.NewGuid(), Guid.NewGuid().ToString("D"), [Stock, Crypto]));

validateWatchList(watchList);
}
Expand Down
13 changes: 6 additions & 7 deletions Alpaca.Markets.Tests/AlpacaTradingClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,11 @@ public async Task GetRateLimitValuesWorks()
return;

IEnumerable<KeyValuePair<String, String>> GetHeaders() =>
new KeyValuePair<String, String>[]
{
new("X-Ratelimit-Limit", "100"),
new("X-Ratelimit-Remaining", "99"),
new("X-Ratelimit-Reset",
resetTime.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture))
};
[
new("X-Ratelimit-Limit", "100"),
new("X-Ratelimit-Remaining", "99"),
new("X-Ratelimit-Reset",
resetTime.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture))
];
}
}
8 changes: 4 additions & 4 deletions Alpaca.Markets.Tests/RequestValidationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void HistoricalRequestBaseNoSymbolsValidationWorks() =>

[Fact]
public void HistoricalRequestBaseEmptySymbolValidationWorks() =>
validate(new HistoricalCryptoBarsRequest(new [] { String.Empty }, _interval, BarTimeFrame.Day));
validate(new HistoricalCryptoBarsRequest([String.Empty], _interval, BarTimeFrame.Day));

[Fact]
public void HistoricalRequestBaseEmptyPageValidationWorks() =>
Expand All @@ -25,7 +25,7 @@ public void HistoricalRequestBaseEmptyPageValidationWorks() =>

[Fact]
public void NewsArticlesRequestEmptySymbolValidationWorks() =>
validate(new NewsArticlesRequest(new [] { String.Empty }));
validate(new NewsArticlesRequest([String.Empty]));

[Fact]
public void NewsArticlesRequestBigPageValidationWorks() =>
Expand All @@ -46,7 +46,7 @@ public void NewWatchListRequestEmptyNameValidationWorks() =>

[Fact]
public void NewWatchListRequestEmptySymbolValidationWorks() =>
validate(new NewWatchListRequest(Guid.NewGuid().ToString("D"), new [] { String.Empty}));
validate(new NewWatchListRequest(Guid.NewGuid().ToString("D"), [String.Empty]));

[Fact]
public void UpdateWatchListRequestEmptyNameValidationWorks() =>
Expand All @@ -55,7 +55,7 @@ public void UpdateWatchListRequestEmptyNameValidationWorks() =>
[Fact]
public void UpdateWatchListRequestEmptySymbolValidationWorks() =>
validate(new UpdateWatchListRequest(Guid.NewGuid(),
Guid.NewGuid().ToString("D"), new [] { String.Empty}));
Guid.NewGuid().ToString("D"), [String.Empty]));

[Fact]
public void ChangeWatchListRequestEmptyNameValidationWorks() =>
Expand Down
8 changes: 4 additions & 4 deletions Alpaca.Markets/Parameters/HistoricalAuctionsRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public HistoricalAuctionsRequest(
String symbol,
DateTime from,
DateTime into)
: this(new[] { symbol.EnsureNotNull() }, from, into)
: this([symbol.EnsureNotNull()], from, into)
{
}

Expand All @@ -36,7 +36,7 @@ public HistoricalAuctionsRequest(
public HistoricalAuctionsRequest(
String symbol,
Interval<DateTime> timeInterval)
: this(new[] { symbol.EnsureNotNull() }, timeInterval)
: this([symbol.EnsureNotNull()], timeInterval)
{
}

Expand All @@ -49,7 +49,7 @@ public HistoricalAuctionsRequest(
/// </exception>
public HistoricalAuctionsRequest(
String symbol)
: this(new[] { symbol.EnsureNotNull() })
: this([symbol.EnsureNotNull()])
{
}

Expand Down Expand Up @@ -111,7 +111,7 @@ public HistoricalAuctionsRequest(
public HistoricalAuctionsRequest(
String symbol,
IInclusiveTimeInterval timeInterval)
: this(new[] { symbol.EnsureNotNull() }, timeInterval)
: this([symbol.EnsureNotNull()], timeInterval)
{
}

Expand Down
2 changes: 1 addition & 1 deletion Alpaca.Markets/Parameters/HistoricalBarsRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public HistoricalBarsRequest(
DateTime from,
DateTime into,
BarTimeFrame timeFrame)
: this(new[] { symbol.EnsureNotNull() }, from, into, timeFrame)
: this([symbol.EnsureNotNull()], from, into, timeFrame)
{
}

Expand Down
8 changes: 4 additions & 4 deletions Alpaca.Markets/Parameters/HistoricalCryptoBarsRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public HistoricalCryptoBarsRequest(
DateTime from,
DateTime into,
BarTimeFrame timeFrame)
: this(new[] { symbol.EnsureNotNull() }, from, into, timeFrame)
: this([symbol.EnsureNotNull()], from, into, timeFrame)
{
}

Expand All @@ -39,7 +39,7 @@ public HistoricalCryptoBarsRequest(
String symbol,
BarTimeFrame timeFrame,
Interval<DateTime> timeInterval)
: this(new[] { symbol.EnsureNotNull() }, timeInterval, timeFrame)
: this([symbol.EnsureNotNull()], timeInterval, timeFrame)
{
}

Expand All @@ -54,7 +54,7 @@ public HistoricalCryptoBarsRequest(
public HistoricalCryptoBarsRequest(
String symbol,
BarTimeFrame timeFrame)
: this(new[] { symbol.EnsureNotNull() }, timeFrame)
: this([symbol.EnsureNotNull()], timeFrame)
{
}

Expand Down Expand Up @@ -121,7 +121,7 @@ public HistoricalCryptoBarsRequest(
String symbol,
BarTimeFrame timeFrame,
IInclusiveTimeInterval timeInterval)
: this(new[] { symbol.EnsureNotNull() }, timeInterval, timeFrame)
: this([symbol.EnsureNotNull()], timeInterval, timeFrame)
{
}

Expand Down
8 changes: 4 additions & 4 deletions Alpaca.Markets/Parameters/HistoricalCryptoQuotesRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public HistoricalCryptoQuotesRequest(
String symbol,
DateTime from,
DateTime into)
: this(new[] { symbol.EnsureNotNull() }, from, into)
: this([symbol.EnsureNotNull()], from, into)
{
}

Expand All @@ -36,7 +36,7 @@ public HistoricalCryptoQuotesRequest(
public HistoricalCryptoQuotesRequest(
String symbol,
Interval<DateTime> timeInterval)
: this(new[] { symbol.EnsureNotNull() }, timeInterval)
: this([symbol.EnsureNotNull()], timeInterval)
{
}

Expand All @@ -49,7 +49,7 @@ public HistoricalCryptoQuotesRequest(
/// </exception>
public HistoricalCryptoQuotesRequest(
String symbol)
: this(new[] { symbol.EnsureNotNull() })
: this([symbol.EnsureNotNull()])
{
}

Expand Down Expand Up @@ -111,7 +111,7 @@ public HistoricalCryptoQuotesRequest(
public HistoricalCryptoQuotesRequest(
String symbol,
IInclusiveTimeInterval timeInterval)
: this(new[] { symbol.EnsureNotNull() }, timeInterval)
: this([symbol.EnsureNotNull()], timeInterval)
{
}

Expand Down
8 changes: 4 additions & 4 deletions Alpaca.Markets/Parameters/HistoricalCryptoTradesRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public HistoricalCryptoTradesRequest(
String symbol,
DateTime from,
DateTime into)
: this(new[] { symbol.EnsureNotNull() }, from, into)
: this([symbol.EnsureNotNull()], from, into)
{
}

Expand All @@ -36,7 +36,7 @@ public HistoricalCryptoTradesRequest(
public HistoricalCryptoTradesRequest(
String symbol,
Interval<DateTime> timeInterval)
: this(new[] { symbol.EnsureNotNull() }, timeInterval)
: this([symbol.EnsureNotNull()], timeInterval)
{
}

Expand All @@ -49,7 +49,7 @@ public HistoricalCryptoTradesRequest(
/// </exception>
public HistoricalCryptoTradesRequest(
String symbol)
: this(new[] { symbol.EnsureNotNull() })
: this([symbol.EnsureNotNull()])
{
}

Expand Down Expand Up @@ -111,7 +111,7 @@ public HistoricalCryptoTradesRequest(
public HistoricalCryptoTradesRequest(
String symbol,
IInclusiveTimeInterval timeInterval)
: this(new[] { symbol.EnsureNotNull() }, timeInterval)
: this([symbol.EnsureNotNull()], timeInterval)
{
}

Expand Down
6 changes: 3 additions & 3 deletions Alpaca.Markets/Parameters/HistoricalOptionTradesRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public HistoricalOptionTradesRequest(
String symbol,
DateTime from,
DateTime into)
: this(new[] { symbol.EnsureNotNull() }, from, into)
: this([symbol.EnsureNotNull()], from, into)
{
}

Expand All @@ -36,7 +36,7 @@ public HistoricalOptionTradesRequest(
public HistoricalOptionTradesRequest(
String symbol,
Interval<DateTime> timeInterval)
: this(new[] { symbol.EnsureNotNull() }, timeInterval)
: this([symbol.EnsureNotNull()], timeInterval)
{
}

Expand All @@ -49,7 +49,7 @@ public HistoricalOptionTradesRequest(
/// </exception>
public HistoricalOptionTradesRequest(
String symbol)
: this(new[] { symbol.EnsureNotNull() })
: this([symbol.EnsureNotNull()])
{
}

Expand Down
8 changes: 4 additions & 4 deletions Alpaca.Markets/Parameters/HistoricalQuotesRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public HistoricalQuotesRequest(
String symbol,
DateTime from,
DateTime into)
: this(new[] { symbol.EnsureNotNull() }, from, into)
: this([symbol.EnsureNotNull()], from, into)
{
}

Expand All @@ -36,7 +36,7 @@ public HistoricalQuotesRequest(
public HistoricalQuotesRequest(
String symbol,
Interval<DateTime> timeInterval)
: this(new[] { symbol.EnsureNotNull() }, timeInterval)
: this([symbol.EnsureNotNull()], timeInterval)
{
}

Expand All @@ -49,7 +49,7 @@ public HistoricalQuotesRequest(
/// </exception>
public HistoricalQuotesRequest(
String symbol)
: this(new[] { symbol.EnsureNotNull() })
: this([symbol.EnsureNotNull()])
{
}

Expand Down Expand Up @@ -111,7 +111,7 @@ public HistoricalQuotesRequest(
public HistoricalQuotesRequest(
String symbol,
IInclusiveTimeInterval timeInterval)
: this(new[] { symbol.EnsureNotNull() }, timeInterval)
: this([symbol.EnsureNotNull()], timeInterval)
{
}

Expand Down
8 changes: 4 additions & 4 deletions Alpaca.Markets/Parameters/HistoricalTradesRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public HistoricalTradesRequest(
String symbol,
DateTime from,
DateTime into)
: this(new[] { symbol.EnsureNotNull() }, from, into)
: this([symbol.EnsureNotNull()], from, into)
{
}

Expand All @@ -36,7 +36,7 @@ public HistoricalTradesRequest(
public HistoricalTradesRequest(
String symbol,
Interval<DateTime> timeInterval)
: this(new[] { symbol.EnsureNotNull() }, timeInterval)
: this([symbol.EnsureNotNull()], timeInterval)
{
}

Expand All @@ -49,7 +49,7 @@ public HistoricalTradesRequest(
/// </exception>
public HistoricalTradesRequest(
String symbol)
: this(new[] { symbol.EnsureNotNull() })
: this([symbol.EnsureNotNull()])
{
}

Expand Down Expand Up @@ -111,7 +111,7 @@ public HistoricalTradesRequest(
public HistoricalTradesRequest(
String symbol,
IInclusiveTimeInterval timeInterval)
: this(new[] { symbol.EnsureNotNull() }, timeInterval)
: this([symbol.EnsureNotNull()], timeInterval)
{
}

Expand Down
12 changes: 8 additions & 4 deletions Alpaca.Markets/Throttling/ThrottleParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,16 @@ public ThrottleParameters(
IEnumerable<HttpStatusCode> retryHttpStatuses)
{
MaxRetryAttempts = maxRetryAttempts;
_retrySocketErrorCodes = new HashSet<SocketError>(
_retrySocketErrorCodes =
[
// ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract
retrySocketErrorCodes ?? _defaultSocketErrorCodes);
_retryHttpStatuses = new HashSet<HttpStatusCode>(
..retrySocketErrorCodes ?? _defaultSocketErrorCodes
];
_retryHttpStatuses =
[
// ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract
retryHttpStatuses ?? _defaultHttpStatuses);
..retryHttpStatuses ?? _defaultHttpStatuses
];
}

/// <summary>
Expand Down

0 comments on commit d7d2d43

Please sign in to comment.