Add `Meziantou.Analyzers` NuGet package

This commit is contained in:
YoshiRulz 2022-07-13 22:29:29 +10:00
parent 6077bcf5af
commit 0405e6399d
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
3 changed files with 331 additions and 0 deletions

View File

@ -78,6 +78,334 @@
<!-- Use UTC time -->
<Rule Id="MEN013" Action="Hidden" />
</Rules>
<Rules AnalyzerId="Meziantou.Analyzers" RuleNamespace="Meziantou.Analyzers">
<!-- StringComparison is missing -->
<Rule Id="MA0001" Action="Hidden" />
<!-- IEqualityComparer<string> or IComparer<string> is missing -->
<Rule Id="MA0002" Action="Hidden" />
<!-- Add parameter name to improve readability -->
<Rule Id="MA0003" Action="Hidden" />
<!-- Use Task.ConfigureAwait(false) -->
<Rule Id="MA0004" Action="Hidden" />
<!-- Use Array.Empty<T>() -->
<Rule Id="MA0005" Action="Hidden" />
<!-- Use String.Equals instead of equality operator -->
<Rule Id="MA0006" Action="Hidden" />
<!-- Add a comma after the last value -->
<Rule Id="MA0007" Action="Hidden" />
<!-- Add StructLayoutAttribute -->
<Rule Id="MA0008" Action="Hidden" />
<!-- Add regex evaluation timeout -->
<Rule Id="MA0009" Action="Hidden" />
<!-- Mark attributes with AttributeUsageAttribute -->
<Rule Id="MA0010" Action="Error" />
<!-- IFormatProvider is missing -->
<Rule Id="MA0011" Action="Hidden" />
<!-- Do not raise reserved exception type -->
<Rule Id="MA0012" Action="Hidden" />
<!-- Types should not extend System.ApplicationException -->
<Rule Id="MA0013" Action="Error" />
<!-- Do not raise System.ApplicationException type -->
<Rule Id="MA0014" Action="Hidden" />
<!-- Specify the parameter name in ArgumentException -->
<Rule Id="MA0015" Action="Hidden" />
<!-- Prefer returning collection abstraction instead of implementation -->
<Rule Id="MA0016" Action="Hidden" />
<!-- Abstract types should not have public or internal constructors -->
<Rule Id="MA0017" Action="Hidden" />
<!-- Do not declare static members on generic types -->
<Rule Id="MA0018" Action="Error" />
<!-- Use EventArgs.Empty -->
<Rule Id="MA0019" Action="Hidden" />
<!-- Use direct methods instead of LINQ methods -->
<Rule Id="MA0020" Action="Hidden" />
<!-- Use StringComparer.GetHashCode instead of string.GetHashCode -->
<Rule Id="MA0021" Action="Hidden" />
<!-- Return Task.FromResult instead of returning null -->
<Rule Id="MA0022" Action="Error" />
<!-- Add RegexOptions.ExplicitCapture -->
<Rule Id="MA0023" Action="Hidden" />
<!-- Use an explicit StringComparer when possible -->
<Rule Id="MA0024" Action="Error" />
<!-- Implement the functionality instead of throwing NotImplementedException -->
<Rule Id="MA0025" Action="Hidden" />
<!-- Fix TODO comment -->
<Rule Id="MA0026" Action="Hidden" />
<!-- Do not remove original exception -->
<Rule Id="MA0027" Action="Error" />
<!-- Optimize StringBuilder usage -->
<Rule Id="MA0028" Action="Hidden" />
<!-- Combine LINQ methods -->
<Rule Id="MA0029" Action="Hidden" />
<!-- Remove useless OrderBy call -->
<Rule Id="MA0030" Action="Error" />
<!-- Optimize Enumerable.Count() usage -->
<Rule Id="MA0031" Action="Hidden" />
<!-- Use an overload with a CancellationToken argument -->
<Rule Id="MA0032" Action="Hidden" />
<!-- Do not tag instance fields with ThreadStaticAttribute -->
<Rule Id="MA0033" Action="Error" />
<!-- Do not use dangerous threading methods -->
<Rule Id="MA0035" Action="Error" />
<!-- Make class static -->
<Rule Id="MA0036" Action="Hidden" />
<!-- Remove empty statement -->
<Rule Id="MA0037" Action="Error" />
<!-- Make method static -->
<Rule Id="MA0038" Action="Hidden" />
<!-- Do not write your own certificate validation method -->
<Rule Id="MA0039" Action="Error" />
<!-- Flow the cancellation token -->
<Rule Id="MA0040" Action="Hidden" />
<!-- Make property static -->
<Rule Id="MA0041" Action="Hidden" />
<!-- Do not use blocking calls in an async method -->
<Rule Id="MA0042" Action="Error" />
<!-- Use nameof operator in ArgumentException -->
<Rule Id="MA0043" Action="Hidden" />
<!-- Remove useless ToString call -->
<Rule Id="MA0044" Action="Hidden" />
<!-- Do not use blocking call in a sync method (need to make containing method async) -->
<Rule Id="MA0045" Action="Hidden" />
<!-- Use EventHandler<T> to declare events -->
<Rule Id="MA0046" Action="Hidden" />
<!-- Declare types in namespaces -->
<Rule Id="MA0047" Action="Error" />
<!-- File name must match type name -->
<Rule Id="MA0048" Action="Hidden" />
<!-- Type name should not match containing namespace -->
<Rule Id="MA0049" Action="Hidden" />
<!-- Validate arguments correctly in iterator methods -->
<Rule Id="MA0050" Action="Error" />
<!-- Method is too long -->
<Rule Id="MA0051" Action="Hidden" />
<!-- Replace constant Enum.ToString with nameof -->
<Rule Id="MA0052" Action="Hidden" />
<!-- Make class sealed -->
<Rule Id="MA0053" Action="Hidden" />
<!-- Embed the caught exception as innerException -->
<Rule Id="MA0054" Action="Hidden" />
<!-- Do not use finalizer -->
<Rule Id="MA0055" Action="Hidden" />
<!-- Do not call overridable members in constructor -->
<Rule Id="MA0056" Action="Hidden" />
<!-- Class name should end with 'Attribute' -->
<Rule Id="MA0057" Action="Hidden" />
<!-- Class name should end with 'Exception' -->
<Rule Id="MA0058" Action="Error" />
<!-- Class name should end with 'EventArgs' -->
<Rule Id="MA0059" Action="Hidden" />
<!-- The value returned by Stream.Read/Stream.ReadAsync is not used -->
<Rule Id="MA0060" Action="Hidden" />
<!-- Method overrides should not change parameter defaults -->
<Rule Id="MA0061" Action="Hidden" />
<!-- Non-flags enums should not be marked with "FlagsAttribute" -->
<Rule Id="MA0062" Action="Hidden" />
<!-- Use Where before OrderBy -->
<Rule Id="MA0063" Action="Error" />
<!-- Avoid locking on publicly accessible instance -->
<Rule Id="MA0064" Action="Hidden" />
<!-- Default ValueType.Equals or HashCode is used for struct's equality -->
<Rule Id="MA0065" Action="Error" />
<!-- Hash table unfriendly type is used in a hash table -->
<Rule Id="MA0066" Action="Hidden" />
<!-- Use Guid.Empty -->
<Rule Id="MA0067" Action="Error" />
<!-- Invalid parameter name for nullable attribute -->
<Rule Id="MA0068" Action="Error" />
<!-- Non-constant static fields should not be visible -->
<Rule Id="MA0069" Action="Hidden" />
<!-- Obsolete attributes should include explanations -->
<Rule Id="MA0070" Action="Hidden" />
<!-- Avoid using redundant else -->
<Rule Id="MA0071" Action="Hidden" />
<!-- Do not throw from a finally block -->
<Rule Id="MA0072" Action="Error" />
<!-- Avoid comparison with bool constant -->
<Rule Id="MA0073" Action="Hidden" />
<!-- Avoid implicit culture-sensitive methods -->
<Rule Id="MA0074" Action="Hidden" />
<!-- Do not use implicit culture-sensitive ToString -->
<Rule Id="MA0075" Action="Hidden" />
<!-- Do not use implicit culture-sensitive ToString in interpolated strings -->
<Rule Id="MA0076" Action="Hidden" />
<!-- A class that provides Equals(T) should implement IEquatable<T> -->
<Rule Id="MA0077" Action="Error" />
<!-- Use 'Cast' instead of 'Select' to cast -->
<Rule Id="MA0078" Action="Hidden" />
<!-- Flow the cancellation token using .WithCancellation() -->
<Rule Id="MA0079" Action="Error" />
<!-- Use a cancellation token using .WithCancellation() -->
<Rule Id="MA0080" Action="Error" />
<!-- Method overrides should not omit params keyword -->
<Rule Id="MA0081" Action="Error" />
<!-- NaN should not be used in comparisons -->
<Rule Id="MA0082" Action="Error" />
<!-- ConstructorArgument parameters should exist in constructors -->
<Rule Id="MA0083" Action="Error" />
<!-- Local variable should not hide other symbols -->
<Rule Id="MA0084" Action="Hidden" />
<!-- Anonymous delegates should not be used to unsubscribe from Events -->
<Rule Id="MA0085" Action="Error" />
<!-- Do not throw from a finalizer -->
<Rule Id="MA0086" Action="Error" />
<!-- Parameters with [DefaultParameterValue] attributes should also be marked [Optional] -->
<Rule Id="MA0087" Action="Error" />
<!-- Use [DefaultParameterValue] instead of [DefaultValue] -->
<Rule Id="MA0088" Action="Error" />
<!-- Optimize string method usage -->
<Rule Id="MA0089" Action="Error" />
<!-- Remove empty else/finally block -->
<Rule Id="MA0090" Action="Hidden" />
<!-- Sender should be 'this' for instance events -->
<Rule Id="MA0091" Action="Hidden" />
<!-- Sender should be 'null' for static events -->
<Rule Id="MA0092" Action="Error" />
<!-- EventArgs should not be null -->
<Rule Id="MA0093" Action="Error" />
<!-- A class that provides CompareTo(T) should implement IComparable<T> -->
<Rule Id="MA0094" Action="Error" />
<!-- A class that implements IEquatable<T> should override Equals(object) -->
<Rule Id="MA0095" Action="Error" />
<!-- A class that implements IComparable<T> should also implement IEquatable<T> -->
<Rule Id="MA0096" Action="Hidden" />
<!-- A class that implements IComparable<T> or IComparable should override comparison operators -->
<Rule Id="MA0097" Action="Hidden" />
<!-- Use indexer instead of LINQ methods -->
<Rule Id="MA0098" Action="Hidden" />
<!-- Use Explicit enum value instead of 0 -->
<Rule Id="MA0099" Action="Hidden" />
<!-- Await task before disposing of resources -->
<Rule Id="MA0100" Action="Error" />
<!-- String contains an implicit end of line character -->
<Rule Id="MA0101" Action="Hidden" />
<!-- Make member readonly -->
<Rule Id="MA0102" Action="Hidden" />
<!-- Use SequenceEqual instead of equality operator -->
<Rule Id="MA0103" Action="Error" />
<!-- Do not create a type with a name from the BCL -->
<Rule Id="MA0104" Action="Hidden" />
<!-- Use the lambda parameters instead of using a closure -->
<Rule Id="MA0105" Action="Error" />
<!-- Avoid closure by using an overload with the 'factoryArgument' parameter -->
<Rule Id="MA0106" Action="Error" />
<!-- Do not use culture-sensitive object.ToString -->
<Rule Id="MA0107" Action="Hidden" />
<!-- Remove redundant argument value -->
<Rule Id="MA0108" Action="Error" />
<!-- Consider adding an overload with a Span<T> or Memory<T> -->
<Rule Id="MA0109" Action="Hidden" />
<!-- Use the Regex source generator -->
<Rule Id="MA0110" Action="Error" />
</Rules>
<Rules AnalyzerId="Microsoft.CodeAnalysis.FxCopAnalyzers" RuleNamespace="Microsoft.CodeAnalysis.FxCopAnalyzers">
<!-- Types that own disposable fields should be disposable -->
<Rule Id="CA1001" Action="Hidden" />

View File

@ -13,6 +13,7 @@
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
<PackageReference Include="DotNetAnalyzers.DocumentationAnalyzers" Version="1.0.0-beta.59" />
<PackageReference Include="Menees.Analyzers" Version="2.0.4" Condition=" '$(MachineRunAnalyzersDuringBuild)' != '' " />
<PackageReference Include="Meziantou.Analyzer" Version="1.0.704" Condition=" '$(MachineRunAnalyzersDuringBuild)' != '' "/>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.333" Condition=" '$(MachineRunAnalyzersDuringBuild)' != '' " />
</ItemGroup>
<ItemGroup>

View File

@ -26,10 +26,12 @@ namespace BizHawk.Tests.Common.MultiPredicateSort
SortedByYDescThenXDesc,
Unsorted.OrderByDescending(t => t.Y).ThenByDescending(t => t.X)
);
#pragma warning disable MA0030
AssertSequenceEqual(
SortedByYDescThenXDesc,
Unsorted.OrderByDescending(t => t.X).OrderByDescending(t => t.Y)
);
#pragma warning restore MA0030
}
[TestMethod]