Skip to content

Commit

Permalink
Don't repeat code
Browse files Browse the repository at this point in the history
  • Loading branch information
BraisGabin committed Apr 26, 2024
1 parent 78fa964 commit a53c630
Showing 1 changed file with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ private class NoEmptyFile(config: Config) : Rule(config, "TestDescription") {
}
}

private class MaxLineLength(config: Config) : Rule(config, "TestDescription") {
private open class MaxLineLength(config: Config) : Rule(config, "TestDescription") {
private val lengthThreshold: Int = config.valueOrDefault("maxLineLength", 10)
override fun visitKtFile(file: KtFile) {
super.visitKtFile(file)
Expand All @@ -418,17 +418,7 @@ private class MaxLineLength(config: Config) : Rule(config, "TestDescription") {
}

@RequiresTypeResolution
private class RequiresTypeResolutionMaxLineLength(config: Config) : Rule(config, "TestDescription") {
private val lengthThreshold: Int = config.valueOrDefault("maxLineLength", 10)
override fun visitKtFile(file: KtFile) {
super.visitKtFile(file)
for (line in file.text.lineSequence()) {
if (line.length > lengthThreshold) {
report(CodeSmell(Entity.atPackageOrFirstDecl(file), description))
}
}
}
}
private class RequiresTypeResolutionMaxLineLength(config: Config) : MaxLineLength(config)

private class FaultyRule(config: Config) : Rule(config, "") {
override fun visitKtFile(file: KtFile) {
Expand Down

0 comments on commit a53c630

Please sign in to comment.