Skip to content

Instantly share code, notes, and snippets.

@anna-yn
Created July 22, 2017 09:33
Show Gist options
  • Select an option

  • Save anna-yn/3806ee9aadcc99033ccbb0f9232f1e68 to your computer and use it in GitHub Desktop.

Select an option

Save anna-yn/3806ee9aadcc99033ccbb0f9232f1e68 to your computer and use it in GitHub Desktop.
/**
* @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