Skip to content

Support Detekt rules using type resolution #92

Open

Description

@ryanpbrewster

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?

Activity

  1. arturdryomov commented on Feb 1, 2021

    @arturdryomov
    Contributor

    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.

  2. changed the title [-]Feature request: support for type resolution[/-] [+]Support Detekt rules using type resolution[/+] on Feb 7, 2021
  3. ryanpbrewster commented on Sep 3, 2021

    @ryanpbrewster
    Author

    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

  4. Kernald commented on Oct 25, 2021

    @Kernald
    Contributor

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

  5. ryanulep commented on Sep 2, 2025

    @ryanulep
    Contributor

    Agree with the above. Having a classpath and jvm_target field could help so that these get caught when the target is tested.

  6. ryanulep commented on Mar 18, 2026

    @ryanulep
    Contributor

    #207 should address this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions