Skip to content

Suppressions

Deliberately exclude individual findings via code comments or an ignore file.

CodeCharter has three mechanisms for deliberately excluding findings.

1. Inline Suppression on the Next Line

// codecharter-disable-next-line DateTime-Direct-Usage
var migrationTimestamp = DateTime.UtcNow;

The directive applies to the immediately following line. The rule slug is optional — without it, all rules are suppressed on the next line.

2. Suppression on the Same Line or the Line Above

var migrationTimestamp = DateTime.UtcNow; // codecharter-disable DateTime-Direct-Usage

Or on the line above:

// codecharter-disable DateTime-Direct-Usage
var migrationTimestamp = DateTime.UtcNow;

3. File-Level Suppression

A single // codecharter-disable line anywhere in the file suppresses all findings for the entire file. Useful for auto-generated code or legacy files you don't want to touch right now.

// codecharter-disable
namespace Acme.Generated;

Suppressions via Ignore File

If you want to exclude entire paths or namespace areas, use .codecharterignore in the solution root or per project directory.

# Rule slug: namespace prefix
namespace-distance: Acme.Generated
namespace-distance: Acme.Migrations

# Exclude complete paths from analysis
[exclude]
**/tests/**
**/bin/**
**/obj/**
**/Generated/**

[exclude] is a section header for paths that are completely excluded from analysis.

More in File Structure.