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 indentation check for classes where invocation is mistaken for a parameter list #194

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class IndentationChecker extends FileChecker {
*/
private def verifyClassIndent(lines: Seq[NormalizedLine], classParamIndentSize: Int) = {
def isInvalid(l1: NormalizedLine, l2: NormalizedLine): Boolean = {
if (startsParamList(l1)) {
if (startsParamList(l1) && !l1.normalizedText.contains(" extends ")) {
(l2.indentDepth - l1.indentDepth) != classParamIndentSize
} else {
false
Expand Down
12 changes: 12 additions & 0 deletions src/test/scala/org/scalastyle/file/IndentationCheckerTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,16 @@ class A {

assertErrors(List(), source, Map("methodParamIndentSize" -> "4"))
}

@Test def testExtendNotConsideredClassIndent(): Unit = {
val source =
"""
object A extends B(
a, b, c, d) {

}
"""

assertErrors(List(), source, Map("classParamIndentSize" -> "4"))
}
}