Skip to content

Commit

Permalink
scalafmt: enable AvoidInfix rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Apr 1, 2024
1 parent 62ae842 commit c6dd3a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ project {
excludeFilters = [
plugin/src/sbt-test
]
layout = StandardConvention
}
newlines {
avoidForSimpleOverflow = [punct, slc, tooLong]
Expand All @@ -13,6 +14,7 @@ newlines {
}
rewrite {
rules = [
AvoidInfix,
Imports,
RedundantBraces,
RedundantParens,
Expand Down
22 changes: 11 additions & 11 deletions plugin/src/main/scala/org/scalafmt/sbt/ScalafmtPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -381,35 +381,35 @@ object ScalafmtPlugin extends AutoPlugin {
sources: Seq[File],
dirs: Seq[File],
session: FormatSession
) = Def.task(session.formatTrackedSources(sources, dirs)) tag
(ScalafmtTagPack: _*)
) = Def.task(session.formatTrackedSources(sources, dirs))
.tag(ScalafmtTagPack: _*)

private def scalafmtCheckTask(
sources: Seq[File],
dirs: Seq[File],
session: FormatSession
) = Def.task(session.checkTrackedSources(sources, dirs)) tag
(ScalafmtTagPack: _*)
) = Def.task(session.checkTrackedSources(sources, dirs))
.tag(ScalafmtTagPack: _*)

private def getScalafmtSourcesTask(
f: (Seq[File], Seq[File], FormatSession) => InitTask
) = Def.taskDyn[Unit] {
val sources = (unmanagedSources in scalafmt).?.value.getOrElse(Seq.empty)
val dirs = (unmanagedSourceDirectories in scalafmt).?.value.getOrElse(Nil)
val sources = unmanagedSources.in(scalafmt).?.value.getOrElse(Seq.empty)
val dirs = unmanagedSourceDirectories.in(scalafmt).?.value.getOrElse(Nil)
getScalafmtTask(f)(sources, dirs, scalaConfig.value)
}

private def scalafmtSbtTask(
sources: Seq[File],
dirs: Seq[File],
session: FormatSession
) = Def.task(session.formatSources(sources, dirs)) tag (ScalafmtTagPack: _*)
) = Def.task(session.formatSources(sources, dirs)).tag(ScalafmtTagPack: _*)

private def scalafmtSbtCheckTask(
sources: Seq[File],
dirs: Seq[File],
session: FormatSession
) = Def.task(session.checkSources(sources, dirs)) tag (ScalafmtTagPack: _*)
) = Def.task(session.checkSources(sources, dirs)).tag(ScalafmtTagPack: _*)

private def getScalafmtSbtTasks(
func: (Seq[File], Seq[File], FormatSession) => InitTask
Expand Down Expand Up @@ -460,10 +460,10 @@ object ScalafmtPlugin extends AutoPlugin {
scalafmtCheck := getScalafmtSourcesTask(scalafmtCheckTask).value,
scalafmtSbtCheck := getScalafmtSbtTasks(scalafmtSbtCheckTask).value,
scalafmtDoFormatOnCompile := Def.settingDyn {
if (scalafmtOnCompile.value) scalafmt in resolvedScoped.value.scope
if (scalafmtOnCompile.value) scalafmt.in(resolvedScoped.value.scope)
else Def.task(())
}.value,
sources in Compile := (sources in Compile)
sources.in(Compile) := sources.in(Compile)
.dependsOn(scalafmtDoFormatOnCompile).value,
scalafmtOnly := {
val files = spaceDelimited("<files>").parsed
Expand Down Expand Up @@ -507,7 +507,7 @@ object ScalafmtPlugin extends AutoPlugin {
)

override def buildSettings: Seq[Def.Setting[_]] =
Seq(scalafmtConfig := (baseDirectory in ThisBuild).value / ".scalafmt.conf")
Seq(scalafmtConfig := baseDirectory.in(ThisBuild).value / ".scalafmt.conf")

override def globalSettings: Seq[Def.Setting[_]] = Seq(
scalafmtFilter := "",
Expand Down

0 comments on commit c6dd3a6

Please sign in to comment.