🔧 Running with --fix will automatically remove some of the reported errors.
config =
[ NoUnused.Parameters.rule
]
This rule looks within function arguments, let functions and lambdas to find any values that are unused. It will report any parameters that are not used.
Fixes for lambdas
We're only offering fixes for lambdas here because we believe unused parameters in functions are a code smell that should be refactored.
Fail
Value number is not used:
add1 number =
1
The rule will also report parameters that are only used to be passed again to the containing recursive function:
last list unused =
case list of
[] ->
Nothing
[ a ] ->
Just a
_ :: rest ->
last rest unused
Success
add1 number =
number + 1
Automatic fixes
When possible, the rule will automatically remove function arguments from the declaration and call sites
-- Before
someFunction : Int -> Int -> Int
someFunction used unused =
used + 1
two =
someFunction 1 10
-- After
someFunction : Int -> Int
someFunction used =
used + 1
two =
someFunction 1
Also for fields and tuple values inside parameters, such as:
-- Before
someFunction : { unused : Int, used : Int } -> Int
someFunction { unused, used } =
otherFunction used
a =
someFunction { unused = 1, used = 2 }
-- After
someFunction : { used : b } -> b
someFunction { used } =
otherFunction used
a =
someFunction { used = 2 }
When fixing the calls is not possible, a fix will be made to ignore the argument (by replacing it by _ for instance.
_ arguments will only be reported if they're automatically fixable, otherwise they will be ignored.
Try it out
You can try this rule out by running the following command:
Report parameters that are not used.
🔧 Running with
--fixwill automatically remove some of the reported errors.This rule looks within function arguments, let functions and lambdas to find any values that are unused. It will report any parameters that are not used.
Fixes for lambdas
We're only offering fixes for lambdas here because we believe unused parameters in functions are a code smell that should be refactored.
Fail
Value
numberis not used:The rule will also report parameters that are only used to be passed again to the containing recursive function:
Success
Automatic fixes
When possible, the rule will automatically remove function arguments from the declaration and call sites
Also for fields and tuple values inside parameters, such as:
When fixing the calls is not possible, a fix will be made to ignore the argument (by replacing it by
_for instance._arguments will only be reported if they're automatically fixable, otherwise they will be ignored.Try it out
You can try this rule out by running the following command: