Skip to content

Commit

Permalink
Fix 'Missing newline before ")"' when no params
Browse files Browse the repository at this point in the history
Avoid checking "parameter-list-wrapping" rule when the element doesn't
have parameters.

Fixes pinterest#327
  • Loading branch information
jlmd committed Mar 31, 2019
1 parent 056d983 commit 6b3637b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class ParameterListWrappingRule : Rule("parameter-list-wrapping") {
return
}
if (node.elementType == VALUE_PARAMETER_LIST &&
// skip when there are no parameters
node.firstChildNode.treeNext.elementType != RPAR &&
// skip lambda parameters
node.treeParent?.elementType != FUNCTION_LITERAL
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ class ParameterListWrappingRuleTest {
)
}

@Test
fun testLintClassParameterListWhenMaxLineLengthExceededAndNoParameters() {
assertThat(
ParameterListWrappingRule().lint(
"""
class ClassAWithALongName()
""".trimIndent(),
userData = mapOf("max_line_length" to "10")
)
).doesNotContain(
LintError(1, 27, "parameter-list-wrapping", """Missing newline before ")"""")
)
}

@Test
fun testLintClassParameterListValid() {
assertThat(
Expand Down

0 comments on commit 6b3637b

Please sign in to comment.