Created
July 22, 2017 09:33
-
-
Save anna-yn/3806ee9aadcc99033ccbb0f9232f1e68 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
| /** | |
| * @author Artur Bosch | |
| * https://github.com/arturbosch/detekt/blob/master/detekt-sample-ruleset/src/main/kotlin/io/gitlab/arturbosch/detekt/sampleruleset/TooManyFunctions.kt | |
| */ | |
| class TooManyFunctions : Rule() { | |
| override val issue = Issue(javaClass.simpleName, Severity.CodeSmell, "") | |
| private var amount: Int = 0 | |
| override fun visitFile(file: PsiFile) { | |
| super.visitFile(file) | |
| if (amount > 10) { | |
| report(CodeSmell(issue, Entity.from(file))) | |
| } | |
| } | |
| override fun visitNamedFunction(function: KtNamedFunction) { | |
| amount++ | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment