Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: allow specifying suppressions for generated files #169

Closed
ZacSweers opened this issue Dec 1, 2020 · 4 comments
Closed
Labels
bug Something isn't working dagger factory Happens when generateDaggerFactories is set to true

Comments

@ZacSweers
Copy link
Collaborator

We enable warnings as errors in our project, which sometimes means suppressing a deprecated usage in a type but this isn't carried over to the generated code. It would be neat if we could disable these via specifying suppressions we need

anvil {
  suppressions = setOf("DEPRECATION")
}

// results in files including
@file:Suppress("DEPRECATION")
@vRallev
Copy link
Collaborator

vRallev commented Dec 1, 2020

To be crystal clear I assume this would be a sample:

@Deprecated("abc")
class MyType

@Module
class MyModule {
  @Provides fun provideMyType(): MyType = MyType()
}

Which results in this error:

e: warnings found and -Werror specified
w: anvil/integration-tests/library/build/anvil/src-gen-main/com/squareup/anvil/test/MyModule_ProvideMyTypeFactory.kt: (11, 13): 'MyType' is deprecated. abc
w: anvil/integration-tests/library/build/anvil/src-gen-main/com/squareup/anvil/test/MyModule_ProvideMyTypeFactory.kt: (12, 32): 'MyType' is deprecated. abc
w: anvil/integration-tests/library/build/anvil/src-gen-main/com/squareup/anvil/test/MyModule_ProvideMyTypeFactory.kt: (20, 49): 'MyType' is deprecated. abc
w: anvil/integration-tests/library/src/main/java/com/squareup/anvil/test/Modules.kt: (40, 41): 'MyType' is deprecated. abc
anvil/integration-tests/library/src/main/java/com/squareup/anvil/test/Modules.kt: (40, 50): 'MyType' is deprecated. abc

@ZacSweers
Copy link
Collaborator Author

Yup!

@vRallev vRallev added bug Something isn't working dagger factory Happens when generateDaggerFactories is set to true labels Dec 1, 2020
@ZacSweers
Copy link
Collaborator Author

I see you went with the hardcoded approach. Any reason not to use a generic option like I mentioned above? Another one that comes up occasionally is explicit API mode from kotlinpoet leading to redundant qualifiers, which would be a different suppression and not covered by the hardcoded deprecation warning.

@vRallev
Copy link
Collaborator

vRallev commented Dec 30, 2020

We talked somewhere else about this. So far there's no need for such an API and the hardcoded approach works good enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dagger factory Happens when generateDaggerFactories is set to true
Projects
None yet
Development

No branches or pull requests

2 participants