Credence.Pattern.NoRedundantLocalCapture (credence v0.8.0)

Copy Markdown

Detects redundant capture of a local function with immediate call.

Capturing a local function reference (var = &fn/arity) and then calling it via var.(args) is non-idiomatic. Directly calling the function (fn(args)) is clearer and avoids creating an unnecessary anonymous function.

Bad

factorial = &factorial/1
div(factorial.(2 * n), factorial.(n))

Good

div(factorial(2 * n), factorial(n))