/detekt-exposed-api-extensions

ExposedApi rule extension for https://detekt.github.io/detekt/

Primary LanguageKotlinApache License 2.0Apache-2.0

Download

detekt-exposed-api-extensions

ExposedApi rule extension for https://detekt.github.io/detekt/

Why

In Kotlin default visibility modifier is public.
This might become an issue if one develops a library, where public should be only for public API, and everything else should be private or internal.
But it is so easy to forget to put internal modifier, so automation help is appreciated.
Detekt is a static analyzer for Kotlin.
In this repository there is an extension plugin with ExposedApi rule.

Top-level class, object, function or property is considered exposed if it has public (or default) visibility modifier and is not marked explicitly as public API available for clients.

Installation

dependencies {
    detektPlugins 'com.krossovochkin.detekt:exposed-api:x.x.x'
}

Configuration

library:
  ExposedApi:
    active: true
    ignoreAnnotated: ["PublicApi"]
    ignorePathRegex: [".*detekt.*"]
  • active - boolean value whether to enable rule
  • ignoreAnnotated - suppress annotated with given annotations places
  • ignorePathRegex - suppress some files (like tests or application modules) by given regex