Code Inspections in VB.NET
In VB.NET, ReSharper 2018.2 provides two kinds of code inspections: 252 inspections that detect errors such as broken syntax, unresolved symbols, compiler errors, etc. (you cannot configure or disable any of these inspections), and 247 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 (107 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) | | | |
| | ||
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 to constant (non-private accessibility) | | | |
Convert local variable or field to constant (private accessibility) | | | |
Convert property to auto-property | | | |
Convert property to auto-property when possible | | | |
Convert property to auto-property with private setter | | | |
| | ||
| | ||
Get-only auto-property is never assigned | | | |
| | ||
| | ||
| | ||
| | ||
Member can be made static(shared) (non-private accessibility) | | | |
| | ||
Member or type can be made internal(friend) | | | |
| | ||
Nullability attribute usage with declaration of void or value 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() | | | |
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) | | | |
| | ||
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' | | | |
| | ||
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) | | | |
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 (22 inspections)
Inspections in this category detect compiler warnings before you compile.Inspection | |||
---|---|---|---|
| | ||
Async method lacks 'Await' operators | | | |
| | ||
Field is never used | | | |
Function doesn't return a value on all code paths | | | |
Function doesn't return a value on all code paths | | | |
| | ||
| | ||
Namespace should be default namespace of this project | | | |
Non-accessed field | | | |
Non-accessed local variable | | | |
Redundant DirectCast to the equals value type | | | |
| | ||
Runtime errors might occur when converting X to Y | | | |
Syntax error in XML comment | | | |
Unassigned field | | | |
Unassigned readonly field | | | |
Unused local variable | | | |
Use obsolete member | | | |
| | ||
| | ||
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 ReSharper's code annotations, and other similar issues.Inspection | |||
---|---|---|---|
| | ||
| |
Language Usage Opportunities (4 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 to extension method call | | | |
| | ||
Part of loop's body can be converted into LINQ-expression | | | |
| |
Potential Code Quality Issues (60 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 | |||
---|---|---|---|
| | ||
| | ||
Abstract or virtual(overridable) event is never invoked | | | |
| | ||
| | ||
| | ||
Annotation conflict in hierarchy | | | |
Assignment to a property of a readonly field can be useless | | | |
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 | | | |
| | ||
| | ||
Class is never instantiated (private accessibility) | | | |
| | ||
| | ||
Collection's content is never queried (non-private accessibility) | | | |
Collection's content is never queried (private accessibility) | | | |
Element is localizable | | | |
| | ||
Event is never subscribed to (non-private accessibility) | | | |
Event is never subscribed to (private accessibility) | | | |
Event never invoked | | | |
Exception rethrow possibly intended | | | |
| | ||
'GC.SuppressFinalize' is invoked for type without destructor | | | |
Impure method is called for readonly field of value type | | | |
Iterator never returns | | | |
| | ||
Non-accessed field (non-private accessibility) | | | |
| | ||
| | ||
'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' | | | |
| | ||
Similar expressions comparison | | | |
| | ||
Static member initializer refers to static member below or in other part | | | |
String formatting method problems | | | |
Suspicious type conversion or check | | | |
The 'l' suffix is easily confused with the digit '1' | | | |
| | ||
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 | | | |
'void' method is annotated by [Pure] attribute | | |
Redundancies in Code (22 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 | | | |
| | ||
Iterator function without 'Yield' statements | | | |
Keyword 'Then' is redundant in multiline 'If' statement | | | |
Parameterless property parentheses are redundant | | | |
| | ||
Redundant array lower bound specification | | | |
| | ||
Redundant empty 'Case Else' statement | | | |
| | ||
Redundant 'Me.' qualifier | | | |
Redundant 'MyBase.' qualifier | | | |
Redundant 'MyClass.' qualifier | | | |
| | ||
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 (26 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) | | | |
Local entity is only used to capture its name | | | |
| | ||
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) | | | |
Type member is never accessed via base type (non-private accessibility) | | | |
Type member is never accessed via base type (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 of local function | | | |
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 | |||
---|---|---|---|
| | ||
| | ||
| |