Code Inspections in C#
In C#, JetBrains Rider 2023.2 provides two kinds of code inspections: 1070 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 879 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 (161 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 | |
Add explicit 'return' or 'continue' before local functions | |
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 the overrider does not have it | |
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' into 'while' | |
| |
Convert local variable or field into constant (non-private accessibility) | |
Convert local variable or field into 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) | |
Dictionary lookup can be simplified with 'TryAdd' | |
Dictionary lookup can be simplified with 'TryGetValue' | |
| |
| |
Extract common property pattern | |
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 | |
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 the base type | |
Parameter can be declared with the 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) | |
Put local function after 'return' or 'continue' | |
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 can be made file-local | |
Type parameter could be declared as covariant or contravariant | |
Use 'ArgumentNullException.ThrowIfNull' | |
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 'MinBy' or 'MaxBy' instead of ordering and taking 'First' or 'Last' | |
| |
Use 'Type.EmptyTypes' |
Compiler Warnings (170 inspections)
Inspections in this category detect compiler warnings before you compile.
Inspection | |
---|---|
| |
[InterpolatedStringHandlerArgument] has no effect when applied to lambda parameters and will be ignored at the call site. | |
A local variable is returned by reference but was initialized to a value that cannot be returned by reference. | |
A member of a variable is returned by reference but was initialized to a value that cannot be returned by reference | |
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 | |
A result of a stackalloc expression in this context may be exposed outside of the containing method. | |
| |
Alignment value 'value' has a magnitude greater than 'magnitude limit' and may result in a large formatted string. | |
Ambiguous reference in XML comment | |
Argument cannot be used as an output for parameter due to differences in the nullability of reference types. | |
Argument cannot be used for corresponding parameter due to differences in the nullability of reference types. | |
Assignment in conditional expression | |
Assignment made to same variable | |
Async function without await expression | |
Async method invocation without await expression | |
Asynchronous 'Main' method will not be used as an entry point because a synchronous entry point was found. | |
Async-iterator has one or more parameters of type 'CancellationToken' but none of them is annotated with the 'EnumeratorCancellation' attribute. | |
| |
| |
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() | |
| |
Comparing with null of nullable value type always produces 'false' | |
Comparison to integral constant is useless; the constant is outside the range of type 'type'. | |
Converting method group to non-delegate type 'object'. | |
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 | |
Default value specified for parameter will have no effect because it applies to a member that is used in contexts that do not allow optional arguments | |
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 explicit interface specifier doesn't match interface implemented by the type. | |
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 return type doesn't match the target delegate (possibly because of nullability attributes). | |
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 a parameter doesn't match the target delegate (possibly because of nullability attributes). | |
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 return type doesn't match implemented member (possibly because of nullability attributes). | |
Nullability of return type doesn't match implicitly implemented member (possibly because of nullability attributes). | |
Nullability of return type doesn't match overridden member (possibly because of nullability attributes). | |
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. | |
Nullability of type of parameter doesn't match implemented member (possibly because of nullability attributes). | |
Nullability of type of parameter doesn't match implicitly implemented member (possibly because of nullability attributes). | |
Nullability of type of parameter doesn't match overridden member (possibly because of nullability attributes). | |
Nullable value type may be null. | |
Object or collection initializer implicitly dereferences possibly null member. | |
Obsolete members should not be required. | |
| |
Opt in to preview features before using them. | |
Parameter has no matching param tag in the XML comment | |
Parameter has params modifier in lambda but not in target delegate type. | |
Parameter must conditionally have a non-null value when exiting a function. | |
Parameter must have a non-null value when exiting because parameter mentioned in [NotNullIfNotNull] annotation is non-null. | |
Parameter must have a non-null value when exiting. | |
Parameter occurs after interpolated string handler parameter in the parameter list. | |
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 | |
Return value must be non-null because parameter mentioned in [NotNullIfNotNull] annotation is non-null. | |
Static type in 'is' or 'as' operator. | |
Struct member returns 'this' or other instance members by reference. | |
| |
Taking address of marshal-by-reference class field | |
The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. | |
The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source. | |
The branches of the ref conditional operator refer to variables with incompatible declaration scopes. | |
The CallerArgumentExpressionAttribute applied to parameter will have no effect because it's self-referential | |
The CallerArgumentExpressionAttribute is applied with an invalid parameter name. | |
The CallerArgumentExpressionAttribute will have no effect because it applies to a member that is used in contexts that do not allow optional arguments | |
The CallerArgumentExpressionAttribute will have no effect; it is overridden by the CallerFilePathAttribute | |
The CallerArgumentExpressionAttribute will have no effect; it is overridden by the CallerLineNumberAttribute | |
The CallerArgumentExpressionAttribute will have no effect; it is overridden by the CallerMemberNameAttribute | |
The default parameter value does not match in the target delegate type. | |
The 'EnumeratorCancellation' attribute is only effective on a parameter of type 'CancellationToken' in an async-iterator method returning 'IAsyncEnumerable<>'. | |
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 'Main' method will not be used as an entry point because compilation unit with top-level statements was found. | |
The result of the expression is always 'null' of nullable type | |
The result of the expression is always 'true' or 'false' since a value of value type is never equal to 'null' | |
The result of the expression is always 'true' or 'false' since a value of value type is never equal to 'null' | |
The 'scoped' modifier of a parameter doesn't match target delegate. | |
The 'scoped' modifier of parameter doesn't match overridden or implemented member. | |
The switch expression does not handle all possible inputs (it is not exhaustive). | |
The switch expression does not handle all possible values of its input type (it is not exhaustive). However, a pattern with a 'when' clause might successfully match this value. | |
The switch expression does not handle some null inputs (it is not exhaustive). | |
The switch expression does not handle some null inputs (it is not exhaustive). However, a pattern with a 'when' clause might successfully match this value. | |
The switch expression does not handle some values of its input type (it is not exhaustive) involving an unnamed enum value. | |
The tuple element name is ignored because a different name or no name is specified by the target type. | |
The tuple element name is ignored because a different name or no name is specified on the other side of the tuple == or != operator. | |
The type name only contains lower-cased ASCII characters. Such names may become reserved for the language | |
| |
This ref-assigns a value that can only escape the current method through a return statement. | |
This ref-assigns a value that has a wider value escape scope than the target allowing assignment through the target of values with narrower escapes scopes. | |
This ref-assigns an expression to a variable with a narrower escape scope. | |
This returns a member of local by reference but it is not a ref local. | |
This returns a parameter by reference but it is not a ref parameter. | |
This returns a parameter by reference but it is scoped to the current method. | |
This returns a parameter by reference through a ref parameter; but it can only safely be returned in a return statement. | |
This returns by reference a member of parameter that is not a ref or out parameter. | |
This returns by reference a member of parameter that is scoped to the current method. | |
This returns by reference a member of parameter through a ref parameter; but it can only safely be returned in a return statement. | |
This returns local by reference but it is not a ref local. | |
This takes the address of, gets the size of, or declares a pointer to a managed type. | |
Thrown value may be null. | |
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 a variable in this context may expose referenced variables outside of their declaration scope. | |
| |
Use of obsolete symbol (without message) | |
Using 'is' to test compatibility with 'dynamic' is essentially identical to testing compatibility with 'Object' and will succeed for all non-null values | |
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 or required 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 |
Entity Framework (4 inspections)
This category groups code inspections that validate usages of types and members from Entity Framework and their derivatives.
Inspection | |
---|---|
Possible multiple queries to the database (N+1 problem) | |
Possible multiple queries to the database for related entities (N+1 problem) | |
Query can return incomplete data for related entities | |
Usage of navigational property can return incomplete data |
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 (indent level is not restored) | |
Incorrect indent (missing indent/outdent elsewhere) | |
Incorrect indent (redundant indent/outdent 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 (80 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 | |
Conditional expression can be rewritten as null-coalescing | |
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 constructor into member initializers | |
Convert constructor into primary constructor | |
Convert delegate variable into local function | |
Convert 'if' statement into 'switch' | |
Convert into 'await using' statement or declaration | |
Convert into lambda expression | |
Convert into static class | |
Convert into 'using' declaration | |
Convert lambda expression into method group | |
Convert negated 'is' expression into 'is' expression with negated pattern | |
Convert 'Nullable<T>' into 'T?' | |
Convert property into auto-property | |
Convert property into auto-property (when possible) | |
Convert property into auto-property with private setter | |
Convert static method invocation into extension method call | |
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 rewritten as '?:' expression | |
'if' statement can be rewritten as '??' expression | |
'if' statement can be rewritten as '??=' assignment | |
'if-return' statement can be rewritten 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 | |
Lambda expression/anonymous method can be made 'static' | |
Lambda expression/anonymous method must be 'static' to avoid allocations | |
Lambda expression/anonymous method must not have captures of the containing context | |
Literal length can be reduced by using verbatim string | |
Loop can be converted into LINQ-expression | |
Merge 'and' pattern | |
Merge conditional ?: expression into conditional access | |
Merge negated null/pattern checks into complex pattern | |
Merge nested property patterns | |
Merge null/pattern checks into complex pattern | |
Merge null/pattern/value checks into 'or'/'and' patterns | |
Merge sequential checks into single conditional access check | |
Move to existing positional deconstruction pattern | |
Move variable declaration inside loop condition | |
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 | |
Pass string interpolation expression | |
Redundant accessor body | |
Replace auto-property with computed property | |
Replace if statement with null-propagating code | |
Replace object pattern not performing any additional checks with 'var' pattern | |
Replace 'SequenceEqual' with constant pattern | |
Replace 'Slice' with range indexer | |
Replace 'Substring' with range indexer | |
Replace 'switch' statement with 'switch' expression | |
Replace ternary expression with 'switch' expression | |
Replace with 'field' keyword | |
Replace with primary constructor parameter | |
Use compound assignment | |
| |
Use deconstruction | |
Use deconstruction to swap variables | |
Use discard assignment | |
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 name | |
Use 'nameof' expression when registering a DependencyProperty | |
Use object or collection initializer when possible | |
Use positional deconstruction pattern | |
Use raw string | |
Use string interpolation expression | |
Use type annotation syntax | |
Use unsigned right shift operator '>>>' | |
Use UTF-8 string literal | |
Use 'with' expression to copy anonymous object | |
Use 'with' expression to copy record | |
Use 'with' expression to copy struct | |
Use 'with' expression to copy tuple |
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. Non-public test method. | |
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. Missing Test or TestFixture attribute. | |
NUnit.AutoFixture. Redundant argument in InlineAutoData attribute. |
Potential Code Quality Issues (182 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] does not 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 | |
Backing field is assigned but never used | |
Backing field is used but never assigned | |
Bitwise operation on enum 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 content is never queried (non-private accessibility) | |
Collection content is never queried (private accessibility) | |
Collection is never updated (non-private accessibility) | |
Collection is never updated (private accessibility) | |
Constant shift expression with non-zero operands results in a zero value | |
| |
Division by zero in at least one execution path | |
Do not store SpinLock in readonly field | |
Do not use object initializer for 'using' variable | |
Do not use object initializer for 'using' variable (object initializer expression may throw exception while initializing 'using' variable) | |
| |
| |
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 according to integer analysis | |
Heuristically unreachable switch arm according to integer analysis | |
Inconsistent arguments passed to 'Math.Clamp()' method | |
Inconsistent order of taken locks | |
Inconsistent synchronization on field | |
Index from end must be greater than zero; use '^1' to refer to the last element | |
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 is not marked as ServiceContract | |
Method with optional or 'params' parameter is hidden by overload | |
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-accessed positional property (non-private accessibility) | |
Non-accessed positional property (private accessibility) | |
Non-public member in implementation class hides default implementation in interface | |
Non-readonly type member referenced in 'GetHashCode()' | |
Nullability conflicts with annotations in hierarchy | |
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 | |
Operator without matching checked operator | |
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 | |
Possible overflow in checked context | |
Possible overflow in unchecked context | |
Possible 'System.ArgumentOutOfRangeException'. Index must be a non-negative integer. | |
Possible 'System.ArgumentOutOfRangeException'. Start index must 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 | |
Potentially misleading parameter name in lambda or local function | |
'ref' or 'out' parameter with [Optional] attribute | |
Return of a task produced by 'using'-captured object | |
Return of a variable captured by 'using' statement | |
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 | |
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 locking over synchronization primitive | |
Suspicious parameter name in ArgumentNullException | |
Suspicious shift count for this type of left operand | |
Suspicious type conversion or check | |
Suspicious use of variable with discard-like name | |
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 expression of 'is' operator is never of the provided type | |
The given expression of 'is' operator is always of the provided type | |
The pattern is redundant, it does not produce any runtime checks | |
The source expression always matches the provided pattern | |
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 null check instead of a type check succeeding on any not-null value | |
Use null check pattern instead of a type check succeeding on any not-null value | |
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 | |
'with' expression modifies all accessible instance members |
Redundancies in Code (97 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 | |
'??' condition is never null according to nullable reference types' annotations | |
[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 | |
Conditional access qualifier expression is not null according to nullable reference types' annotations | |
| |
| |
Empty region | |
Explicit delegate creation expression is redundant | |
Expression is always 'null' | |
Expression is always 'true' or always 'false' | |
Expression is always 'true' or 'false' according to nullable reference types' annotations | |
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 into local variable | |
Raw string can be simplified | |
Redundant [AttributeUsage] attribute property assignment | |
| |
Redundant anonymous type property explicit name | |
Redundant argument passed to caller argument expression parameter | |
Redundant argument with default value | |
Redundant arithmetic overflow checking context | |
Redundant 'Attribute' suffix | |
Redundant 'base.' qualifier | |
Redundant boolean comparison | |
Redundant braces in collection initializer | |
| |
Redundant 'case' label before default section | |
| |
| |
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 dictionary 'ContainsKey' before adding to the collection | |
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 nullable directive | |
Redundant nullable warning suppression expression | |
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 'scoped' parameter modifier | |
Redundant semicolon after type or namespace declaration | |
Redundant set 'Contains' before 'Add' | |
Redundant string interpolation | |
Redundant 'string.Format()' call | |
Redundant 'string.ToCharArray()' call | |
Redundant type arguments of method | |
Redundant type check in a pattern | |
Redundant type declaration body | |
| |
Redundant verbatim prefix | |
Redundant verbatim string prefix | |
Redundant 'virtual' modifier | |
Redundant 'WithCancellation()' invocation | |
Remove redundant pattern-matching parentheses | |
Subpattern that always matches is redundant | |
'true' is redundant as 'for'-statement condition | |
Type check for nullable type is equal to underlying type check | |
Unsafe context declaration is redundant | |
Unused nullable directive |
Redundancies in Symbol Declarations (49 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' must 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 | |
Non-accessed local variable only used to discard the 'out' parameter value | |
Not accessed primary constructor parameter | |
Parameter is only used for precondition check (non-private accessibility) | |
Parameter is only used for precondition check (private accessibility) | |
Parameter output value is always discarded (non-private accessibility) | |
Parameter output value is always discarded (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 (46 inspections)
Inspections in this category detect violations of code syntax styles. In contrast to most 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 Control+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 in section | |
Join or separate 'var' in deconstruction declarations | |
Place assignment expression into block | |
| |
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 into constructor or destructor with preferred body style) | |
Use preferred body style (convert into local function with preferred body style) | |
Use preferred body style (convert into method or operator with preferred body style) | |
Use preferred body style (convert into 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 namespace body style | |
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) |
Unreal Build System (2 inspections)
Inspection | |
---|---|
Dependency for the plugin is missing in the project file | |
Module with this name does not exist |
Xunit (1 inspection)
These inspections detect code issues related to xUnit.Net tests.
Inspection | |
---|---|
|