Skip to content

Rules Reference

MonadicLeaf enforces 10 green-code rules, grouped by severity.

Error rules (block CI by default)

RuleNameDescription
GC001No bare throwPublic methods must not throw — return Result<T> instead
GC002No nullable returnFailable methods must return Option<T> instead of T?
GC003No unhandled ResultEvery Result<T> must be matched, bound, or explicitly discarded
GC004No bool for failableMethods that can fail must not return bool — use Result<T>
GC005No out parametersUse Option<T> instead of TryGet-style out params
GC006No swallowed catchEmpty catch blocks are forbidden

Warning rules

RuleNameDescription
GC007Prefer Bind over awaitSequential Result chains should use BindAsync instead of nested await
GC008Prefer Map over manual SelectUse Map instead of manually unwrapping and rewrapping values
GC009No nested ResultResult<Result<T>> is always a modeling error
GC010Prefer Match at boundariesUnwrap Results at the outermost layer — not mid-pipeline

Auto-fixable rules

Rules marked with 🔧 can be fixed automatically with leaf migrate:

🔧 GC001, GC002, GC003, GC005, GC009

Released under the MIT License.