| Property | Value |
|---|---|
| Package | Philips.CodeAnalysis.MaintainabilityAnalyzers |
| Diagnostic ID | PH2140 |
| Category | Maintainability |
| Analyzer | AvoidExcludeFromCodeCoverageAnalyzer |
| CodeFix | Yes |
| Severity | Error |
| Enabled By Default | Yes |
Avoid using the ExcludeFromCodeCoverage attribute, as this manipulates the code coverage measurements in an way that is not visible in the code coverage report.
Remove the attribute.
Code that triggers a diagnostic:
using System.Diagnostics.CodeAnalysis;
class BadExample
{
[ExcludeFromCodeCoverage]
public void BadMethod()
{
return;
}
}And the replacement code:
class GoodExample
{
public void GoodMethod()
{
return;
}
}This analyzer does not offer any special configuration. The general ways of suppressing diagnostics apply.