Skip to content

Commit

Permalink
AvoidInfixSettings: refactor defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Nov 28, 2023
1 parent b9a6315 commit 92196d2
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ case class AvoidInfixSettings(
) {
private[config] def forSbt: Option[AvoidInfixSettings] =
// if the user customized these, we don't touch
if (excludeFilters ne AvoidInfixSettings.default.excludeFilters) None
if (excludeFilters ne AvoidInfixSettings.mainExclude) None
else Some(copy(excludeFilters = AvoidInfixSettings.sbtExclude))

def matches(lhs: String, op: String): Boolean =
Expand Down Expand Up @@ -60,8 +60,13 @@ object AvoidInfixSettings {
generic.deriveSurface
implicit lazy val codec: ConfCodecEx[AvoidInfixSettings] =
generic.deriveCodecEx(default).noTypos
val default = AvoidInfixSettings(
Seq("[\\w\\d_]+").map(Filter.apply),

private def mainInclude =
Seq(
"[\\w\\d_]+"
).map(Filter.apply)

private val mainExclude =
Seq(
"until",
"to",
Expand Down Expand Up @@ -91,9 +96,14 @@ object AvoidInfixSettings {
"inOrderElementsOf",
"theSameElementsAs"
).map(Filter.apply)
)

private val sbtExclude = Seq(
"cross"
).map(Filter.apply) ++ default.excludeFilters
).map(Filter.apply) ++ mainExclude

private[config] val default = AvoidInfixSettings(
includeFilters = mainInclude,
excludeFilters = mainExclude
)

}

0 comments on commit 92196d2

Please sign in to comment.