Skip to content

UNI002: Long method detected

What and why

Method exceeds length thresholds: lines >= 80 or CogCC >= 25 (Critical: lines >= 150 or CogCC >= 40).

Long methods are harder to test, review, and reuse.

Threshold: lines >= 80 or CogCC >= 25 (Critical: lines >= 150 or CogCC >= 40).

How to fix: extract helpers, apply guard clauses, or split by responsibility.

Default thresholds

Severity Condition
Warning lines >= 80 or CogCC >= 25
Critical lines >= 150 or CogCC >= 40

Fix guidance

Extract helper methods or decompose control flow (threshold: lines >= 80 or CogCC >= 25).

Tags

maintainability

Suppression

Place // unilyze-disable UNI002 -- reason in the leading trivia of the reported type or method declaration. Metric findings are matched by type or method name, so suppressing one overload also suppresses same-name overloads. For partial types, place the directive on the declaration indexed by unilyze. For project-wide suppression, use "rules": { "UNI002": "off" }; use a baseline to freeze existing findings while reporting new ones.