Skip to content

Latest commit

 

History

History
51 lines (39 loc) · 1.31 KB

File metadata and controls

51 lines (39 loc) · 1.31 KB

PH2140: Avoid ExcludeFromCodeCoverage

Property Value
Package Philips.CodeAnalysis.MaintainabilityAnalyzers
Diagnostic ID PH2140
Category Maintainability
Analyzer AvoidExcludeFromCodeCoverageAnalyzer
CodeFix Yes
Severity Error
Enabled By Default Yes

Introduction

Avoid using the ExcludeFromCodeCoverage attribute, as this manipulates the code coverage measurements in an way that is not visible in the code coverage report.

How to solve

Remove the attribute.

Example

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;
    }
}

Configuration

This analyzer does not offer any special configuration. The general ways of suppressing diagnostics apply.