Skip to content

Commit

Permalink
Remove warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
BraisGabin committed Oct 4, 2024
1 parent 4873989 commit 2df143e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class LightsaberPluginIntegrationTest {
assertThat(buildResult).contains("MyModule.java:15:17: The @Provides `myLong` declared in `com.example.MyModule` is not used. [UnusedBindsAndProvides]")
assertThat(buildResult).contains("Foo.java:5:8: The @Inject in `com.example.Foo` constructor is unused because there is a @Provides defined in `com.example.MyModule.foo`. [UnusedInject]")
assertThat(buildResult).contains("> Analysis failed with 2 errors")
assertThat(buildResult).doesNotContain("warning:")
}

@Test
Expand All @@ -41,6 +42,7 @@ class LightsaberPluginIntegrationTest {
assertThat(buildResult).contains("MyModule.java:26:27: The @Provides `myLong` declared in `com.example.MyModule` is not used. [UnusedBindsAndProvides]")
assertThat(buildResult).contains("Foo.java:4:14: The @Inject in `com.example.Foo` constructor is unused because there is a @Provides defined in `com.example.MyModule.Companion.provideFoo`. [UnusedInject]")
assertThat(buildResult).contains("> Analysis failed with 2 errors")
assertThat(buildResult).doesNotContain("warning:")
}

@Test
Expand Down Expand Up @@ -75,6 +77,7 @@ class LightsaberPluginIntegrationTest {

assertThat(buildResult).contains("MyModule.java:15:17: The @Provides `myLong` declared in `com.example.MyModule` is not used. [UnusedBindsAndProvides]")
assertThat(buildResult).contains("> Analysis failed with 1 error")
assertThat(buildResult).doesNotContain("warning:")
}

@Test
Expand All @@ -92,6 +95,7 @@ class LightsaberPluginIntegrationTest {

assertThat(buildResult).contains("MyModule.java:26:27: The @Provides `myLong` declared in `com.example.MyModule` is not used. [UnusedBindsAndProvides]")
assertThat(buildResult).contains("> Analysis failed with 1 error")
assertThat(buildResult).doesNotContain("warning:")
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class BuildResultSubject(
check("getOutput()").that(actual?.output).contains(output)
}

fun doesNotContain(output: String) {
check("getOutput()").that(actual?.output).doesNotContain(output)
}

internal object Factory : Subject.Factory<BuildResultSubject, BuildResult> {
override fun createSubject(metadata: FailureMetadata, actual: BuildResult?): BuildResultSubject {
return BuildResultSubject(metadata, actual)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ import schwarz.it.lightsaber.utils.writeFile
import javax.annotation.processing.AbstractProcessor
import javax.annotation.processing.ProcessingEnvironment
import javax.annotation.processing.RoundEnvironment
import javax.annotation.processing.SupportedAnnotationTypes
import javax.annotation.processing.SupportedSourceVersion
import javax.lang.model.SourceVersion
import javax.lang.model.element.TypeElement

@SupportedAnnotationTypes("*")
@SupportedSourceVersion(SourceVersion.RELEASE_11)
class LightsaberJavacProcessor : AbstractProcessor() {
private lateinit var fileGenerator: FileGenerator
private lateinit var rules: Set<Pair<String, LightsaberJavacRule>>
Expand Down Expand Up @@ -49,6 +45,12 @@ class LightsaberJavacProcessor : AbstractProcessor() {

return false
}

override fun getSupportedOptions() = setOf("Lightsaber.CheckUnusedInject", "Lightsaber.CheckUnusedScopes")

override fun getSupportedSourceVersion(): SourceVersion = SourceVersion.latestSupported()

override fun getSupportedAnnotationTypes() = setOf("*")
}

interface LightsaberJavacRule {
Expand Down

0 comments on commit 2df143e

Please sign in to comment.