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: Inform about Boolean Parameters not for case class initializer #649

Merged
merged 1 commit into from
May 10, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's probably not intended, but it doesn't matter much.

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
}
}
}
}