mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-01-31 09:09:00 +03:00
Add code analysis to prohibit using bad methods and properties (#70)
This PR adds the package `Microsoft.CodeAnalysis.BannedApiAnalyzers` to scan for banned code (defined by `CodeAnalysis/BannedSymbols.txt`) and provide warnings if it is used. The list of banned symbols is borrowed from osu! and other projects Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
7b722a45cb
commit
397bb83ba8
2 changed files with 23 additions and 0 deletions
|
@ -22,6 +22,7 @@
|
||||||
<PackageReference Include="DiffPlex" Version="1.7.1"/>
|
<PackageReference Include="DiffPlex" Version="1.7.1"/>
|
||||||
<PackageReference Include="Humanizer.Core.ru" Version="2.14.1"/>
|
<PackageReference Include="Humanizer.Core.ru" Version="2.14.1"/>
|
||||||
<PackageReference Include="JetBrains.Annotations" Version="2023.2.0"/>
|
<PackageReference Include="JetBrains.Annotations" Version="2023.2.0"/>
|
||||||
|
<PackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.4"/>
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1"/>
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1"/>
|
||||||
<PackageReference Include="Remora.Discord.Caching" Version="37.0.0"/>
|
<PackageReference Include="Remora.Discord.Caching" Version="37.0.0"/>
|
||||||
<PackageReference Include="Remora.Discord.Extensions" Version="5.3.2"/>
|
<PackageReference Include="Remora.Discord.Extensions" Version="5.3.2"/>
|
||||||
|
@ -34,4 +35,7 @@
|
||||||
<LastGenOutput>Messages.Designer.cs</LastGenOutput>
|
<LastGenOutput>Messages.Designer.cs</LastGenOutput>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<AdditionalFiles Include="CodeAnalysis\BannedSymbols.txt"/>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
19
CodeAnalysis/BannedSymbols.txt
Normal file
19
CodeAnalysis/BannedSymbols.txt
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
M:System.Object.Equals(System.Object)~System.Boolean;Don't use object.Equals. Use IEquatable<T> or EqualityComparer<T>.Default instead.
|
||||||
|
M:System.ValueType.Equals(System.Object)~System.Boolean;Don't use object.Equals(Fallbacks to ValueType). Use IEquatable<T> or EqualityComparer<T>.Default instead.
|
||||||
|
M:System.Nullable`1.Equals(System.Object)~System.Boolean;Use == instead.
|
||||||
|
T:System.IComparable;Don't use non-generic IComparable. Use generic version instead.
|
||||||
|
M:System.Guid.#ctor;Probably meaning to use Guid.NewGuid() instead. If actually wanting empty, use Guid.Empty.
|
||||||
|
M:System.Threading.Tasks.Task.Wait();Don't use Task.Wait.
|
||||||
|
P:System.Threading.Tasks.Task`1.Result;Don't use Task.Result.
|
||||||
|
M:System.Threading.ManualResetEventSlim.Wait();Specify a timeout to avoid waiting forever.
|
||||||
|
M:System.Char.ToLower(System.Char);char.ToLower() changes behaviour depending on CultureInfo.CurrentCulture. Use char.ToLowerInvariant() instead. If wanting culture-sensitive behaviour, explicitly provide CultureInfo.CurrentCulture.
|
||||||
|
M:System.Char.ToUpper(System.Char);char.ToUpper() changes behaviour depending on CultureInfo.CurrentCulture. Use char.ToUpperInvariant() instead. If wanting culture-sensitive behaviour, explicitly provide CultureInfo.CurrentCulture.
|
||||||
|
M:System.String.ToLower();string.ToLower() changes behaviour depending on CultureInfo.CurrentCulture. Use string.ToLowerInvariant() instead. If wanting culture-sensitive behaviour, explicitly provide CultureInfo.CurrentCulture or use LocalisableString.
|
||||||
|
M:System.String.ToUpper();string.ToUpper() changes behaviour depending on CultureInfo.CurrentCulture. Use string.ToUpperInvariant() instead. If wanting culture-sensitive behaviour, explicitly provide CultureInfo.CurrentCulture or use LocalisableString.
|
||||||
|
M:Humanizer.InflectorExtensions.Pascalize(System.String);Humanizer's .Pascalize() extension method changes behaviour depending on CultureInfo.CurrentCulture. Use StringDehumanizeExtensions.ToPascalCase() instead.
|
||||||
|
M:Humanizer.InflectorExtensions.Camelize(System.String);Humanizer's .Camelize() extension method changes behaviour depending on CultureInfo.CurrentCulture. Use StringDehumanizeExtensions.ToCamelCase() instead.
|
||||||
|
M:Humanizer.InflectorExtensions.Underscore(System.String);Humanizer's .Underscore() extension method changes behaviour depending on CultureInfo.CurrentCulture. Use StringDehumanizeExtensions.ToSnakeCase() instead.
|
||||||
|
M:Humanizer.InflectorExtensions.Kebaberize(System.String);Humanizer's .Kebaberize() extension method changes behaviour depending on CultureInfo.CurrentCulture. Use StringDehumanizeExtensions.ToKebabCase() instead.
|
||||||
|
P:System.DateTime.Now;Use System.DateTime.UtcNow instead.
|
||||||
|
P:System.DateTimeOffset.Now;Use System.DateTimeOffset.UtcNow instead.
|
||||||
|
P:System.DateTimeOffset.DateTime;Use System.DateTimeOffset.UtcDateTime instead.
|
Loading…
Reference in a new issue