🧩Flag overly complex function params

Flag overly complex function params

params
flags
params

Why Too Many Parameters Is a Problem

Functions with lots of parameters are easy to call incorrectly, especially when boolean flags are mixed in — the call site alone rarely tells you what each flag actually means. This tool takes the total parameter count, the number of boolean flags, and the number of optional parameters, then returns a complexity score that flags whether refactoring is worth doing now.

How the Score Is Calculated

FactorWeight
Per parameter+8 pts
Per boolean flag+10 pts
Per optional parameter+4 pts

Where to Start Refactoring

If your score comes out high, start by grouping related parameters into a single options object. Boolean flags hurt readability the most at the call site, so consider splitting the function per flag or replacing flags with an enum value instead.

Frequently Asked Questions

How many parameters is too many?

Readability typically drops past 4 parameters, and 6 or more usually calls for an options object or builder pattern.

Why do boolean flags increase complexity more?

Boolean flags are hard to read at the call site and add branching logic inside the function, multiplying test cases.

How should I refactor a high-scoring function?

Group related parameters into a single options object, or split flag-based behavior into separate functions.