Created
July 11, 2020 22:20
-
-
Save jeremyrempel/f4cb28aaf7a63f164b5b97fd46d9822d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DeprecatedClassUsageDetector : Detector(), SourceCodeScanner { | |
companion object { | |
/** Issue describing the problem and pointing to the detector implementation */ | |
@JvmField | |
val ISSUE: Issue = Issue.create( | |
// ID: used in @SuppressLint warnings etc | |
id = "DeprecatedLib", | |
// Title -- shown in the IDE's preference dialog, as category headers in the | |
// Analysis results window, etc | |
briefDescription = "Deprecated library", | |
// Full explanation of the issue; you can use some markdown markup such as | |
// `monospace`, *italic*, and **bold**. | |
explanation = """ | |
This check highlights string literals in code which mentions the word `lint`. \ | |
Blah blah blah. | |
Another paragraph here.MyDeprecatedLibClass | |
""", // no need to .trimIndent(), lint does that automatically | |
category = Category.CORRECTNESS, | |
priority = 6, | |
severity = Severity.WARNING, | |
implementation = Implementation( | |
DeprecatedClassUsageDetector::class.java, | |
Scope.JAVA_FILE_SCOPE | |
) | |
) | |
} | |
override fun getApplicableConstructorTypes(): List<String> { | |
return listOf("com.github.jeremyrempel.mylinttest.MyDeprecatedLibClass") | |
} | |
override fun visitConstructor( | |
context: JavaContext, | |
node: UCallExpression, | |
constructor: PsiMeclass DeprecatedClassUsageDetector : Detector(), SourceCodeScanner { | |
companion object { | |
/** Issue describing the problem and pointing to the detector implementation */ | |
@JvmField | |
val ISSUE: Issue = Issue.create( | |
// ID: used in @SuppressLint warnings etc | |
id = "DeprecatedLib", | |
// Title -- shown in the IDE's preference dialog, as category headers in the | |
// Analysthod | |
) { | |
context.report( | |
issue = ISSUE, | |
scope = node, | |
location = context.getLocation(node), | |
message = "`MyDeprecatedLibClass` should not be used." | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment