Lightsaber is a Dagger 2 plugin that detects unused code in your Module
s, Component
s and Subcomponent
s
/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@Module
s - Unused
@Component(dependencies)
- Unused member injection methods (
Component.inject(Foo)
) - Unused
@Module
s
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.
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
}
Clone the repo and execute:
./gradlew build