bazel_rules_detekt icon indicating copy to clipboard operation
bazel_rules_detekt copied to clipboard

Support Detekt rules using type resolution

Open ryanpbrewster opened this issue 4 years ago • 3 comments

Detekt has experimental support for rules that rely on type resolution.

The gradle plugin seems to have support for this. The CLI tool looks like it requires the --jvm-target and --classpath arguments to be provided. Are those paths available during the bazel compilation phase? Is it possible that the bazel rules could support these type-resolution rules?

ryanpbrewster avatar Jan 27 '21 19:01 ryanpbrewster

Definitely an interesting option. It was not pursued at this point since it requires Kotlin code compilation before executing Detekt. Right now it can be executed without ready-to-use classpath. At the same time, I’m not sure if there are rules using this in the first place, a lot of bundled ones use regular UAST.

arturdryomov avatar Feb 01 '21 06:02 arturdryomov

I’m not sure if there are rules using this in the first place

The main one I had in mind is IgnoredReturnValue, which would be extremely helpful in catching common errors when dealing with immutable data structures and Result types

ryanpbrewster avatar Sep 03 '21 22:09 ryanpbrewster

ForbiddenMethodCall is another quite useful one (e.g. preventing stray calls to println and friends) that requires type resolution.

Kernald avatar Oct 25 '21 05:10 Kernald