Code Issues fixes and suppression
Code Issues can be easily fixed with the corresponding code fixes. The code fixes are operations that allow you to automatically fix the issue by changing the source code, so the issue is no longer valid for the block of code in question. The code fixes are refactoring or code providers assigned to the code issues as fixes.
There are several ways to fix an issue:
- Code Fix hint
- Zoom Window
- Manually apply a fix
The hint shows not only the list of code issues, but when you hover the mouse over the issue highlighted in the code editor, available code fixes. You can also see this hint when hovering over the left view bar. Clicking the link with the name of the code fix will automatically fix the issue. Hovering over a link will also show you a preview hint of changes being made after the fix is applied.
This window appears when you hover the mouse over the marks on the right document bar. The window behaves as a container of several Code Fix hints. Clicking the link works similarly to the Code Fix hint.
The fix for an issue can be applied the same way as all other refactoring and/or code operations. For example, from the Refactor!/Code! popup menu:
If you don’t like some of the issues or don’t want them to appear in a specific source code, you can easily suppress them for different scopes, such as:
You can also completely disable the issue. If you have disabled the issue, you can reenable it on the code issues Catalog options page:
To suppress an issue, click the blue triangle on the code fix hint, after which the Suppression menu appears with several options available:
Once you have suppressed the issue, you are able to restore it on the Editor | Code Analysis | Issue Suppression options page:
Here, you can see the list of previously suppressed code issues and remove them from this list. After they are removed, they appear again in the source code if appropriate. On this options page, you can also change the suppression scope for the specific code issue.
The suppression settings are individual for every solution and are stored near the solution cache.
This post is a part of post series about CodeRush Code Issues technology. To learn more about code issues, please refer to the appropriate topics:
- Code Issues technology overview
- Code Issues types overview
- Code Issues visual presentation
- Code Issues fixes and suppression (current post)
- Code Issues navigation techniques
- Code Issues tool window
- Code Issues configuration and options
- Code Issues overall list
- Creating your own code issue