Inspections and Quick-Fixes in ReSharper
Helping you write better code, faster, and automatically fixes code issues.
What are Inspections and Quick-Fixes?
ReSharper warns you when there's a problem in your code at design time, so you see any errors, problems or possible improvements directly in the editor. Many of these inspections come with associated quick-fixes - an automated way of solving the issue by pressing Alt+Enter.
Inspections are shown in the editor, using different types of underlines. The type of underline depends on the severity of an inspection. They can be hints, suggestions, warnings, or errors. Certain inspections can also be plain informational and will use individual highlighting.
When hovering an inspection, ReSharper will show you that a quick-fix is available by showing a red (for errors) or yellow (for warnings, suggestions and hints) light bulb that appears to the left of a highlighted code line. You can see the list of available quick-fixes for a given error by clicking the light bulb, or by pressing Alt+Enter. Then, select an appropriate quick-fix from the list, and the issue will be resolved by ReSharper.
Inspections for Code Style
While ReSharper comes with a wide range of code inspections to notify us about redundancies in code, potential code quality issues or common practices, there are also a number of inspections that help with readability.
- Maintaining consistent code style with formatting inspections
- Configuring inspection severities with EditorConfig
- Code style settings from Roslyn conventions in EditorConfig
- StyleCop code style settings and inspections
Share Inspection Settings with the Team
ReSharper comes with severities pre-configured, but it's easy to change the severity of an inspection to your own or your team's preference. For example, some teams may want to enforce using
var in code by showing that inspection as an error, while others will opt for this being a suggestion. Some teams will prefer
string.Format(), while others prefer string interpolation. Changing the severity will help you and your team write more consistent code, and ReSharper will nudge you when something is off.
Most of the inspections have a configurable severity level.
Severities and several other settings can be shared with your team using settings layers.
Usage in Continuous Integration (CI)
ReSharper's code analysis can also be used while practicing continuous integration. For that, the ReSharper Command-Line Tools can be used. Specifically the
inspectcode command, will create a report with all the discovered code issues as a simple XML report. Such a report can either be manually examined with XML APIs, or reported to TeamCity to show as an additional report tab.