Open jfmengels opened 3 years ago
Something something mark arguments has having an impact on flow something something fixpoint?
Most of these have been implemented a while ago. Only the let
declaration case hasn't:
recursive unusedValue list =
case list of
[] -> 1
x :: xs ->
let value = unusedValue - 1
in x + recursive value xs
This one would be the most complex because as @miniBill mentioned, this will likely need a bit more flow-like analysis.
What the rule should do:
Detect parameters of recursive function that are only used for passing it to the function again.
What problems does it solve:
This would help remove the argument and simplify both the recursive function and its call sites.
Example of things the rule would report:
In the case above,
unusedValue
is marked as used byNoUnused.Variables
because it is used as an argument ofrecursive
. But we never use the value anywhere else, meaning it serves no purpose.We can report the same thing even if different values are passed in some cases.
In the example above, the value of
unusedValue
may change, but we never use it anywhere.Slightly more advanced:
For this one, it is used in an expression, but that expression ultimately ends up only being used as the same argument for
recursive
, meaning whatever the value may turn out to be, it will not serve any purpose.To go one step further, we could detect let declarations
And also pipeline usage (note that I've reversed arguments)
Example of things the rule would not report:
When (not) to enable this rule:
:man_shrugging:
I am looking for: