Code Inspections in C#
In C#, JetBrains Rider 2021.2 provides two kinds of code inspections: 938 inspections that detect errors such as broken syntax, unresolved symbols, compiler errors, and so on (you cannot configure or disable any of these inspections), and 773 proprietary code inspections, any of which you can disable or change its severity level.
These code inspections help you detect code issues in design time in all open files, and additionally they allow you to find code issues in specific scope.
Configurable C# inspections are listed below, grouped by their categories.
Code Notification (2 inspections)
This category groups code inspections with minor severity levels.
Inspection | |
---|---|
| |
Part of the code cannot be parsed |
Common Practices and Code Improvements (155 inspections)
This category groups inspections that hunt for medium severity issues that mainly affect code readability.
Inspection | |
---|---|
Access to a static member of a type via a derived type | |
Annotation duplicate in hierarchy | |
Auto-property can be made get-only (non-private accessibility) | |
Auto-property can be made get-only (private accessibility) | |
Base member has 'params' parameter, but overrider hasn't | |
Check for reference equality instead | |
Check for reference equality instead | |
Check for reference equality instead | |
Check for reference equality instead | |
Class can be made sealed (non-inheritable) (non-private accessibility) | |
Class can be made sealed (non-inheritable) (private accessibility) | |
Container nullability attribute usage with declaration of non-container type | |
Convert 'if do while' to 'while | |
| |
Convert local variable or field to constant (non-private accessibility) | |
Convert local variable or field to constant (private accessibility) | |
Declaration nullability inferred (parameter is inferred to be not null) | |
Declaration nullability inferred (parameter is inferred to be nullable) | |
Declaration nullability inferred (type member is inferred to be not null) | |
Declaration nullability inferred (type member is inferred to be nullable) | |
| |
| |
Field can be made readonly (non-private accessibility) | |
Field can be made readonly (private accessibility) | |
Get-only auto-property is never assigned | |
Invert condition | |
Iteration variable can be declared with a more specific type | |
Join local variable declaration and assignment | |
Literal's length can be reduced by using verbatim string | |
Local function can be made static | |
Local variable has too wide declaration scope | |
Make constructor in abstract class protected | |
Member can be made private (non-private accessibility) | |
Member can be made private (private accessibility) | |
Member can be made protected (non-private accessibility) | |
Member can be made protected (private accessibility) | |
Member can be made static (shared) (non-private accessibility) | |
Member can be made static (shared) (private accessibility) | |
Member or type can be made internal(friend) | |
Method has async overload | |
Method has async overload with cancellation support | |
Method supports cancellation | |
Missing XML comment for private or internal type or member | |
Multiple nullable attributes usage | |
Nested string interpolation can be inlined | |
Nullability attribute usage with declaration of void or value type | |
Nullability attribute used with declaration that cannot be directly referenced from other code | |
Parameter can be declared with base type | |
Parameter can be declared with base type | |
Parameter type can be IEnumerable<T> (non-private accessibility) | |
Parameter type can be IEnumerable<T> (private accessibility) | |
Possible mistaken argument | |
Possible mistaken call to GetType() | |
Possible mistaken call to GetType() | |
Property can be made init-only (non-private accessibility) | |
Property can be made init-only (private accessibility) | |
Redundant 'is' | |
Remove constructor invocation | |
Remove redundant statement | |
Remove redundant statement | |
Remove ToList() | |
Remove ToList() | |
Replace with FirstOrDefault($args$) | |
Replace with FirstOrDefault($args$) | |
Replace with FirstOrDefault($args$) | |
Replace with FirstOrDefault($args$) | |
Replace with LastOrDefault($args$) | |
Replace with LastOrDefault($args$) | |
Replace with LastOrDefault($args$) | |
Replace with LastOrDefault($args$) | |
Replace with OfType<T>() | |
Replace with OfType<T>() | |
Replace with OfType<T>() | |
Replace with OfType<T>().Any() | |
Replace with OfType<T>().Any() (replace with OfType<T>().Any(..)) | |
Replace with OfType<T>().Count() | |
Replace with OfType<T>().Count() (replace with OfType<T>().Count(..)) | |
Replace with OfType<T>().First() | |
Replace with OfType<T>().First() (replace with OfType<T>().First(..)) | |
Replace with OfType<T>().FirstOrDefault() | |
Replace with OfType<T>().FirstOrDefault() (replace with OfType<T>().FirstOrDefault(..)) | |
Replace with OfType<T>().Last() | |
Replace with OfType<T>().Last() (replace with OfType<T>().Last(..)) | |
Replace with OfType<T>().LastOrDefault() | |
Replace with OfType<T>().LastOrDefault() (replace with OfType<T>().LastOrDefault(..)) | |
Replace with OfType<T>().LongCount() | |
Replace with OfType<T>().Single() | |
Replace with OfType<T>().Single() (replace with OfType<T>().Single(..)) | |
Replace with OfType<T>().SingleOrDefault() | |
Replace with OfType<T>().SingleOrDefault() (replace with OfType<T>().SingleOrDefault(..)) | |
Replace with OfType<T>().Where() (replace with OfType<T>().Where(..)) | |
Replace with simple assignment | |
Replace with simple assignment | |
Replace with single assignment | |
Replace with single assignment | |
Replace with single call to Any(..) | |
Replace with single call to Count(..) | |
Replace with single call to First(..) | |
Replace with single call to FirstOrDefault(..) | |
Replace with single call to Last(..) | |
Replace with single call to LastOrDefault(..) | |
Replace with single call to Single(..) | |
Replace with single call to SingleOrDefault(..) | |
Replace with SingleOrDefault($args$) | |
Replace with SingleOrDefault($args$) | |
Replace with SingleOrDefault($args$) | |
Replace with SingleOrDefault($args$) | |
Return type can be IEnumerable<T> (non-private accessibility) | |
Return type can be IEnumerable<T> (private accessibility) | |
Simplify conditional ternary expression | |
Simplify LINQ expression (use 'All') | |
Simplify LINQ expression (use 'Any') | |
Simplify negated pattern | |
Simplify negated relational pattern | |
Simplify negative equality expression | |
Specify string comparison explicitly | |
Specify string culture explicitly | |
String literal can be inlined | |
String.Compare is culture-specific (string.Compare(string, int, string, int) is culture-specific) | |
| |
| |
String.Compare is culture-specific (string.Compare(string, string) is culture-specific) | |
String.Compare is culture-specific (string.Compare(string, string, bool) is culture-specific) | |
String.Compare is culture-specific (string.Compare(string, string, bool) is culture-specific) | |
String.CompareTo is culture-specific | |
String.EndsWith is culture-specific (string.EndsWith(string) is culture-specific) | |
String.IndexOf is culture-specific (string.IndexOf(string) is culture-specific) | |
String.IndexOf is culture-specific (string.IndexOf(string, int) is culture-specific) | |
String.IndexOf is culture-specific (string.IndexOf(string, int) is culture-specific) | |
String.LastIndexOf is culture-specific (string.LastIndexOf(string) is culture-specific) | |
String.LastIndexOf is culture-specific (string.LastIndexOf(string, int) is culture-specific) | |
String.LastIndexOf is culture-specific (string.LastIndexOf(string, int) is culture-specific) | |
String.StartsWith is culture-specific (string.StartsWith(string) is culture-specific) | |
Struct can be made readonly | |
Struct member can be made readonly | |
try-catch and try-finally statements can be merged | |
Type parameter could be declared as covariant or contravariant | |
Unreachable code detected | |
Use array creation expression | |
Use array creation expression | |
Use 'Array.Empty<T>()' | |
Use cancellation token | |
Use compiler-supported nullable attributes | |
Use 'EventArgs.Empty' | |
Use indexed property | |
Use 'is' operator | |
Use 'is' operator | |
| |
Use method Any() | |
Use method Any() | |
Use method Any() | |
Use method Any() | |
Use method IsInstanceOfType(..) | |
| |
Use 'Type.EmptyTypes' |
Compiler Warnings (128 inspections)
Inspections in this category detect compiler warnings before you compile.
Inspection | |
---|---|
| |
A method marked [DoesNotReturn] should not return. | |
A possible null value may not be used for a type marked with [NotNull] or [DisallowNull]. | |
A previous catch clause already catches all exceptions | |
| |
| |
Ambiguous reference in XML comment | |
| |
| |
Assignment in conditional expression | |
Assignment made to same variable | |
Async function without await expression | |
Async method invocation without await expression | |
| |
| |
| |
| |
Badly formed XML in included comments file | |
Bitwise-or operator used on a sign-extended operand. | |
Call to a non-readonly member from a 'readonly' member results in an implicit copy of 'this' | |
Cannot convert null literal to non-nullable reference type. | |
Cannot resolve reference in XML comment | |
Class overrides Object.Equals(object o) but not Object.GetHashCode() | |
| |
Comparison to integral constant is useless; the constant is outside the range of type 'type'. | |
Converting null literal or possible null value to non-nullable type. | |
Declaring new protected member in sealed class is the same as declaring it as private | |
| |
Dereference of a possibly null reference. | |
Duplicate param tag in XML comment | |
Duplicate typeparam tag in XML comment | |
| |
Field is never used | |
Filter expression is a constant, consider removing the filter | |
Given expression always matches the provided pattern | |
Given expression is always of the provided type | |
Given expression is never of the provided type | |
'goto case' value is not implicitly convertible to required type | |
Incorrect signature in XML comment | |
Introducing a 'Finalize' method can interfere with destructor invocation | |
| |
| |
| |
| |
Member cannot be used in this attribute. | |
Member must conditionally have a non-null value when exiting a function. | |
Member must have a non-null value when exiting. | |
Member overrides obsolete member | |
Method lacks '[DoesNotReturn]' annotation in order to match implemented or overridden member. | |
Missing XML comment for publicly visible type or member | |
Multiple override candidates at run-time | |
Namespace should be default namespace of this project | |
Non-accessed field | |
Non-accessed local variable | |
Non-nullable member is uninitialized. | |
Nullability mismatch in constraints for type parameter. | |
| |
Nullability of reference types in interface implemented by the base type doesn't match. | |
Nullability of reference types in return type doesn't match implemented member. | |
Nullability of reference types in return type doesn't match implicitly implemented member. | |
Nullability of reference types in return type doesn't match overridden member. | |
Nullability of reference types in return type doesn't match partial method declaration. | |
| |
Nullability of reference types in source type doesn't match target type. | |
Nullability of reference types in type doesn't match implemented member. | |
Nullability of reference types in type doesn't match implicitly implemented member. | |
Nullability of reference types in type doesn't match overridden member. | |
| |
Nullability of reference types in type of parameter doesn't match implemented member. | |
Nullability of reference types in type of parameter doesn't match implicitly implemented member. | |
Nullability of reference types in type of parameter doesn't match overridden member. | |
Nullability of reference types in type of parameter doesn't match partial method declaration. | |
| |
| |
| |
Nullability of type argument doesn't match 'class' constraint. | |
Nullability of type argument doesn't match constraint type. | |
Nullability of type argument doesn't match 'notnull' constraint. | |
| |
| |
| |
Nullable value type may be null. | |
Object or collection initializer implicitly dereferences possibly null member. | |
| |
Parameter has no matching param tag in the XML comment | |
Parameter must conditionally have a non-null value when exiting a function. | |
| |
Parameter must have a non-null value when exiting. | |
Partial method declarations have inconsistent nullability for type parameter. | |
Possible mistaken empty statement | |
Possible null reference argument for a parameter. | |
Possible null reference assignment. | |
Possible null reference return. | |
Possible unintended reference comparison | |
Record defined 'Equals' but not 'GetHashCode' | |
Reference to a volatile field will not be treated as volatile | |
| |
Static type in 'is' or 'as' operator. | |
| |
Taking address of marshal-by-reference class field | |
| |
| |
| |
The given expression always matches the provided constant. | |
The given expression never matches the provided pattern. | |
The 'l' suffix is easily confused with the digit '1' | |
| |
The switch expression does not handle all possible inputs (it is not exhaustive). | |
The switch expression does not handle some null inputs (it is not exhaustive). | |
| |
| |
| |
Type is already listed in the interface list with different nullability of reference types. | |
Type parameter has no matching typeparam tag in the XML comment | |
Type parameter has the same name as a type parameter from the outer type | |
Types and aliases should not be named 'record' | |
Unable to include XML fragment | |
Unassigned field | |
Unassigned readonly field | |
Unboxing a possibly null value. | |
Unused local variable | |
| |
Use of obsolete symbol (without message) | |
| |
XML comment has a 'param' tag for 'Parameter', but there is no parameter by that name | |
XML comment has a 'typeparam' tag for 'TypeParameter', but there is no type parameter by that name | |
XML comment has cref attribute that refers to a type parameter | |
XML comment is not placed on a valid language element |
Constraints Violations (11 inspections)
This category includes code inspections, mostly with the warning severity level, which detect violations related to symbol attributes, including JetBrains Rider's code annotations, and other similar issues.
Inspection | |
---|---|
| |
BaseTypeRequired attribute supports only classes and interfaces | |
Compare with '==' types marked by 'CannotApplyEqualityOperatorAttribute' | |
| |
Namespace does not correspond to file location | |
Non-nullable member is not initialized at constructor exit | |
Possible 'null' assignment to non-nullable entity | |
Possible violation of 'ValueRange'/'NonNegativeValue' attribute | |
Problem in contract annotation definition | |
Required base type conflicting another type | |
Type specified in '[BaseTypeRequired]' attribute conflicts another type |
Formatting (41 inspections)
Inspections in this category detect code formatting problems.
Inspection | |
---|---|
Incorrect blank lines (blank lines are missing elsewhere) | |
Incorrect blank lines (blank lines are redundant elsewhere) | |
Incorrect blank lines (incorrect number of blank lines near braces) | |
Incorrect indent (around child statement) | |
Incorrect indent (around declaration braces) | |
Incorrect indent (around expression braces) | |
Incorrect indent (around namespace braces) | |
Incorrect indent (around preprocessor directive) | |
Incorrect indent (around statement braces) | |
Incorrect indent (around switch statement) | |
Incorrect indent (incorrect indent size) | |
Incorrect indent (line indent should be restored to the previous level elsewhere) | |
Incorrect indent (line indent should not be changed relative to the previous line elsewhere) | |
Incorrect indent (line should be indented or outdented elsewhere) | |
Incorrect indent (tabs/spaces mismatch) | |
Incorrect line breaks (around comma in lists) | |
Incorrect line breaks (around declaration braces) | |
Incorrect line breaks (around empty braces) | |
Incorrect line breaks (around expression braces) | |
Incorrect line breaks (around LINQ queries) | |
Incorrect line breaks (around parenthesis) | |
Incorrect line breaks (around statement braces) | |
Incorrect line breaks (line break is missing elsewhere) | |
Incorrect line breaks (line break is redundant elsewhere) | |
Incorrect line breaks (multiple statements on one line) | |
Incorrect line breaks (multiple type members on one line) | |
Incorrect spacing (around attributes) | |
Incorrect spacing (around braces) | |
Incorrect spacing (around colon) | |
Incorrect spacing (around comma) | |
Incorrect spacing (around generic brackets) | |
Incorrect spacing (around member access symbols) | |
Incorrect spacing (around operator symbols) | |
Incorrect spacing (around parenthesis) | |
Incorrect spacing (around semicolon) | |
Incorrect spacing (around square brackets within a statement) | |
Incorrect spacing (between keyword and parenthesis) | |
Incorrect spacing (multiple spaces are prohibited) | |
Incorrect spacing (space is missing elsewhere) | |
Incorrect spacing (space is redundant elsewhere) | |
Incorrect spacing (tabs are prohibited here) |
Language Usage Opportunities (67 inspections)
This category includes code inspections, mostly with the suggestion severity level, which notify you when more advanced language constructs can be used. These inspections detect syntax of outdated language versions and suggest using features from more modern language versions. For most of the supported languages, language version can be detected automatically or set manually.
Inspection | |
---|---|
Class cannot be instantiated | |
Convert 'as' expression type check and the following null check into negated pattern matching | |
Convert 'as' expression type check and the following null check into pattern matching | |
Convert delegate variable to local function | |
Convert 'if' statement to 'switch' expression | |
Convert 'if' statement to 'switch' statement | |
Convert lambda expression to method group | |
Convert negated 'is' expression to 'is' expression with negated pattern | |
| |
Convert property to auto-property | |
Convert property to auto-property (when possible) | |
Convert property to auto-property with private setter | |
Convert static method invocation to extension method call | |
Convert to 'await using' statement or declaration | |
| |
Convert to lambda expression (when possible) | |
Convert to static class | |
Convert to 'using' declaration | |
Foreach loop can be converted into LINQ-expression but another 'GetEnumerator' method will be used | |
For-loop can be converted into foreach-loop | |
'if' statement can be re-written as '?:' expression | |
'if' statement can be re-written as '??' expression | |
'if' statement can be re-written as '??=' assignment | |
'if-return' statement can be re-written as 'return' statement | |
Inline 'out' variable declaration | |
Inline temporary variable | |
Introduce optional parameters (non-private accessibility) | |
Introduce optional parameters (private accessibility) | |
Invert 'if' statement to reduce nesting | |
Join null check with assignment | |
Join null check with assignment (when possible) | |
Lambda expression/anonymous method can be made 'static' | |
Lambda expression/anonymous method must be 'static' to avoid allocations | |
Lambda expression/anonymous method should not have captures of the containing context | |
Loop can be converted into LINQ-expression | |
Merge 'and' pattern | |
Merge conditional ?: expression into conditional access | |
Merge conditional ?: expression into conditional access (when possible) | |
Merge negated null/pattern checks into complex pattern | |
Merge null/pattern checks into complex pattern | |
Merge null/pattern/value checks into 'or'/'and' patterns | |
Merge sequential checks into single conditional access check | |
Merge sequential checks into single conditional access check (when possible) | |
Move to existing positional deconstruction pattern | |
Part of foreach loop can be converted into LINQ-expression but another 'GetEnumerator' method will be used | |
Part of loop's body can be converted into LINQ-expression | |
Replace auto-property with computed property | |
Replace if statement with null-propagating code | |
Replace if statement with null-propagating code (when possible) | |
Replace object pattern not performing any additional checks with 'var' pattern | |
Replace 'Slice' with range indexer | |
Replace 'Substring' with range indexer | |
Replace 'switch' statement with 'switch' expression | |
Replace ternary expression with 'switch' expression | |
Use compound assignment | |
Use compound assignment | |
Use deconstruction | |
Use deconstruction (on parameter declaration) | |
Use deconstruction to swap variables | |
Use index from end expression | |
Use 'nameof' expression to reference name | |
Use 'nameof' expression to reference name in part of the string literal | |
Use 'nameof' expression to reference type's name | |
Use object or collection initializer when possible | |
Use positional deconstruction pattern | |
Use string interpolation expression | |
Use type annotation syntax |
NUnit (30 inspections)
These inspections detect code issues related to NUnit tests.
Inspection | |
---|---|
NUnit. Async test method must return Task or Task<T> | |
NUnit. Cannot resolve symbol in TestCaseSource or ValueSource attribute | |
NUnit. Duplicate values | |
NUnit. Ignored parameter attribute | |
NUnit. Implicitly unspecified null values | |
NUnit. Incompatible argument type or incorrect argument value | |
NUnit. Incompatible expected result type or incorrect value | |
NUnit. Incorrect range bounds. 'to' must be greater than or equal to 'from' | |
NUnit. Mismatch of the range step sign | |
NUnit. Missing arguments in TestCase attribute | |
NUnit. Missing expected result for non-void test method | |
NUnit. No values provided in the attributes | |
| |
NUnit. Range 'step' parameter value must be non-zero | |
NUnit. Redundant argument in TestCase attribute | |
NUnit. Redundant argument instead of ExpectedResult | |
NUnit. Redundant expected result for void test method | |
NUnit. Specified attribute values produce too many tests | |
NUnit. Specified values are not compatible with the test parameter type | |
NUnit. Test case Result property duplicates ExpectedResult | |
NUnit. Test case Result property is obsolete | |
NUnit. Test case source must be field, property, or method | |
NUnit. Test case source must be non-abstract and implement IEnumerable | |
NUnit. Test case source must be static | |
NUnit. The maximum range value is not reachable with the step value | |
NUnit. Values for test method parameters are not provided | |
NUnit. Values in range do not fit the type of the test parameter | |
NUnit.AutoFixture. Incompatible argument type or incorrect argument value | |
NUnit.AutoFixture. Missed Test or TestFixture attribute | |
NUnit.AutoFixture. Redundant argument in InlineAutoData attribute |
Potential Code Quality Issues (166 inspections)
This category includes inspections that detect critical issues (code smells), mostly with Error or Warning level. This category also includes inspections that ensure localization assistance.
Inspection | |
---|---|
'?:' expression has identical true and false branches | |
[ThreadStatic] doesn't work with instance fields | |
A suppressed nullable warning might hide an underlying problem. | |
Abstract or virtual (overridable) event is never invoked | |
Access to disposed captured variable | |
Access to foreach variable in closure | |
Access to modified captured variable | |
According to values of the bit masks, expression result will always be the same. | |
Actual shift count equals zero. | |
Ambiguous symbols in text argument | |
Annotation conflict in hierarchy | |
Assignment in conditional expression | |
Async iterator invocation without 'await foreach' | |
Auto-property accessor is never used (non-private accessibility) | |
Auto-property accessor is never used (private accessibility) | |
Avoid using 'async' lambda when delegate type returns 'void' | |
Avoid using 'async' methods with the 'void' return type | |
Bitwise operation on enum which is not marked by [Flags] attribute | |
Call to base member with implicit default parameters | |
Call to 'base.Equals(...)' is reference equality | |
Cannot access static symbol in text argument | |
Cannot access symbol in text argument | |
Cannot resolve property | |
Cannot resolve resource | |
Cannot resolve resource item | |
Cannot resolve symbol in text argument | |
Captured field reference of a marshal-by-reference class may cause a runtime exception | |
Captured reference to 'volatile' field will not be treated as 'volatile' | |
Char is possibly unintentionally used as integer | |
Class is never instantiated (non-private accessibility) | |
Class is never instantiated (private accessibility) | |
Collection is never updated (non-private accessibility) | |
Collection is never updated (private accessibility) | |
Collection's content is never queried (non-private accessibility) | |
Collection's content is never queried (private accessibility) | |
Constant shift expression with non-zero operands results in zero value. | |
| |
Division by zero in at least one execution path. | |
Do not store SpinLock in readonly field | |
| |
| |
Empty 'with' expression is redundant | |
'Enumerable.Sum' invocation in explicit unchecked context | |
Equality comparison of floating point numbers | |
Event is never subscribed to (non-private accessibility) | |
Event is never subscribed to (private accessibility) | |
Event never invoked | |
Event unsubscription via anonymous delegate | |
Exception rethrow possibly intended | |
Explicit argument passed to parameter with caller info attribute | |
Field hides property with default implementation in interface | |
Formatting is specified, but interpolated string expression is not IFormattable | |
Function body is too complex to analyze | |
Function is recursive on all execution paths | |
| |
'GC.SuppressFinalize' is invoked for type without destructor | |
Heuristically unreachable case due to integer analysis. | |
Heuristically unreachable switch arm due to integer analysis. | |
Inconsistent arguments passed to 'Math.Clamp()' method. | |
Inconsistent synchronization on field | |
Instance of IEnumerator is never disposed | |
Interfaces marked as ServiceContract should declare at least one OperationContract | |
Invalid XML documentation comment | |
Invocation of polymorphic field-like event | |
IQueryable is possibly unintentionally used as IEnumerable | |
Iterator never returns | |
Local function hides method | |
| |
Loop control variable is never changed inside loop | |
Member hides static member from outer class | |
Member initialized value ignored | |
Method is marked as OperationContract but containing type isn't marked as ServiceContract | |
Method with optional or 'params' parameter is hidden by overload | |
Method with 'params' is invoked while more specific method is available | |
Mismatch of optional parameter value in overridden method | |
Missing '.ConfigureAwait(false)' for async disposable in library code | |
Missing '.ConfigureAwait(false)' in library code | |
Multiple sequential 'OrderBy' invocation | |
Non-accessed field (non-private accessibility) | |
Non-accessed field (private accessibility) | |
Non-public member in implementation class hides default implementation in interface | |
Non-readonly type member referenced in 'GetHashCode()' | |
Nullable warning suppression operator might be confused with inverted 'is' expression | |
'Object.ReferenceEquals' is always false because it is called with value type | |
One way operations must not return values | |
Operator 'is'/'Type Of ... Is ...' can be used | |
Overridden GetHashCode calls base 'Object.GetHashCode()' | |
| |
Parameter name differs in partial method declaration | |
Possible ambiguity while accessing member by interface | |
Possible comparison of value type with 'null' | |
Possible cyclic constructor call | |
| |
Possible incorrect implementation of Double-Check Locking pattern. Read access to checked field | |
| |
Possible loss of fraction | |
| |
Possible overflow in checked context. | |
Possible overflow in unchecked context. | |
Possible overflow. | |
Possible 'System.ArgumentOutOfRangeException'. Index must be a non-negative integer | |
Possible 'System.ArgumentOutOfRangeException'. Start index should be less than or equal to end index | |
Possible 'System.InvalidCastException' | |
Possible 'System.InvalidCastException' in foreach loop | |
Possible 'System.InvalidOperationException' | |
Possible 'System.NullReferenceException' | |
Possible unassigned object created by 'new' expression | |
Possible unintended reference comparison | |
Possibly impure struct method is called on readonly variable: struct value always copied before invocation | |
Possibly misleading 'DefaultValueAttribute' usage to define optional parameter value | |
Possibly missing comma before indexer initializer | |
Possibly unintended linear search in set | |
Possibly unintended string interpolation instead of format string template. | |
'ref' or 'out' parameter with [Optional] attribute | |
Return type of a function can be non-nullable | |
Return value of [MustUseReturnValue] annotated method is not used | |
Return value of iterator is not used | |
Return value of pure method is not used | |
Right operand of dynamic shift operation should be convertible to 'int' | |
Safe cast expression always succeeds | |
Shift expression with zero left operand equals zero. | |
Similar anonymous type detected nearby | |
Similar expressions comparison | |
| |
Some values of the enum are not processed inside 'switch' statement | |
| |
Static field or auto-property in generic type | |
Static member initializer refers to static member below or in other part | |
String formatting method problems | |
Structured message template problems | |
Suspicious parameter name in ArgumentNullException | |
Suspicious shift count for this type of left operand. | |
Suspicious type conversion or check | |
Suspicious 'volatile' field usage: compound operation is not atomic. 'Interlocked' class can be used instead | |
Symbol from module that might be missing at runtime | |
Tail recursive call can be replaced with loop | |
The given expression of 'is' operator is always of the provided type | |
The given expression of 'is' operator is never of the provided type | |
The source expression always matches the provided pattern | |
The source expression is always of pattern's type | |
The source expression never matches the provided pattern | |
Thread static field has initializer | |
Try cast and check for null can be replaced with a type check | |
Type check and casts can be merged | |
Type pattern and casts can be merged | |
Unassigned field (non-private accessibility) | |
Unassigned field (private accessibility) | |
Unassigned readonly field | |
Unknown Razor layout | |
Unknown Razor section | |
Usage of <inheritdoc /> is invalid. | |
Use <inheritdoc /> on root level to inherit documentation from base candidate. | |
Use collection's count property | |
Use format specifier in format strings | |
Use format specifier in interpolated strings | |
Use nullable annotation instead of an attribute. | |
Useless arithmetical operation. | |
Using stackalloc inside loop | |
Value assigned to a property of non-variable qualifier expression can be lost | |
| |
Variable can be declared as non-nullable | |
Variable in local function hides variable from outer scope | |
Virtual member call in constructor | |
'void' method is annotated by [MustUseReturnValue] attribute | |
'void' method is annotated by [Pure] attribute | |
'with' expression is used instead of object initializer |
Redundancies in Code (81 inspections)
Code inspections in this category look for redundancies and dead code, which affect code readability and style, and could be safely removed. Some code redundancies cannot be fixed automatically, and quick-fixes for them are performed in the interactive mode, requiring the user input. But the majority of the redundancies can be fixed without user interaction, using either fix in scope or code cleanup.
Inspection | |
---|---|
'??' condition is known to be null or not null | |
[NotNull] or [CanBeNull] attribute is applied to a type that already has the same annotation from nullable reference types. | |
Anonymous method signature is not necessary | |
Array creation can be replaced with array initializer | |
| |
Assignment results are fully discarded | |
Comparison to integral constant is useless. | |
Conditional access qualifier expression is known to be null or not null | |
| |
| |
Explicit delegate creation expression is redundant | |
Expression is always 'null' | |
Expression is always 'true' or always 'false' | |
Heuristically unreachable code | |
Immediate delegate invocation | |
Math.Abs() argument is always non-negative | |
Math.Sign() method always gives the same result | |
Parentheses are redundant if attribute has no arguments | |
Pattern is always 'true' or always 'false' | |
Private field can be converted to local variable | |
Redundant [AttributeUsage] attribute property assignment | |
| |
Redundant always match subpattern | |
Redundant anonymous type property explicit name | |
Redundant argument with default value | |
Redundant arithmetic overflow checking context | |
Redundant 'base.' qualifier | |
Redundant boolean comparison | |
Redundant braces in collection initializer | |
| |
| |
| |
Redundant 'class' keyword in record declaration | |
Redundant condition check before assignments | |
Redundant conditional ternary expression usage | |
Redundant 'ConfigureAwait(true)' | |
Redundant control flow jump statement | |
Redundant discard designation | |
| |
Redundant empty argument list on object creation expression | |
Redundant empty finally block | |
Redundant empty object or collection initializer | |
Redundant empty switch section | |
Redundant explicit array creation in argument of 'params' parameter | |
Redundant explicit nullable type creation | |
Redundant explicit positional property declaration | |
Redundant explicit size specification in array creation | |
Redundant explicit tuple component name | |
Redundant explicit type in array creation | |
Redundant fixed pointer declaration | |
Redundant global using directive | |
Redundant 'IEnumerable.Cast<T>' or 'IEnumerable.OfType<T>' call | |
Redundant lambda expression parameter type specification | |
Redundant lambda signature parentheses | |
| |
Redundant 'notnull' constraint on type parameter constrained by non-nullable base type. | |
Redundant nullable annotation on base type constraint of type parameter constrained by another non-nullable base type. | |
Redundant nullable annotation on base type constraint of type parameter having non-nullable type kind. | |
Redundant nullable annotation on 'class?' constraint of type parameter constrained by non-nullable base type. | |
Redundant nullable attribute. | |
Redundant 'object.ToString()' call | |
Redundant 'object.ToString()' call for value types | |
Redundant operand in logical conditional expression | |
Redundant 'orderby' clause 'ascending' keyword | |
Redundant property pattern clause | |
Redundant range bound | |
Redundant 'readonly' modifier | |
Redundant 'record' type declaration body | |
Redundant semicolon after type or namespace declaration | |
Redundant string interpolation | |
Redundant 'string.Format()' call | |
Redundant 'string.ToCharArray()' call | |
Redundant suppress nullable warnings expression. | |
Redundant type arguments of method | |
| |
Redundant verbatim prefix | |
Redundant verbatim string prefix | |
Remove redundant pattern-matching parentheses | |
'true' is redundant as 'for'-statement condition | |
Type check for nullable type is equal to underlying type check | |
Unsafe context declaration is redundant |
Redundancies in Symbol Declarations (45 inspections)
This category includes code inspections, mostly with the warning severity level, which detect empty and unused symbol declarations.
Inspection | |
---|---|
Class with virtual (overridable) members never inherited (non-private accessibility) | |
Class with virtual (overridable) members never inherited (private accessibility) | |
Component of the tuple is never used | |
'DefaultParameterValueAttribute' should be used in conjunction with 'OptionalAttribute' | |
| |
| |
| |
Entity is only used to capture its name (non-private accessibility) | |
Entity is only used to capture its name (private accessibility) | |
| |
Local function is never used | |
Local function return value is never used | |
Method return value is never used (non-private accessibility) | |
Method return value is never used (private accessibility) | |
Non-accessed local variable | |
Parameter is only used for precondition check (non-private accessibility) | |
Parameter is only used for precondition check (private accessibility) | |
'params' modifier is always ignored on overrides | |
Redundant base constructor call | |
Redundant class or interface specification in base types list | |
| |
| |
Redundant method overload (non-private accessibility) | |
Redundant method overload (private accessibility) | |
Redundant 'partial' modifier on method declaration | |
Redundant 'partial' modifier on type declaration | |
| |
Type is never used (non-private accessibility) | |
Type is never used (private accessibility) | |
Type member is never accessed via base type (non-private accessibility) | |
Type member is never accessed via base type (private accessibility) | |
Type member is never used (non-private accessibility) | |
Type member is never used (private accessibility) | |
Type member is only used in overrides (non-private accessibility) | |
Type member is only used in overrides (private accessibility) | |
Underlying type of enum is 'int' | |
Unused label | |
| |
Unused parameter (non-private accessibility) | |
Unused parameter (private accessibility) | |
Unused parameter in partial method | |
Unused positional parameter | |
Unused type parameter | |
Virtual (overridable) member is never overridden (non-private accessibility) | |
Virtual (overridable) member is never overridden (private accessibility) |
Spelling issues (3 inspections)
These inspections detect typos in various contexts.
Inspection | |
---|---|
| |
| |
|
Syntax Style (43 inspections)
Inspections in this category detect violations of code syntax styles. In contrast to most of other code inspections, these inspections can either detect the same code construct as a code issue or not depending on the corresponding code style rule configured on the page of JetBrains Rider settings Ctrl+Alt+S. You can also fix issues that these inspection detect using code cleanup.
Inspection | |
---|---|
Add parentheses to avoid non-obvious precedence | |
Add/remove qualifier for static members | |
| |
Adjust modifiers declaration order | |
Join or separate attributes is section | |
Join or separate 'var' in deconstruction declarations | |
| |
Replace built-in type reference with a CLR type name or a keyword | |
| |
Separate control transfer statement with blank line | |
Unnecessary whitespace at the end of line | |
Usage of tabulation character for indentation is prohibited | |
Use explicit or implicit modifier definition for type members | |
Use explicit or implicit modifier definition for types | |
| |
Use preferred argument style for anonymous functions | |
Use preferred argument style for literal values | |
Use preferred argument style for named expressions | |
Use preferred argument style for string literal values | |
Use preferred body style (convert to constructor or destructor with preferred body style) | |
Use preferred body style (convert to local function with preferred body style) | |
Use preferred body style (convert to method or operator with preferred body style) | |
Use preferred body style (convert to property, indexer or event with preferred body style) | |
Use preferred braces style (enforce braces in 'do-while' statement) | |
Use preferred braces style (enforce braces in 'fixed' statement) | |
Use preferred braces style (enforce braces in 'for' statement) | |
Use preferred braces style (enforce braces in 'foreach' statement) | |
Use preferred braces style (enforce braces in 'if' statement) | |
Use preferred braces style (enforce braces in 'lock' statement) | |
Use preferred braces style (enforce braces in 'using' statement) | |
Use preferred braces style (enforce braces in 'while' statement) | |
Use preferred braces style (remove redundant braces) | |
Use preferred style for discard declaration | |
Use preferred style for trailing comma before new line in multiline lists | |
Use preferred style for trailing comma when the last element is not followed by a new line | |
Use preferred style of default value expression when type is evident | |
Use preferred style of default value expression when type is not evident | |
Use preferred style of 'new' expression when created type is evident | |
Use preferred style of 'new' expression when created type is not evident | |
Use preferred 'var' style (elsewhere) | |
Use preferred 'var' style (for built-in types) | |
Use preferred 'var' style (in deconstruction declarations) | |
Use preferred 'var' style (when type is simple) |
Xunit (1 inspection)
These inspections detect code issues related to xUnit.Net tests.
Inspection | |
---|---|
|