-
Notifications
You must be signed in to change notification settings - Fork 22
SA1409
TypeName |
RemoveUnnecessaryCode |
CheckId |
SA1409 |
Category |
Maintainability Rules |
A C# file contains code which is unnecessary and can be removed without changing the overall logic of the code.
A violation of this rule occurs when the file contains code which can be removed without changing the overall logic of the code.
For example, the following try-catch statement could be removed completely since the try and catch blocks are both empty.
try
{
}
catch (Exception ex)
{
}
The try-finally statement below does contain code within the try block, but it does not contain any catch blocks, and the finally block is empty. Thus, the try-finally is not performing any useful function and can be removed.
try
{
this.Method();
}
finally
{
}
As a final example, the unsafe statement below is empty, and thus provides no value.
unsafe
{
}
The fix a violation of this rule, remove the unnecessary code, or fill in the code with additional statements.
[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1409:RemoveUnnecessaryCode", Justification = "Reviewed.")]
- - SA0102 - Clean Install
- - Download
- - Documentation Rules - Layout Rules - Maintainability Rules - Naming Rules - Ordering Rules - Readability Rules - Spacing Rules - Suppressions
- - Adding a custom StyleCop settings page - Adding custom rule settings - Authoring a custom styleCop rule - Authoring rules metadata - Custom CSharp Language Service - Custom MSBuild Integration - Hosting StyleCop in a Custom Environment - Installing a Custom Rule - Integrating StyleCop Into Build Environments - Integrating StyleCop into MSBuild - Writing Custom Rules for StyleCop