All rules

Nullability and Type Safety

Detects null-forgiving operator (!) overuse, pragma warning disables for nullable, and unchecked as-casts that bypass the type system.

Why this rule exists

Every ! and #pragma warning disable nullable is a promise to the compiler that the developer knows better. When that promise is wrong, you get a NullReferenceException with no help from the type system.

Code example

Triggers the rule
+ var name = user!.Profile!.DisplayName!;
Passes the rule
+ var name = user?.Profile?.DisplayName
+     ?? throw new InvalidOperationException("Profile missing");

Configuration

Disable or adjust the severity of this rule in .gauntletci.json:

{
  "rules": {
    "GCI0043": { "enabled": true, "severity": "Info" }
  }
}

See Configuration for the full schema.

Related rules

Real-world evidence

Implemented in src/GauntletCI.Core/Rules/Implementations/GCI0043_*.cs.

About the author

Eric Cogen -- Founder, GauntletCI

Twenty years as a senior technical consultant building and modernizing enterprise platforms across .NET, AWS, serverless, microservices, and AI-driven systems.