Hi! Is there an existing rule that would report if...
# detekt
d
Hi! Is there an existing rule that would report if some
also
is unnecessary, for example
Copy code
foo.also { bar() } // doesn't use "it"
l
I often use this with expressions. Sometimes I just need
Copy code
fun foo() = Bar().also { baz() }
With this rule, it'd make me use a full function body.
Typically baz would use the new Bar in some way, needing 'it', but not always.
d
Ah, right, thats a nice use case. I've just found
Copy code
fun foo() {
  val x = 3
  bar().also { baz() }
}
in our code and thought it makes no sense. I guess it was using
it
at some point, which got lost after some edit.
I may try to write a rule for this which would exclude your case.
l
A rule like this with an option to ignore expressions makes sense. Expressions are the only case I can think of where this matters.
a
Hi @Landry Norris / @dimsuz can you create a new issue in the repo(if not already created)?
d
I thought I'd try to implement + apply this rule in the local ruleset to test it out...
a
That's more better. Than also push it to
detekt
😀