Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save guilhermekrz/79a2b0b99e2dc254e2c299f7d05f89a5 to your computer and use it in GitHub Desktop.
Save guilhermekrz/79a2b0b99e2dc254e2c299f7d05f89a5 to your computer and use it in GitHub Desktop.
KotlinShouldNotThrowExceptionsDetector Issue
val IMPLEMENTATION = Implementation(
KotlinShouldNotThrowExceptionsDetector::class.java,
Scope.JAVA_FILE_SCOPE
)
val ISSUE: Issue = Issue.create(
id = "KotlinShouldNotThrowExceptionsDetector",
briefDescription = "Kotlin code should not throw Exceptions",
explanation = """
Kotlin does not support checked Exceptions, so we should not rely on Exceptions to propagate errors in our application.
More details in: https://kotlinlang.org/docs/reference/exceptions.html
""".trimIndent(),
category = Category.CORRECTNESS,
priority = 9,
severity = Severity.ERROR,
androidSpecific = true,
implementation = IMPLEMENTATION
)
fun reportUsage(context: JavaContext, location: Location) {
context.report(
issue = ISSUE,
location = location,
message = "Kotlin code should not throw Exceptions"
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment