buildfoundation / bazel_rules_detekt

Bazel rules for Detekt (Kotlin static analysis tool)
Apache License 2.0
29 stars 8 forks source link

Support Detekt rules using type resolution #92

Open ryanpbrewster opened 3 years ago

ryanpbrewster commented 3 years ago

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?

arturdryomov commented 3 years ago

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.

ryanpbrewster commented 2 years ago

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

Kernald commented 2 years ago

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