Skip to content

SchwarzIT/dagger-lightsaber

Repository files navigation

Lightsaber

Lightsaber is a Dagger 2 plugin that detects unused code in your Modules, Components and Subcomponents

What to expect

/path/module/com/example/MyComponent.java:6:8: e: The @BindsInstance `myInt` declared in `test.MyComponent` is not used. [UnusedBindsInstances]

This plugin contains several rules:

  • Empty @Component and @Subcomponent
  • Unused @BindsInstance
  • Unused @Provides or @Binds inside @Modules
  • Unused @Component(dependencies)
  • Unused member injection methods (Component.inject(Foo))
  • Unused @Modules

How to use it

Add the plugin to your project:

// build.gradle.kts
plugins {
    id("io.github.schwarzit.lightsaber") version "0.0.13"
}

And run ./gradlew lightsaberCheck. Lightsaber will check your code and fail if there is any issue.

Configuration

You can change that default for each rule from error to warnings or even ignore it completely like this:

import schwarz.it.lightsaber.gradle.Severity

lightsaber {
  emptyComponents = Severity.Error
  unusedBindsInstances = Severity.Error
  unusedBindsAndProvides = Severity.Error
  unusedDependencies = Severity.Error
  unusedMembersInjection = Severity.Error
  unusedModules = Severity.Error
}

How to build it

Clone the repo and execute:

./gradlew build

About

Lightsaber is a Dagger 2 plugin that flags the unused dependencies declared in your Modules and Components

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published