Code Inspections in VB.NET
In VB.NET, JetBrains Rider 2023.1 provides two kinds of code inspections: 259 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 266 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 VB.NET inspections are listed below, grouped by their categories.
Code Notification (1 inspection)
This category groups code inspections with minor severity levels.
Inspection | |
---|---|
Inactive preprocessor branch |
Common Practices and Code Improvements (112 inspections)
This category groups inspections that hunt for medium severity issues that mainly affect code readability.
Inspection | |
---|---|
Annotation duplicate in hierarchy | |
Auto-property can be made get-only (non-private accessibility) | |
Auto-property can be made get-only (private accessibility) | |
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 local variable or field into constant (non-private accessibility) | |
Convert local variable or field into constant (private accessibility) | |
Convert property to auto-property | |
Convert property to auto-property when possible | |
Convert property to auto-property with private setter | |
Field can be made readonly (non-private accessibility) | |
Field can be made readonly (private accessibility) | |
Get-only auto-property is never assigned | |
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) | |
Multiple nullable attributes usage | |
Nullability attribute usage with declaration of void or value type | |
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) | |
Remove ToList() | |
Remove ToList() | |
Replace with FirstOrDefault($args$) | |
Replace with LastOrDefault($args$) | |
Replace with OfType<T>() (replace with OfType(Of ..)()) | |
Replace with OfType<T>() (replace with OfType(Of ..)()) | |
Replace with OfType<T>().Any() (replace with OfType(Of ..)().Any()) | |
Replace with OfType<T>().Any() (replace with OfType(Of ..)().Any(..)) | |
Replace with OfType<T>().Count() (replace with OfType(Of ..)().Count()) | |
Replace with OfType<T>().Count() (replace with OfType(Of ..)().Count(..)) | |
Replace with OfType<T>().First() (replace with OfType(Of ..)().First()) | |
Replace with OfType<T>().First() (replace with OfType(Of ..)().First(..)) | |
Replace with OfType<T>().FirstOrDefault() (replace with OfType(Of ..)().FirstOrDefault()) | |
Replace with OfType<T>().FirstOrDefault() (replace with OfType(Of ..)().FirstOrDefault(..)) | |
Replace with OfType<T>().Last() (replace with OfType(Of ..)().Last()) | |
Replace with OfType<T>().Last() (replace with OfType(Of ..)().Last(..)) | |
Replace with OfType<T>().LastOrDefault() (replace with OfType(Of ..)().LastOrDefault()) | |
Replace with OfType<T>().LastOrDefault() (replace with OfType(Of ..)().LastOrDefault(..)) | |
Replace with OfType<T>().Single() (replace with OfType(Of ..)().Single()) | |
Replace with OfType<T>().Single() (replace with OfType(Of ..)().Single(..)) | |
Replace with OfType<T>().SingleOrDefault() (replace with OfType(Of ..)().SingleOrDefault()) | |
Replace with OfType<T>().SingleOrDefault() (replace with OfType(Of ..)().SingleOrDefault(..)) | |
Replace with OfType<T>().Where() (replace with OfType(Of ..)().Where(..)) | |
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$) | |
Return type can be IEnumerable<T> (non-private accessibility) | |
Return type can be IEnumerable<T> (private accessibility) | |
Simplify conditional operator | |
Simplify expression | |
Simplify expression | |
Simplify expression | |
Simplify expression | |
Simplify expression | |
Simplify expression | |
Simplify expression | |
Simplify expression | |
Simplify expression | |
Simplify expression | |
Simplify 'IIf' | |
Specify string comparison explicitly | |
String.Compare is culture-specific (string.Compare(string, int, string, int) is culture-specific) | |
String.Compare is culture-specific (string.Compare(string, int, string, int, bool) is culture-specific) | |
String.Compare is culture-specific (string.Compare(string, int, string, int, bool) 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 | |
Use array creation expression | |
Use array creation expression | |
Use First() instead | |
Use method Any() | |
Use method Any() | |
Use method Any() | |
Use method Any() | |
Use method Any() | |
Use method IsInstanceOfType(..) | |
Use 'TypeOf .. Is ..' operator | |
Use 'TypeOf .. Is ..' operator |
Compiler Warnings (24 inspections)
Inspections in this category detect compiler warnings before you compile.
Inspection | |
---|---|
Access of shared member through an instance | |
Async method lacks 'Await' operators | |
| |
Field is never used | |
Function doesn't return a reference type value on all code paths | |
Function doesn't return a struct value on all code paths | |
Member shadows an overriable member | |
| |
Namespace should be default namespace of this project | |
Non-accessed field | |
Non-accessed local variable | |
Redundant DirectCast to the equals value type | |
Runtime errors are likely to occur when converting X to Y | |
Runtime errors might occur when converting X to Y | |
| |
The CallerArgumentExpressionAttribute applied to parameter will have no effect because it's self-referential | |
The CallerArgumentExpressionAttribute applied to parameter will have no effect. It is applied with an invalid parameter name. | |
Unassigned field | |
Unassigned readonly field | |
Unused local variable | |
Use obsolete member | |
Use obsolete member (without message) | |
Variable is used before it has been assigned a value | |
XML comment has a tag with a 'cref' attribute that could not be resolved |
Constraints Violations (2 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 | |
---|---|
| |
Namespace does not correspond to file location |
Language Usage Opportunities (7 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 | |
---|---|
Convert static method invocation into extension method call | |
Foreach loop can be converted into LINQ-expression but another 'GetEnumerator' method will be used | |
Loop can be converted into LINQ-expression | |
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 | |
Use string interpolation expression |
Potential Code Quality Issues (65 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 | |
Abstract or virtual (overridable) event is never invoked | |
Access to disposed captured variable | |
Access to foreach variable in closure | |
Access to modified captured variable | |
Annotation conflict in hierarchy | |
Auto-property accessor is never used (non-private accessibility) | |
Auto-property accessor is never used (private accessibility) | |
Call to base member with implicit default parameters | |
Call to 'base.Equals(...)' is reference equality | |
Cannot resolve property | |
Cannot resolve resource | |
Cannot resolve resource item | |
Cannot resolve symbol in text argument | |
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) | |
| |
Equality comparison of floating point numbers | |
Event is never subscribed to (non-private accessibility) | |
Event is never subscribed to (private accessibility) | |
Event never invoked | |
Exception rethrow possibly intended | |
Explicit argument passed to parameter with caller info attribute | |
| |
'GC.SuppressFinalize' is invoked for type without destructor | |
Iterator never returns | |
| |
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-readonly type member referenced in 'GetHashCode()' | |
'Object.ReferenceEquals' is always false because it is called with value type | |
Operator 'is'/'Type Of ... Is ...' can be used | |
'out' parameter is not assigned upon exit | |
Overridden GetHashCode calls base 'Object.GetHashCode()' | |
| |
| |
Possible incorrect implementation of Double-Check Locking pattern. Read access to checked field. | |
| |
| |
Possible write to 'Me' | |
Possibly impure struct method is called on readonly variable: struct value always copied before invocation | |
Return value of pure method is not used | |
Similar expressions comparison | |
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 type conversion or check | |
Symbol from module that might be missing at runtime | |
The 'l' suffix is easily confused with the digit '1' | |
Thread static field has initializer | |
Type check and casts can be merged | |
Unassigned field (non-private accessibility) | |
Unassigned field (private accessibility) | |
Unassigned readonly field | |
Use format specifier in format strings | |
Value assigned to a property of non-variable qualifier expression can be lost | |
'void' method is annotated by [Pure] attribute |
Redundancies in Code (23 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 | |
---|---|
| |
Explicit 'value' parameter declaration is redundant | |
Expression is always 'true' or always 'false' | |
Iterator function without 'Yield' statements | |
Keyword 'Then' is redundant in multiline 'If' statement | |
Parameterless property parentheses are redundant | |
Parentheses are redundant if attribute has no arguments | |
Redundant argument passed to caller argument expression parameter | |
Redundant array lower bound specification | |
| |
Redundant empty 'Case Else' statement | |
Redundant explicit size specification in array creation | |
Redundant 'Me.' qualifier | |
Redundant 'MyBase.' qualifier | |
Redundant 'MyClass.' qualifier | |
Redundant operand in logical conditional expression | |
Redundant qualifier | |
Remove redundant parentheses | |
Unreachable code | |
Unused import clause | |
Use implicit 'ByVal' modifier | |
Use implicitly typed variable declaration | |
Use implicitly typed variable declaration (evident) |
Redundancies in Symbol Declarations (29 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) | |
Entity is only used to capture its name (non-private accessibility) | |
Entity is only used to capture its name (private accessibility) | |
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 | |
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) | |
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) | |
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 | |
---|---|
| |
| |
|