mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-01 17:07:10 +01:00
Code analysis (#4293)
* Enable NETAnalyzers for whole project - remove obsolete analyzers so that the .NET Core SDK NETAnalyzers can be used - enable NETAnalyzers for all projects so that developers can use them by defining the AnalysisMode on individual projects This is because if we set AnalysisMode to minimal, recommended or all it would spam with warning. The idea is to be able to turn them on during development to fix recommended stuff without polluting the build output. Following commits will implement some of the Code Analysis findings * Performance hints for using char overloads for single characters (CA1834 and CA1847) CA1834: Use StringBuilder.Append(char) for single character strings CA1847: Use string.Contains(char) instead of string.Contains(string) with single characters
This commit is contained in:
parent
1e2acfb296
commit
ec76acd3a6
7 changed files with 7 additions and 14 deletions
|
@ -180,7 +180,7 @@ namespace BTCPayServer.Logging
|
||||||
logBuilder.Append(": ");
|
logBuilder.Append(": ");
|
||||||
var lenAfter = logBuilder.ToString().Length;
|
var lenAfter = logBuilder.ToString().Length;
|
||||||
while (lenAfter++ < 18)
|
while (lenAfter++ < 18)
|
||||||
logBuilder.Append(" ");
|
logBuilder.Append(' ');
|
||||||
// scope information
|
// scope information
|
||||||
GetScopeInformation(logBuilder);
|
GetScopeInformation(logBuilder);
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,7 @@ namespace BTCPayServer.Services.Rates
|
||||||
sb.Append(url);
|
sb.Append(url);
|
||||||
if (payload != null)
|
if (payload != null)
|
||||||
{
|
{
|
||||||
sb.Append("?");
|
sb.Append('?');
|
||||||
sb.Append(String.Join('&', payload.Select(kv => $"{kv.Key}={kv.Value}").OfType<object>().ToArray()));
|
sb.Append(String.Join('&', payload.Select(kv => $"{kv.Key}={kv.Value}").OfType<object>().ToArray()));
|
||||||
}
|
}
|
||||||
var request = new HttpRequestMessage(HttpMethod.Get, sb.ToString());
|
var request = new HttpRequestMessage(HttpMethod.Get, sb.ToString());
|
||||||
|
|
|
@ -54,11 +54,6 @@
|
||||||
<PackageReference Include="LNURL" Version="0.0.24" />
|
<PackageReference Include="LNURL" Version="0.0.24" />
|
||||||
<PackageReference Include="MailKit" Version="3.3.0" />
|
<PackageReference Include="MailKit" Version="3.3.0" />
|
||||||
<PackageReference Include="McMaster.NETCore.Plugins.Mvc" Version="1.4.0" />
|
<PackageReference Include="McMaster.NETCore.Plugins.Mvc" Version="1.4.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Filter" Version="1.1.2" />
|
|
||||||
<PackageReference Include="Microsoft.NetCore.Analyzers" Version="3.3.2">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
<PackageReference Include="QRCoder" Version="1.4.3" />
|
<PackageReference Include="QRCoder" Version="1.4.3" />
|
||||||
<PackageReference Include="System.IO.Pipelines" Version="6.0.3" />
|
<PackageReference Include="System.IO.Pipelines" Version="6.0.3" />
|
||||||
<PackageReference Include="NBitpayClient" Version="1.0.0.39" />
|
<PackageReference Include="NBitpayClient" Version="1.0.0.39" />
|
||||||
|
@ -70,10 +65,6 @@
|
||||||
<PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
|
<PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
|
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
|
||||||
<PackageReference Include="SSH.NET" Version="2020.0.2" />
|
<PackageReference Include="SSH.NET" Version="2020.0.2" />
|
||||||
<PackageReference Include="Text.Analyzers" Version="3.3.3">
|
|
||||||
<PrivateAssets>all</PrivateAssets>
|
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
|
||||||
</PackageReference>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -105,7 +105,7 @@ namespace BTCPayServer.Filters
|
||||||
{
|
{
|
||||||
hasSelf = group.Any(g => g.Value.Contains("'self'", StringComparison.OrdinalIgnoreCase));
|
hasSelf = group.Any(g => g.Value.Contains("'self'", StringComparison.OrdinalIgnoreCase));
|
||||||
if (!hasSelf && !group.Any(g => g.Value.Contains("'none'", StringComparison.OrdinalIgnoreCase) ||
|
if (!hasSelf && !group.Any(g => g.Value.Contains("'none'", StringComparison.OrdinalIgnoreCase) ||
|
||||||
g.Value.Contains("*", StringComparison.OrdinalIgnoreCase)))
|
g.Value.Contains('*', StringComparison.OrdinalIgnoreCase)))
|
||||||
{
|
{
|
||||||
policies.Add(new ConsentSecurityPolicy(group.Key, "'self'"));
|
policies.Add(new ConsentSecurityPolicy(group.Key, "'self'"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace BTCPayServer.Plugins.Shopify.Models
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return ShopName?.Contains(".", StringComparison.OrdinalIgnoreCase) is true ? ShopName : $"https://{ShopName}.myshopify.com";
|
return ShopName?.Contains('.', StringComparison.OrdinalIgnoreCase) is true ? ShopName : $"https://{ShopName}.myshopify.com";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace BTCPayServer.Plugins.Shopify
|
||||||
string relativeUrl = null)
|
string relativeUrl = null)
|
||||||
{
|
{
|
||||||
var url =
|
var url =
|
||||||
$"https://{(shopName.Contains(".", StringComparison.InvariantCulture) ? shopName : $"{shopName}.myshopify.com")}/{relativeUrl ?? ("admin/api/2020-07/" + action)}";
|
$"https://{(shopName.Contains('.', StringComparison.InvariantCulture) ? shopName : $"{shopName}.myshopify.com")}/{relativeUrl ?? ("admin/api/2020-07/" + action)}";
|
||||||
var req = new HttpRequestMessage(method, url);
|
var req = new HttpRequestMessage(method, url);
|
||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
<TargetFramework Condition="'$(TargetFrameworkOverride)' != ''">$(TargetFrameworkOverride)</TargetFramework>
|
<TargetFramework Condition="'$(TargetFrameworkOverride)' != ''">$(TargetFrameworkOverride)</TargetFramework>
|
||||||
<NoWarn>NU1701,CA1816,CA1308,CA1810,CA2208,CA1303,CA2000,CA2016,CA1835,CA2249,CA9998,CA1704</NoWarn>
|
<NoWarn>NU1701,CA1816,CA1308,CA1810,CA2208,CA1303,CA2000,CA2016,CA1835,CA2249,CA9998,CA1704</NoWarn>
|
||||||
<LangVersion>10.0</LangVersion>
|
<LangVersion>10.0</LangVersion>
|
||||||
|
<EnableNETAnalyzers>True</EnableNETAnalyzers>
|
||||||
|
<AnalysisLevel>6.0</AnalysisLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|
Loading…
Add table
Reference in a new issue