Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions _rules/1150.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
rule_id: 1150
rule_category: member-design
title: Avoid local functions
severity: 3
---
Local functions (methods defined inside another method) can be useful in rare cases, but they often obscure a method's structure and make unit testing harder. Their usage often indicates a lack of proper decomposition.

Local functions can be a good fit for:
- Trivial private recursion.
- Iterator implementations (validate inputs upfront in the containing method, instead of during deferred execution).
- Extracting to a method would require passing many parameters that are otherwise captured.