Skip to content

Commit

Permalink
Fix: Inform about Boolean Parameters not for case class initializer (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
saeltz authored May 10, 2022
1 parent a5435fd commit b441e0a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ developers := List(
)
)

scalaVersion := "2.13.7"
scalaVersion := "2.13.8"
crossScalaVersions := Seq("2.11.12", "2.12.14", "2.12.15", "2.13.7", "2.13.8")
autoScalaLibrary := false
crossVersion := CrossVersion.full
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class BooleanParameter
case DefDef(mods, _, _, _, _, _) if mods.hasFlag(Flags.ACCESSOR) =>
// ignore overridden methods as the parent will receive the warning
case DefDef(mods, _, _, _, _, _) if mods.isOverride =>
case DefDef(_, _, _, vparamss, _, _) if hasBooleanParameter(vparamss) =>
case DefDef(_, name, _, vparamss, _, _)
if hasBooleanParameter(vparamss) && name != TermName("<init>") =>
context.warn(tree.pos, self, tree.toString.take(300))
case _ => continue(tree)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ class BooleanParameterTest extends InspectionTest {
compileCodeSnippet(code)
compiler.scapegoat.feedback.warnings.size shouldBe 1
}

"not for case classes using Boolean parameter" in {
val code = """final case class Test(bool: Boolean)""".stripMargin

compileCodeSnippet(code)
compiler.scapegoat.feedback.warnings.size shouldBe 0
}
}
}
}

0 comments on commit b441e0a

Please sign in to comment.