Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reported text position of wrapping rule #5004

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -2,9 +2,11 @@ package io.gitlab.arturbosch.detekt.formatting.wrappers

import com.pinterest.ktlint.ruleset.standard.WrappingRule
import io.gitlab.arturbosch.detekt.api.Config
import io.gitlab.arturbosch.detekt.api.TextLocation
import io.gitlab.arturbosch.detekt.api.internal.ActiveByDefault
import io.gitlab.arturbosch.detekt.api.internal.AutoCorrectable
import io.gitlab.arturbosch.detekt.formatting.FormattingRule
import org.jetbrains.kotlin.com.intellij.lang.ASTNode

/**
* See [ktlint-website](https://ktlint.github.io#rule-indentation) for documentation.
Expand All @@ -15,4 +17,6 @@ class Wrapping(config: Config) : FormattingRule(config) {

override val wrapping = WrappingRule()
override val issue = issueFor("Reports missing newlines (e.g. between parentheses of a multi-line function call")

override fun getTextLocationForViolation(node: ASTNode, offset: Int) = TextLocation(offset, offset)
}
Expand Up @@ -16,14 +16,16 @@ class WrappingSpec {
}

@Test
fun `Given a wrong wrapping in the class definition`() {
fun `should report a wrong wrapping in the extends clause of the class definition`() {
val code =
"""
class A() : B,
C {
}
""".trimIndent()

assertThat(subject.lint(code)).hasSize(1)
assertThat(subject.lint(code))
.hasSize(1)
.hasTextLocations(11 to 11)
}
}