Rider Help

Code Inspections

Rider provides over 2300 code inspections in all supported languages. These inspections are used to detect and highlight code issues in design time in all opened files and/or to find all code issues in specific scope, which can be as large as the entire solution.

Code inspections can be roughly divided into the following groups:

  • Inspections with the fixed severity level 'Error'. These inspections detect compiler errors.
  • Inspections with configurable severity levels, which detect the rest of code issues (e.g. compiler warnings, runtime and logical errors, code smells, redundancies, improvement suggestions, etc.). You can find these configurable inspections on the Editor | Inspection Severity page of Rider settings (Ctrl+Alt+S). You can change severity level or disable any of the configurable inspections.

Severity levels of Code Inspections

All Rider code inspections have one of the following severity levels:

Error

Code inspections that have the 'Error' severity level by default are aimed at code issues that either prevent your code from compiling or result in runtime errors. Most of these inspections are not configurable, i.e. you cannot disable them or change their severity level.

In design-time inspection, Rider displays unresolved symbols in red:

/help/img/dotnet/2017.2/Code_Analysis__Code_Highlighting__Errors__1.png
and highlights erroneous statements or part of them with a red curly underline:
/help/img/dotnet/2017.2/Code_Analysis__Code_Highlighting__Errors__2.png
If there is at least one error in the current file, the status indicator displays the Error /help/img/dotnet/2017.2/ThemedIcon.ErrorStripeError.Screen.[Gray].png icon, and red markers are shown for each error on the marker bar.

Code issues that are found with inspections having the 'Error' severity level, appear in the Errors in Solution window if the solution-wide analysis is enabled.

Warning

This severity level corresponds to compiler warnings and to other issues that do not prevent your code from compiling but may nevertheless represent serious coding inefficiencies. For example, Rider informs you about redundant type casts or namespace import directives, incorrect format strings, declared but never used local variables or private fields, unused private methods, etc.

In design-time inspection, Rider displays redundant symbols with greyed text:

/help/img/dotnet/2017.2/Code_Analysis__Code_Highlighting__Warnings__1.png
and highlights statements or part of them with a blue curly underline:
/help/img/dotnet/2017.2/Code_Analysis__Code_Highlighting__Warnings__2.png
If there is at least one warning in the current file, the status indicator displays the Warning /help/img/dotnet/2017.2/ThemedIcon.ErrorStripeWarning.Screen.[Gray].png icon, and yellow markers are shown for each warning on the marker bar.

Warnings also appear in the Errors in Solution window if the solution-wide analysis with warnings is enabled

Suggestion

Code issues with this severity level provide insights into code structure, drawing your attention to things that aren't necessarily bad or wrong, but probably useful to know.

For instance, you might be interested to know that 'parameter can be declared with base type', meaning that your method only uses members of the parameter's base type. This can be an indication of a different error, such as failure to take into account the specifics of the actual parameter type. Based on this knowledge, you may want to change the parameter's type - or not, if that is by design.

In design-time inspection, Rider highlights suggestions with a green curly underline:

/help/img/dotnet/2017.2/Code_Analysis__Code_Highlighting__Suggestions__1.png
and adds green markers for each warning on the marker bar.

Hint

This is the lowest severity level. Code issues with this severity simply bring your attention to a particular code detail and/or recommends a way of improvement.

In design-time inspection, Rider highlights hints by adding a dashed green underline to the initial two letters of the corresponding symbol:

/help/img/dotnet/2017.2/Code_Analysis__Code_Highlighting__Hints__1.png
Unlike errors, warnings and suggestions, hints are not taken into account when you navigate between code issues in the editor, and not shown in the marker bar.

Note that when you set the caret over a highlighted hint, no pop-up is shown, the corresponding message only appears in the status bar.

Severity levels of most code inspections (except those detecting compiler errors) can be changed, i.e. you can define severity levels for each code inspection according to your needs.

When you inspect code in specific scope, Rider adds corresponding icons to the detected issues and allows sorting issues by the severity level in the Inspection Results window.

Categories of Code Inspections

Rider groups configurable code inspections by several categories. These categories roughly define purposes of inspections and kinds of code issues that they detect. The categories are used to group code inspections on the Editor | Inspection Severity page of Rider settings (Ctrl+Alt+S), and to group code issues found in specific scope and displayed in the Inspection Results window.

  • Potential Code Quality Issues
    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.
  • Common Practices and Code Improvements
    This category groups inspections that hunt for medium severity issues that mainly affect code readability.
  • Redundancies in Code
    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.
  • Language Usage Opportunities
    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.
  • Code Notifications
    This category groups code inspections with minor severity levels.
  • Code Style
    Inspections in this category detect violations of code style rules. In contrast to the rest of 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 in the Code Editing | [Language] | Code Style pages of ReSharper options. You can also fix issues that these inspection detect, using code cleanup. For more information, see Code Style and Cleanup.
  • Constraints Violations
    This category includes code inspections, mostly with the warning severity level, which detect violations related to symbol attributes, including Rider's code annotations, and other similar issues.
  • Redundancies in Symbol Declaration
    This category includes code inspections, mostly with the warning severity level, which detect empty and unused symbol declarations.
  • Compiler Warnings
    Inspections in this section detect compiler warnings before you compile.
  • NUnit
    These inspections detect code issues related to NUnit tests.

Last modified: 11 October 2017

See Also