Created
January 11, 2019 22:18
-
-
Save creativedrewy/37ca5559162a55e7544976df275d5ac7 to your computer and use it in GitHub Desktop.
//BLOCK comment lint rule
This file contains 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 BlockCommentDetector : Detector(), Detector.UastScanner { | |
companion object { | |
val ISSUE: Issue = Issue.create( | |
"BlockComment", | |
"BLOCK comment found, cannot continue build.", | |
"Please resolve all BLOCK commented code before merging.", | |
Category.CORRECTNESS, | |
6, | |
Severity.ERROR, | |
Implementation(BlockCommentDetector::class.java, Scope.JAVA_FILE_SCOPE) | |
) | |
} | |
override fun getApplicableUastTypes(): MutableList<Class<out UElement>> { | |
return mutableListOf(UFile::class.java) | |
} | |
override fun createUastHandler(context: JavaContext): UElementHandler { | |
return object : UElementHandler() { | |
override fun visitFile(node: UFile) { | |
node.allCommentsInFile | |
.filter { it.text.startsWith("//BLOCK") || it.text.startsWith("// BLOCK") } | |
.forEach { comment -> | |
context.report(ISSUE, context.getLocation(comment), "Resolve all BLOCK commented code before merging.") | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment