Skip to content

RalfKoban/MiKo-Analyzers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MiKo-Analyzers

Provides analyzers that are based on the .NET Compiler Platform (Roslyn) and can be used inside Visual Studio 2019 (v16.11) or 2022 (v17.14).

How to install an Roslyn analyzer is described here.

Screenshots on how to use such analyzers can be found here.

Build / Project status

Maintenance Build status codecov Coverity Scan Build Status

Available Rules

The following tables lists all the 527 rules that are currently provided by the analyzer.

Metrics

ID Title Enabled by default CodeFix available
MiKo_0001 Keep methods small -
MiKo_0002 Simplify complex methods -
MiKo_0003 Keep types small -
MiKo_0004 Limit method parameters -
MiKo_0005 Keep local functions small -
MiKo_0006 Simplify complex local functions -
MiKo_0007 Limit local function parameters -

Naming

ID Title Enabled by default CodeFix available
MiKo_1000 Suffix 'System.EventArgs' types with 'EventArgs'
MiKo_1001 Name 'System.EventArgs' parameters 'e'
MiKo_1002 Follow .NET Framework Design Guidelines for event handler parameter names
MiKo_1003 Follow .NET Framework Design Guidelines for event handling method names
MiKo_1004 Remove term 'Event' from event names
MiKo_1005 Name 'System.EventArgs' variables properly
MiKo_1006 Use 'EventHandler<T>' with 'EventArgs' named after the event -
MiKo_1007 Place events and their 'EventArgs' types in the same namespace -
MiKo_1008 Follow .NET Framework Design Guidelines for DependencyProperty event handler parameter names
MiKo_1009 Name 'System.EventHandler' variables properly
MiKo_1010 Do not include 'CanExecute' or 'Execute' in method names
MiKo_1011 Do not include 'Do' in method names
MiKo_1012 Use 'Raise' instead of 'Fire' in method names
MiKo_1013 Do not name methods 'Notify' or 'OnNotify'
MiKo_1014 Do not use ambiguous 'Check' in method names
MiKo_1015 Use 'Initialize' instead of 'Init' in method names
MiKo_1016 Name factory methods 'Create'
MiKo_1017 Do not prefix methods with 'Get' or 'Set' when followed by 'Is', 'Can' or 'Has'
MiKo_1018 Do not suffix methods with noun of a verb
MiKo_1019 Name 'Clear' and 'Remove' methods based on their number of parameters
MiKo_1020 Limit type name length - -
MiKo_1021 Limit method name length - -
MiKo_1022 Limit parameter name length - -
MiKo_1023 Limit field name length - -
MiKo_1024 Limit property name length - -
MiKo_1025 Limit event name length - -
MiKo_1026 Limit variable name length - -
MiKo_1027 Limit loop variable name length - -
MiKo_1028 Limit local function name length - -
MiKo_1030 Do not mark base types with 'Abstract' or 'Base'
MiKo_1031 Do not suffix entity types with 'Model'
MiKo_1032 Do not use 'Model' as marker in methods dealing with entities
MiKo_1033 Do not suffix entity parameters with 'Model'
MiKo_1034 Do not suffix entity fields with 'Model'
MiKo_1035 Do not use 'Model' marker in properties dealing with entities
MiKo_1036 Do not use 'Model' marker in events dealing with entities
MiKo_1037 Do not suffix types with 'Type', 'Interface', 'Class', 'Struct', 'Record' or 'Enum'
MiKo_1038 Use consistent suffix for extension method container classes
MiKo_1039 Use default name for 'this' parameter of extension methods
MiKo_1040 Do not suffix parameters with implementation details
MiKo_1041 Do not suffix fields with implementation details
MiKo_1042 Use specific name for 'CancellationToken' parameters
MiKo_1043 Use specific name for 'CancellationToken' variables
MiKo_1044 Suffix commands with 'Command'
MiKo_1045 Do not suffix command-invoked methods with 'Command'
MiKo_1046 Follow Task-based Asynchronous Pattern (TAP) for asynchronous methods
MiKo_1047 Do not falsely indicate asynchronous behavior for methods not following Task-based Asynchronous Pattern (TAP)
MiKo_1048 End value converter classes with a specific suffix
MiKo_1049 Do not use requirement terms such as 'Shall', 'Should', 'Must' or 'Need' for names
MiKo_1050 Use descriptive names for return values
MiKo_1051 Do not suffix parameters with delegate types
MiKo_1052 Do not suffix variables with delegate types
MiKo_1053 Do not suffix fields with delegate types
MiKo_1054 Do not name types 'Helper' or 'Utility'
MiKo_1055 Suffix dependency properties with 'Property' (as in the .NET Framework)
MiKo_1056 Prefix dependency properties with property names (as in the .NET Framework)
MiKo_1057 Suffix dependency property keys with 'Key' (as in the .NET Framework)
MiKo_1058 Prefix dependency property keys with property names (as in the .NET Framework)
MiKo_1059 Do not name types 'Impl' or 'Implementation'
MiKo_1060 Use '<Entity>NotFound' instead of 'Get<Entity>Failed' or '<Entity>Missing'
MiKo_1061 Use specific name for 'Try' method's [out] parameters
MiKo_1062 Keep 'Can/Has/Contains' methods, properties or fields to a few words -
MiKo_1063 Do not use abbreviations in names
MiKo_1064 Make parameter names reflect their meaning, not their type -
MiKo_1065 Follow .NET Framework Design Guidelines for operator overload parameter names
MiKo_1066 Name constructor parameters after the property they're assigned to
MiKo_1067 Do not include 'Perform' in method names
MiKo_1068 Name workflow methods 'CanRun' or 'Run' -
MiKo_1069 Make property names reflect their meaning, not their type -
MiKo_1070 Use plural names for local collection variables
MiKo_1071 Name local boolean variables as statements, not questions -
MiKo_1072 Name boolean properties or methods as statements, not questions -
MiKo_1073 Name boolean fields as statements, not questions -
MiKo_1074 Suffix lock objects with 'Lock' -
MiKo_1075 Do not suffix non-'System.EventArgs' types with 'EventArgs'
MiKo_1076 Suffix Prism event types with 'Event'
MiKo_1077 Do not suffix enum members with 'Enum'
MiKo_1078 Start builder method names with 'Build'
MiKo_1079 Do not suffix repositories with 'Repository'
MiKo_1080 Use numbers instead of their spellings in names -
MiKo_1081 Do not suffix methods with a number
MiKo_1082 Do not suffix properties with a number if their types have number suffixes
MiKo_1083 Do not suffix fields with a number if their types have number suffixes
MiKo_1084 Do not suffix variables with a number if their types have number suffixes
MiKo_1085 Do not suffix parameters with a number
MiKo_1086 Do not use numbers as slang in method names -
MiKo_1087 Name constructor parameters after their base class counterparts
MiKo_1088 Name singleton instances 'Instance' -
MiKo_1089 Do not prefix methods with 'Get'
MiKo_1090 Do not suffix parameters with specific types
MiKo_1091 Do not suffix variables with specific types
MiKo_1092 Do not suffix 'Ability' types with redundant information
MiKo_1093 Do not use the suffix 'Object' or 'Struct'
MiKo_1094 Do not suffix types with passive namespace names -
MiKo_1095 Do not use 'Delete' and 'Remove' both in names and documentation -
MiKo_1096 Use 'Failed' instead of 'NotSuccessful' in names -
MiKo_1097 Do not use field naming schemes for parameter names
MiKo_1098 Reflect implemented business interface(s) in type names -
MiKo_1099 Use identical names for matching parameters on method overloads
MiKo_1100 Start test class names with the name of the type under test -
MiKo_1101 End test class names with 'Tests'
MiKo_1102 Do not include 'Test' in test method names
MiKo_1103 Name test initialization methods 'PrepareTest'
MiKo_1104 Name test cleanup methods 'CleanupTest'
MiKo_1105 Name one-time test initialization methods 'PrepareTestEnvironment'
MiKo_1106 Name one-time test cleanup methods 'CleanupTestEnvironment'
MiKo_1107 Do not use Pascal-casing for test methods
MiKo_1108 Do not name variables, parameters, fields and properties 'Mock', 'Stub', 'Fake' or 'Shim'
MiKo_1109 Prefix testable types with 'Testable' instead of using the 'Ut' suffix
MiKo_1110 Suffix test methods with parameters with underscore
MiKo_1111 Do not suffix parameterless test methods with underscore
MiKo_1112 Do not name test data 'arbitrary'
MiKo_1113 Do not use BDD style naming for test methods -
MiKo_1114 Do not name test methods 'HappyPath' or 'BadPath' -
MiKo_1115 Name test methods in a fluent way
MiKo_1116 Use present tense for test method names
MiKo_1117 Make test method names more precise -
MiKo_1118 Do not end test method names with 'Async'
MiKo_1200 Name catch block exceptions consistently
MiKo_1201 Name exception parameters consistently
MiKo_1300 Name unimportant lambda statement identifiers '_'
MiKo_1400 Use plural for namespace names -
MiKo_1401 Do not include technical language names in namespaces -
MiKo_1402 Do not name namespaces after WPF-specific design patterns -
MiKo_1403 Do not name namespaces after any of their parent namespaces -
MiKo_1404 Do not use unspecific names for namespaces -
MiKo_1405 Do not include 'Lib' in namespaces -
MiKo_1406 Place value converters in 'Converters' namespace -
MiKo_1407 Do not include 'Test' in test namespaces -
MiKo_1408 Place extension methods in same namespace as the extended types -
MiKo_1409 Do not prefix or suffix namespaces with underscores -
MiKo_1501 Do not use 'Filter' in names -
MiKo_1502 Do not use 'Process' in names -
MiKo_1503 Do not suffix methods with 'Counter'
MiKo_1504 Do not suffix properties with 'Counter'
MiKo_1505 Do not suffix fields with 'Counter'
MiKo_1506 Do not suffix local variables with 'Counter'
MiKo_1507 Do not suffix parameters with 'Counter'
MiKo_1508 Do not suffix local variables with pattern names
MiKo_1509 Do not suffix parameters with pattern names
MiKo_1510 Do not suffix fields with pattern names
MiKo_1511 Do not prefix or suffix local variables with 'proxy'
MiKo_1512 Do not prefix or suffix parameters with 'proxy'
MiKo_1513 Do not suffix types with 'Advanced', 'Complex', 'Enhanced', 'Extended', 'Simple' or 'Simplified'
MiKo_1514 Do not suffix types with 'Info' -
MiKo_1515 Express binary conditions clearly in boolean property names
MiKo_1516 Express binary conditions clearly in boolean parameter names
MiKo_1517 Express binary conditions clearly in boolean field names
MiKo_1518 Do not prefix or suffix local variables with 'reference'
MiKo_1519 Do not prefix or suffix parameters with 'reference'
MiKo_1520 Do not prefix or suffix local variables with 'toCopy'
MiKo_1521 Do not prefix or suffix parameters with 'toCopy'

Documentation

ID Title Enabled by default CodeFix available
MiKo_2000 Write valid XML documentation
MiKo_2001 Document events properly
MiKo_2002 Document EventArgs properly
MiKo_2003 Start event handler documentation with default phrase
MiKo_2004 Follow .NET Framework Design Guidelines for event handler parameter names in documentation
MiKo_2005 Document textual references to EventArgs properly -
MiKo_2006 Document routed events as done by the .NET Framework
MiKo_2010 Document sealed classes as being sealed
MiKo_2011 Do not falsely document unsealed classes as sealed
MiKo_2012 Describe the type's responsibility in <summary> documentation
MiKo_2013 Start Enum <summary> documentation with default phrase
MiKo_2014 Document Dispose methods as done by the .NET Framework
MiKo_2015 Use 'raise' or 'throw' instead of 'fire' in documentation
MiKo_2016 Start documentation for asynchronous methods with specific phrase
MiKo_2017 Document dependency properties as done by the .NET Framework
MiKo_2018 Do not use ambiguous terms 'Check' or 'Test' in documentation
MiKo_2019 Start <summary> documentation with third person singular verb (e.g., "Provides")
MiKo_2020 Use <inheritdoc /> marker for inherited documentation
MiKo_2021 Start parameter documentation with default phrase
MiKo_2022 Start [out] parameter documentation with default phrase
MiKo_2023 Start Boolean parameter documentation with default phrase
MiKo_2024 Start Enum parameter documentation with default phrase
MiKo_2025 Start 'CancellationToken' parameter documentation with default phrase
MiKo_2026 Do not document used parameters as unused -
MiKo_2027 Document serialization constructor parameters with specific phrase
MiKo_2028 Provide more information than just parameter name in documentation -
MiKo_2029 Do not use self-referencing 'cref' in <inheritdoc> documentation
MiKo_2030 Start return value documentation with default phrase -
MiKo_2031 Use specific (starting) phrase for Task return value documentation
MiKo_2032 Use specific phrase for Boolean return value documentation
MiKo_2033 Start String return value documentation with default phrase
MiKo_2034 Start Enum return value documentation with default phrase
MiKo_2035 Start collection return value documentation with default phrase
MiKo_2036 Describe default values in Boolean or Enum property documentation
MiKo_2037 Start command property <summary> documentation with default phrase
MiKo_2038 Start command <summary> documentation with default phrase
MiKo_2039 Start extension method class <summary> documentation with default phrase
MiKo_2040 Use <see langword="..."/> instead of <c>...</c>
MiKo_2041 Do not include other documentation tags in <summary> documentation
MiKo_2042 Use '<para>' XML tags instead of '<p>' HTML tags in documentation
MiKo_2043 Start custom delegate <summary> documentation with default phrase
MiKo_2044 Reference method parameters correctly in documentation
MiKo_2045 Do not reference parameters in <summary> documentation
MiKo_2046 Reference type parameters correctly in documentation
MiKo_2047 Start Attribute <summary> documentation with default phrase -
MiKo_2048 Start value converter <summary> documentation with default phrase
MiKo_2049 Use explicit wording instead of 'will be' in documentation
MiKo_2050 Follow .NET Framework conventions for exception documentation
MiKo_2051 Document thrown exceptions as conditions (e.g., '<paramref name="xyz"/> is <c>42</c>')
MiKo_2052 Use default phrase for ArgumentNullException documentation
MiKo_2053 Document ArgumentNullException only for reference type parameters -
MiKo_2054 Start ArgumentException documentation with default phrase
MiKo_2055 Start ArgumentOutOfRangeException documentation with default phrase
MiKo_2056 End ObjectDisposedException documentation with default phrase
MiKo_2057 Do not throw ObjectDisposedException from non-disposable types
MiKo_2059 Consolidate multiple documentations of same exception into one
MiKo_2060 Document factories uniformly
MiKo_2070 Do not start <summary> documentation with 'Returns'
MiKo_2071 Do not use boolean phrases in Enum return type <summary> documentation -
MiKo_2072 Do not start <summary> documentation with 'Try'
MiKo_2073 Start 'Contains' method <summary> documentation with 'Determines whether'
MiKo_2074 End 'Contains' method parameter documentation with default phrase
MiKo_2075 Use 'callback' instead of 'action', 'func' or 'function' in documentation
MiKo_2076 Document default values of optional parameters
MiKo_2077 Do not include <code> in <summary> documentation -
MiKo_2078 Do not include XML tags in <code> documentation -
MiKo_2079 Do not include obvious text in property <summary> documentation
MiKo_2080 Start field <summary> documentation with default phrase
MiKo_2081 End public-visible read-only field <summary> documentation with default phrase
MiKo_2082 Use distinct phrases for Enum member <summary> documentation
MiKo_2083 Do not falsely document writable fields as read-only
MiKo_2090 Use default phrase for equality operator documentation
MiKo_2091 Use default phrase for inequality operator documentation
MiKo_2100 Start <example> documentation with descriptive default phrase
MiKo_2101 Show code examples within <code> tags in <example> documentation
MiKo_2200 Start comments with a capitalized letter
MiKo_2201 Start sentences in comments with a capitalized letter -
MiKo_2202 Use term 'identifier' instead of 'id' in documentation
MiKo_2203 Use term 'unique identifier' instead of 'guid' in documentation
MiKo_2204 Use <list> for enumerations in documentation
MiKo_2205 Use <note> for important information in documentation -
MiKo_2206 Do not use term 'flag' in documentation -
MiKo_2207 Keep <summary> documentation short -
MiKo_2208 Do not use term 'an instance of' in documentation
MiKo_2209 Do not use double periods in documentation
MiKo_2210 Use term 'information' instead of 'info' in documentation
MiKo_2211 Do not use <remarks> sections for enum members
MiKo_2212 Use phrase 'failed' instead of 'was not successful' in documentation
MiKo_2213 Do not use contraction "n't" in documentation
MiKo_2214 Remove empty lines from documentation
MiKo_2215 Keep documentation sentences short -
MiKo_2216 Use <paramref> instead of <param> to reference parameters
MiKo_2217 Format <list> documentation properly
MiKo_2218 Use shorter terms instead of 'used to/in/by' in documentation
MiKo_2219 Do not use question or exclamation marks in documentation -
MiKo_2220 Use 'to seek' instead of 'to look for', 'to inspect for' or 'to test for' in documentation
MiKo_2221 Do not use empty XML tags in documentation -
MiKo_2222 Use term 'identification' instead of 'ident' in documentation
MiKo_2223 Link references via <see cref="..."/> in documentation
MiKo_2224 Place XML tags and texts on separate lines in documentation
MiKo_2225 Place code marked with <c> tags on single line
MiKo_2226 Explain the 'Why' instead of the 'That' in documentation -
MiKo_2227 Remove ReSharper suppressions from documentation -
MiKo_2228 Use positive wording instead of negative in documentation -
MiKo_2229 Remove left-over XML fragments from documentation
MiKo_2230 Use <list> for return values with specific meanings in documentation
MiKo_2231 Use '<inheritdoc />' marker for overridden 'GetHashCode()' methods documentation
MiKo_2232 Do not leave <summary> documentation empty
MiKo_2233 Place XML tags on single line
MiKo_2234 Use 'to' instead of 'that is to' or 'which is to' in documentation
MiKo_2235 Use 'will' instead of 'going to' in documentation
MiKo_2236 Use 'for example' instead of abbreviation 'e.g.' in documentation
MiKo_2237 Do not separate documentation with empty lines
MiKo_2238 Do not start <summary> documentation with 'Make sure to call this' -
MiKo_2239 Use '///' instead of '/** */' for documentation
MiKo_2240 Do not start <response> documentation with 'Returns'
MiKo_2244 Use <list> instead of <ul> or <ol> in documentation
MiKo_2245 Wrap numbers with <c> in documentation
MiKo_2300 Explain the 'Why' instead of the 'How' in comments -
MiKo_2301 Do not use obvious comments in AAA-Tests
MiKo_2302 Remove commented-out code -
MiKo_2303 Do not end comments with a period
MiKo_2304 Do not formulate comments as questions -
MiKo_2305 Do not use double periods in comments
MiKo_2306 End comments with a period - -
MiKo_2307 Use phrase 'failed' instead of 'was not successful' in comments
MiKo_2308 Place comments after code instead of on single line before closing brace
MiKo_2309 Do not use contraction "n't" in comments
MiKo_2310 Explain the 'Why' instead of the 'That' in comments -
MiKo_2311 Do not use separator comments
MiKo_2312 Use 'to' instead of 'that is to' or 'which is to' in comments
MiKo_2313 Format plain documentation comments as XML documentation

Maintainability

ID Title Enabled by default CodeFix available
MiKo_3000 Do not use empty regions -
MiKo_3001 Do not use custom delegates -
MiKo_3002 Limit class dependencies -
MiKo_3003 Follow .NET Framework Design Guidelines for events -
MiKo_3004 Make EventArgs property setters private -
MiKo_3005 Follow Trier-Doer-Pattern for methods named 'Try' -
MiKo_3006 Place 'CancellationToken' parameter last in method parameters -
MiKo_3007 Do not mix LINQ method and declarative query syntax in same method -
MiKo_3008 Return immutable collections -
MiKo_3009 Use named methods instead of lambda expressions with commands -
MiKo_3010 Do not create or throw reserved exception types -
MiKo_3011 Provide correct parameter name for ArgumentExceptions
MiKo_3012 Provide actual value when throwing ArgumentOutOfRangeExceptions
MiKo_3013 Throw ArgumentOutOfRangeException (not ArgumentException) in 'switch' default clauses
MiKo_3014 Include reason in InvalidOperationException, NotImplementedException and NotSupportedException messages
MiKo_3015 Use InvalidOperationExceptions for inappropriate states of parameterless methods
MiKo_3016 Do not throw ArgumentNullException for property return values
MiKo_3017 Include original exception when throwing new exceptions
MiKo_3018 Throw ObjectDisposedExceptions on public methods of disposable types -
MiKo_3020 Use 'Task.CompletedTask' instead of 'Task.FromResult'
MiKo_3021 Do not use 'Task.Run' in implementation -
MiKo_3022 Do not return Task<IEnumerable> or Task<IEnumerable<T>> -
MiKo_3023 Do not use 'CancellationTokenSource' as parameter -
MiKo_3024 Do not use [ref] keyword on reference parameters -
MiKo_3025 Do not re-assign method parameters -
MiKo_3026 Remove unused parameters -
MiKo_3027 Do not reserve parameters for future use -
MiKo_3028 Do not assign null to lambda parameters -
MiKo_3029 Prevent memory leaks in event registrations -
MiKo_3030 Follow Law of Demeter in methods - -
MiKo_3031 Do not implement ICloneable.Clone() -
MiKo_3032 Use 'nameof' instead of Cinch for PropertyChangedEventArgs property names
MiKo_3033 Use 'nameof' for property names in PropertyChangingEventArgs and PropertyChangedEventArgs
MiKo_3034 Use [CallerMemberName] attribute for PropertyChanged event raisers
MiKo_3035 Always specify timeouts with 'WaitOne' methods -
MiKo_3036 Use 'TimeSpan' factory methods instead of constructors
MiKo_3037 Do not use magic numbers for timeouts -
MiKo_3038 Do not use magic numbers -
MiKo_3039 Do not use Linq or yield in properties -
MiKo_3040 Use enums instead of booleans when more than 2 values might be needed -
MiKo_3041 Do not use delegates in EventArgs -
MiKo_3042 Do not implement interfaces in EventArgs -
MiKo_3043 Use 'nameof' for WeakEventManager event (de-)registrations
MiKo_3044 Use 'nameof' to compare property names of PropertyChangingEventArgs and PropertyChangedEventArgs
MiKo_3045 Use 'nameof' for EventManager event registrations
MiKo_3046 Use 'nameof' for property names in property raising methods
MiKo_3047 Use 'nameof' for applied [ContentProperty] attributes
MiKo_3048 Apply [ValueConversion] attribute to ValueConverters -
MiKo_3049 Apply [Description] attribute to enum members -
MiKo_3050 Declare DependencyProperty fields as 'public static readonly'
MiKo_3051 Register DependencyProperty fields properly
MiKo_3052 Declare DependencyPropertyKey fields as non-public 'static readonly'
MiKo_3053 Register DependencyPropertyKey fields properly -
MiKo_3054 Expose DependencyProperty identifier for read-only DependencyProperties
MiKo_3055 Implement INotifyPropertyChanged in ViewModels -
MiKo_3060 Do not use Debug.Assert or Trace.Assert
MiKo_3061 Use proper log categories with loggers -
MiKo_3062 End exception log messages with a colon
MiKo_3063 End non-exceptional log messages with a dot
MiKo_3064 Do not use contraction "n't" in log messages
MiKo_3065 Do not use interpolated strings with Microsoft Logging calls
MiKo_3070 Do not return null for IEnumerable -
MiKo_3071 Do not return null for Task -
MiKo_3072 Do not return 'List<>' or 'Dictionary<>' from non-private methods -
MiKo_3073 Fully initialize objects -
MiKo_3074 Do not define 'ref' or 'out' parameters on constructors -
MiKo_3075 Mark internal and private types as static or sealed unless derivation is needed
MiKo_3076 Do not initialize static members with static members below or in other type parts -
MiKo_3077 Provide default values for Enum-returning properties
MiKo_3078 Provide default values for enum members
MiKo_3079 Write HResults in hexadecimal
MiKo_3080 Use 'switch ... return' instead of 'switch ... break' for variable assignments -
MiKo_3081 Use pattern matching instead of logical NOT conditions
MiKo_3082 Use pattern matching instead of comparing with 'true' or 'false'
MiKo_3083 Use pattern matching for null checks
MiKo_3084 Place variables, not constants, on the left side of comparisons
MiKo_3085 Keep conditional statements short
MiKo_3086 Do not nest conditional statements -
MiKo_3087 Do not use negative complex conditions -
MiKo_3088 Use pattern matching for not-null checks
MiKo_3089 Do not use simple constant property patterns as conditions in 'if' statements
MiKo_3090 Do not throw exceptions in finally blocks -
MiKo_3091 Do not raise events in finally blocks -
MiKo_3092 Do not raise events in locks -
MiKo_3093 Do not invoke delegates inside locks -
MiKo_3094 Do not invoke methods or properties of parameters inside locks -
MiKo_3095 Do not use empty code blocks -
MiKo_3096 Use dictionaries instead of large switch statements -
MiKo_3097 Do not cast to type and return object -
MiKo_3098 Provide meaningful explanations for suppressed messages -
MiKo_3099 Do not compare enum values with null
MiKo_3100 Place test classes in same namespace as types under test -
MiKo_3101 Include tests in test classes -
MiKo_3102 Do not use conditional statements in test methods -
MiKo_3103 Do not use 'Guid.NewGuid()' in test methods
MiKo_3104 Apply NUnit's [Combinatorial] attribute properly
MiKo_3105 Use NUnit's fluent Assert approach in test methods
MiKo_3106 Do not use equality or comparison operators in assertions -
MiKo_3107 Use Moq Mock condition matchers only on mocks
MiKo_3108 Include assertions in test methods -
MiKo_3109 Include assertion messages with multiple assertions
MiKo_3110 Do not use 'Count' or 'Length' in assertions
MiKo_3111 Use 'Is.Zero' instead of 'Is.EqualTo(0)' in assertions
MiKo_3112 Use 'Is.Empty' instead of 'Has.Count.Zero' in assertions
MiKo_3113 Do not use FluentAssertions
MiKo_3114 Use 'Mock.Of<T>()' instead of 'new Mock<T>().Object'
MiKo_3115 Include code in test methods -
MiKo_3116 Include code in test initialization methods -
MiKo_3117 Include code in test cleanup methods -
MiKo_3118 Do not use ambiguous Linq calls in test methods -
MiKo_3119 Do not return only completed task in test methods
MiKo_3120 Use direct values instead of 'It.Is<>(...)' condition matcher to verify exact values in Moq mocks
MiKo_3121 Test concrete implementations instead of interfaces -
MiKo_3122 Limit test method parameters to 2 or fewer -
MiKo_3123 Do not catch exceptions in test methods
MiKo_3124 Do not use assertions in finally blocks in test methods
MiKo_3201 Invert if statements in short methods
MiKo_3202 Use positive conditions when returning in all paths
MiKo_3203 Invert if-continue statements when followed by single line
MiKo_3204 Invert negative if statements when they have an else clause
MiKo_3210 Make only the longest overloads virtual or abstract -
MiKo_3211 Do not use finalizers in public types -
MiKo_3212 Follow standard Dispose pattern without adding other Dispose methods -
MiKo_3213 Implement parameterless Dispose method using Basic Dispose pattern -
MiKo_3214 Remove 'Begin/End' or 'Enter/Exit' scope-defining methods from interfaces -
MiKo_3215 Use 'Func<T, bool>' instead of 'Predicate<bool>' for callbacks
MiKo_3216 Mark static fields with initializers as read-only
MiKo_3217 Do not use generic types that have other generic types as type arguments -
MiKo_3218 Define extension methods in expected places -
MiKo_3219 Do not mark public members as 'virtual' -
MiKo_3220 Simplify logical '&&' or '||' conditions using 'true' or 'false'
MiKo_3221 Use 'HashCode.Combine' in GetHashCode overrides
MiKo_3222 Simplify string comparisons
MiKo_3223 Simplify reference comparisons
MiKo_3224 Simplify value comparisons
MiKo_3225 Simplify redundant comparisons
MiKo_3226 Make read-only fields with initializers const
MiKo_3227 Use pattern matching for equality checks
MiKo_3228 Use pattern matching for inequality checks
MiKo_3229 Use 'KeyValuePair.Create' instead of constructors
MiKo_3230 Do not use 'Guid' as type for identifiers -
MiKo_3231 Use pattern matching for ordinal string comparison equality checks
MiKo_3301 Use lambda expression bodies instead of parenthesized lambda expression blocks for single statements
MiKo_3302 Use simple lambda expression bodies instead of parenthesized lambda expression bodies for single parameters
MiKo_3401 Keep namespace hierarchies from becoming too deep -
MiKo_3501 Do not suppress nullable warnings on Null-conditional operators
MiKo_3502 Do not suppress nullable warnings on Linq calls
MiKo_3503 Do not assign variables in try-catch blocks that are returned directly outside

Ordering

ID Title Enabled by default CodeFix available
MiKo_4001 Order methods with same name based on their parameter count
MiKo_4002 Place methods with same name and accessibility side-by-side
MiKo_4003 Place Dispose methods directly after constructors and finalizers
MiKo_4004 Place Dispose methods before all other methods of the same accessibility
MiKo_4005 Place the interface that gives a type its name directly after the type's declaration
MiKo_4007 Place operators before methods
MiKo_4008 Place GetHashCode methods directly after Equals methods
MiKo_4101 Place test initialization methods directly after One-Time methods
MiKo_4102 Place test cleanup methods after test initialization methods and before test methods
MiKo_4103 Place One-Time test initialization methods before all other methods
MiKo_4104 Place One-Time test cleanup methods directly after One-Time test initialization methods
MiKo_4105 Place object under test fields before all other fields

Performance

ID Title Enabled by default CodeFix available
MiKo_5001 Invoke 'Debug' and 'DebugFormat' methods only after checking 'IsDebugEnabled'
MiKo_5002 Use 'xxxFormat' methods only with multiple arguments
MiKo_5003 Use appropriate Log methods for exceptions -
MiKo_5010 Do not use 'object.Equals()' on value types
MiKo_5011 Do not concatenate strings with += operator -
MiKo_5012 Do not use 'yield return' for recursively defined structures -
MiKo_5013 Do not create empty arrays
MiKo_5014 Do not create empty lists when return value is read-only
MiKo_5015 Do not intern string literals
MiKo_5016 Use HashSet for lookups in 'List.RemoveAll' -
MiKo_5017 Make fields or variables assigned with string literals constant
MiKo_5019 Add [in] modifier to read-only struct parameters

Spacing

ID Title Enabled by default CodeFix available
MiKo_6001 Surround log statements with blank lines
MiKo_6002 Surround assertion statements with blank lines
MiKo_6003 Precede local variable statements with blank lines
MiKo_6004 Precede variable assignment statements with blank lines
MiKo_6005 Precede return statements with blank lines
MiKo_6006 Surround awaited statements with blank lines
MiKo_6007 Surround test statements with blank lines
MiKo_6008 Precede using directives with blank lines
MiKo_6009 Surround try statements with blank lines
MiKo_6010 Surround if statements with blank lines
MiKo_6011 Surround lock statements with blank lines
MiKo_6012 Surround foreach loops with blank lines
MiKo_6013 Surround for loops with blank lines
MiKo_6014 Surround while loops with blank lines
MiKo_6015 Surround do/while loops with blank lines
MiKo_6016 Surround using statements with blank lines
MiKo_6017 Surround switch statements with blank lines
MiKo_6018 Surround break statements with blank lines
MiKo_6019 Surround continue statements with blank lines
MiKo_6020 Surround throw statements with blank lines
MiKo_6021 Surround ArgumentNullException.ThrowIfNull statements with blank lines
MiKo_6022 Surround ArgumentException.ThrowIfNullOrEmpty statements with blank lines
MiKo_6023 Surround ArgumentOutOfRangeException.ThrowIf statements with blank lines
MiKo_6024 Surround ObjectDisposedException.ThrowIf statements with blank lines
MiKo_6030 Place open braces of initializers directly below the corresponding type definition
MiKo_6031 Place question and colon tokens of ternary operators directly below the corresponding condition
MiKo_6032 Position multi-line parameters outdented at end of method
MiKo_6033 Place braces of blocks below case sections directly below the corresponding case keyword
MiKo_6034 Place dots on same line(s) as invoked members
MiKo_6035 Place open parenthesis on same line(s) as invoked methods
MiKo_6036 Place lambda blocks directly below the corresponding arrow(s)
MiKo_6037 Place single arguments on same line(s) as invoked methods
MiKo_6038 Place casts on same line(s)
MiKo_6039 Place return values on same line(s) as return keywords
MiKo_6040 Align consecutive multi-line invocations by their dots
MiKo_6041 Place assignments on same line(s)
MiKo_6042 Place 'new' keywords on same line(s) as the types
MiKo_6043 Place expression bodies of lambdas on same line as lambda when fitting
MiKo_6044 Place operators such as '&&' or '||' on same line(s) as their (right) operands
MiKo_6045 Place comparisons using operators such as '==' or '!=' on same line(s)
MiKo_6046 Place calculations using operators such as '+' or '%' on same line(s)
MiKo_6047 Place braces of switch expressions directly below the corresponding switch keyword
MiKo_6048 Place logical conditions on a single line
MiKo_6049 Surround event (un-)registrations with blank lines
MiKo_6050 Position multi-line arguments outdented at end of method call
MiKo_6051 Place colon of constructor call on same line as constructor call
MiKo_6052 Place colon of list of base types on same line as first base type
MiKo_6053 Place single-line arguments on single line
MiKo_6054 Place lambda arrows on same line as the parameter(s) of the lambda
MiKo_6055 Surround assignment statements with blank lines
MiKo_6056 Place brackets of collection expressions at the same position as collection initializer braces
MiKo_6057 Align type parameter constraint clauses vertically
MiKo_6058 Indent type parameter constraint clauses below parameter list
MiKo_6059 Position multi-line conditions outdented below associated calls
MiKo_6060 Place switch case labels on same line
MiKo_6061 Place switch expression arms on same line
MiKo_6062 Place expressions within complex initializer expressions beside open brace
MiKo_6063 Place invocations on same line
MiKo_6064 Place identifier invocations on same line
MiKo_6065 Indent rather than outdent consecutive invocations spanning multiple lines
MiKo_6066 Indent rather than outdent collection expression elements
MiKo_6067 Place ternary operators on same lines as their respective expressions
MiKo_6070 Surround Console statements with blank lines
MiKo_6071 Surround local using statements with blank lines

Packages

No packages published

Contributors 2

  •  
  •