Skip to content

Commit f6bff33

Browse files
Merge pull request #1274 from bjaglin/scalafmt
scalafmt-core 2.7.5
2 parents b1d8950 + 540e362 commit f6bff33

File tree

98 files changed

+1076
-1006
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+1076
-1006
lines changed

.scalafmt.conf

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
version = 2.3.1
1+
version = 2.7.5
22
project.git = true
3-
docstrings = Javadoc
3+
docstrings.style = Asterisk
44
optIn.blankLineBeforeDocstring = true
55
assumeStandardLibraryStripMargin = true
6-
align = none
6+
align.preset = none
77
onTestFailure = "To fix this, run `./scalafmt` from the project base directory"
88
optIn.annotationNewlines = true
99
project.excludeFilters = [

build.sbt

+4-2
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ lazy val unit = project
192192
libraryDependencies ++= testsDeps,
193193
libraryDependencies ++= List(
194194
jgit,
195-
scalatest.withRevision("3.2.0"), // make sure testkit clients can use recent 3.x versions
195+
scalatest.withRevision(
196+
"3.2.0"
197+
), // make sure testkit clients can use recent 3.x versions
196198
"org.scalameta" %% "testkit" % scalametaV
197199
),
198200
compileInputs.in(Compile, compile) := {
@@ -257,7 +259,7 @@ lazy val unit = project
257259
semanticdbTargetRoot.in(testsShared, Compile).value,
258260
"sharedSourceroot" ->
259261
baseDirectory.in(ThisBuild).value /
260-
"scalafix-tests" / "shared" / "src" / "main",
262+
"scalafix-tests" / "shared" / "src" / "main",
261263
"sharedClasspath" ->
262264
classDirectory.in(testsShared, Compile).value
263265
),

project/ScalafixBuild.scala

+16-16
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ object ScalafixBuild extends AutoPlugin with GhpagesKeys {
158158
// Custom settings to publish scalafix forks to alternative maven repo.
159159
lazy val adhocRepoUri = sys.props("scalafix.repository.uri")
160160
lazy val adhocRepoCredentials = sys.props("scalafix.repository.credentials")
161-
lazy val isCustomRepository = adhocRepoUri != null && adhocRepoCredentials != null
161+
lazy val isCustomRepository =
162+
adhocRepoUri != null && adhocRepoCredentials != null
162163

163164
override def globalSettings: Seq[Def.Setting[_]] = List(
164165
stableVersion := version.in(ThisBuild).value.replaceFirst("\\+.*", ""),
@@ -308,21 +309,20 @@ object ScalafixBuild extends AutoPlugin with GhpagesKeys {
308309
val currentState = state.value
309310
val ref = thisProjectRef.value
310311
val versions = crossScalaVersions.value
311-
versions.map {
312-
version =>
313-
val withScalaVersion = Project
314-
.extract(currentState)
315-
.appendWithoutSession(
316-
Seq(
317-
scalaVersion.in(ThisBuild) := version,
318-
publishArtifact.in(ThisBuild, packageDoc) := false,
319-
publishArtifact.in(ThisBuild, packageSrc) := false
320-
),
321-
currentState
322-
)
323-
Project
324-
.extract(withScalaVersion)
325-
.runTask(publishLocalTransitive.in(ref), withScalaVersion)
312+
versions.map { version =>
313+
val withScalaVersion = Project
314+
.extract(currentState)
315+
.appendWithoutSession(
316+
Seq(
317+
scalaVersion.in(ThisBuild) := version,
318+
publishArtifact.in(ThisBuild, packageDoc) := false,
319+
publishArtifact.in(ThisBuild, packageSrc) := false
320+
),
321+
currentState
322+
)
323+
Project
324+
.extract(withScalaVersion)
325+
.runTask(publishLocalTransitive.in(ref), withScalaVersion)
326326
}
327327
}
328328
)

project/project/plugins.sbt

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.23")
2-
unmanagedSources.in(Compile) += baseDirectory.value / ".." / "Dependencies.scala"
2+
unmanagedSources.in(
3+
Compile
4+
) += baseDirectory.value / ".." / "Dependencies.scala"

scalafix-cli/src/main/scala/scalafix/internal/interfaces/ScalafixErrorImpl.scala

+5-6
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ object ScalafixErrorImpl {
99
val to = ScalafixError.values().toList
1010
assert(from.length == to.length, s"$from != $to")
1111
val map = from.zip(to).toMap
12-
map.foreach {
13-
case (key, value) =>
14-
assert(
15-
key.name.toLowerCase() == value.toString.toLowerCase,
16-
s"$key != $value"
17-
)
12+
map.foreach { case (key, value) =>
13+
assert(
14+
key.name.toLowerCase() == value.toString.toLowerCase,
15+
s"$key != $value"
16+
)
1817
}
1918
map
2019
}

scalafix-cli/src/main/scala/scalafix/internal/v1/Args.scala

+42-43
Original file line numberDiff line numberDiff line change
@@ -128,23 +128,23 @@ case class Args(
128128
@Section("Tab completions")
129129
@Description(
130130
"""|Print out bash tab completions. To install:
131-
|```
132-
|# macOS, requires "brew install bash-completion"
133-
|scalafix --bash > /usr/local/etc/bash_completion.d/scalafix
134-
|# Linux
135-
|scalafix --bash > /etc/bash_completion.d/scalafix
136-
|```
137-
|""".stripMargin
131+
|```
132+
|# macOS, requires "brew install bash-completion"
133+
|scalafix --bash > /usr/local/etc/bash_completion.d/scalafix
134+
|# Linux
135+
|scalafix --bash > /etc/bash_completion.d/scalafix
136+
|```
137+
|""".stripMargin
138138
)
139139
bash: Boolean = false,
140140
@Description(
141141
"""|Print out zsh tab completions. To install:
142-
|```
143-
|scalafix --zsh > /usr/local/share/zsh/site-functions/_scalafix
144-
|unfunction _scalafix
145-
|autoload -U _scalafix
146-
|```
147-
|""".stripMargin
142+
|```
143+
|scalafix --zsh > /usr/local/share/zsh/site-functions/_scalafix
144+
|unfunction _scalafix
145+
|autoload -U _scalafix
146+
|```
147+
|""".stripMargin
148148
)
149149
zsh: Boolean = false,
150150
// TODO: --sbt
@@ -384,34 +384,33 @@ case class Args(
384384
}
385385

386386
def validate: Configured[ValidatedArgs] = {
387-
baseConfig.andThen {
388-
case (base, scalafixConfig, delegator) =>
389-
(
390-
configuredSourceroot |@|
391-
configuredSymtab |@|
392-
configuredRules(base, scalafixConfig) |@|
393-
resolvedPathReplace |@|
394-
configuredDiffDisable |@|
395-
configuredGlobal
396-
).map {
397-
case (
387+
baseConfig.andThen { case (base, scalafixConfig, delegator) =>
388+
(
389+
configuredSourceroot |@|
390+
configuredSymtab |@|
391+
configuredRules(base, scalafixConfig) |@|
392+
resolvedPathReplace |@|
393+
configuredDiffDisable |@|
394+
configuredGlobal
395+
).map {
396+
case (
398397
((((root, symtab), rulez), pathReplace), diffDisable),
399398
global
400-
) =>
401-
ValidatedArgs(
402-
this,
403-
symtab,
404-
rulez,
405-
scalafixConfig,
406-
classLoader,
407-
root,
408-
pathReplace,
409-
diffDisable,
410-
delegator,
411-
semanticdbFilterMatcher,
412-
global
413-
)
414-
}
399+
) =>
400+
ValidatedArgs(
401+
this,
402+
symtab,
403+
rulez,
404+
scalafixConfig,
405+
classLoader,
406+
root,
407+
pathReplace,
408+
diffDisable,
409+
delegator,
410+
semanticdbFilterMatcher,
411+
global
412+
)
413+
}
415414
}
416415
}
417416
}
@@ -477,14 +476,14 @@ object Args {
477476
TPrint.make[PathMatcher](_ => "<glob>")
478477
implicit val confPrint: TPrint[Conf] =
479478
TPrint.make[Conf](implicit cfg => TPrint.implicitly[ScalafixConfig].render)
480-
implicit def optionPrint[T](
481-
implicit ev: pprint.TPrint[T]
479+
implicit def optionPrint[T](implicit
480+
ev: pprint.TPrint[T]
482481
): TPrint[Option[T]] =
483482
TPrint.make { implicit cfg =>
484483
ev.render
485484
}
486-
implicit def iterablePrint[C[x] <: Iterable[x], T](
487-
implicit ev: pprint.TPrint[T]
485+
implicit def iterablePrint[C[x] <: Iterable[x], T](implicit
486+
ev: pprint.TPrint[T]
488487
): TPrint[C[T]] =
489488
TPrint.make { implicit cfg =>
490489
s"[${ev.render} ...]"

scalafix-cli/src/main/scala/scalafix/internal/v1/CompletionsOps.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ object CompletionsOps {
2828
s"$assign[$escaped]"
2929
}
3030
names(setting).map { name =>
31-
s""""$repeat${option(Case.camelToKebab(name))}$description$message$action""""
31+
s""""$repeat${option(
32+
Case.camelToKebab(name)
33+
)}$description$message$action""""
3234
}
3335
}
3436
}

scalafix-cli/src/main/scala/scalafix/internal/v1/MainOps.scala

+6-6
Original file line numberDiff line numberDiff line change
@@ -448,15 +448,15 @@ object MainOps {
448448
s"Scalafix ${Versions.version}"
449449
def usage: String =
450450
"""|Usage: scalafix [options] [<path> ...]
451-
|""".stripMargin
451+
|""".stripMargin
452452
def description: D =
453453
D.paragraph(
454454
"""|Scalafix is a refactoring and linting tool.
455-
|Scalafix supports both syntactic and semantic linter and rewrite rules.
456-
|Syntactic rules can run on source code without compilation.
457-
|Semantic rules can run on source code that has been compiled with the
458-
|SemanticDB compiler plugin.
459-
|""".stripMargin
455+
|Scalafix supports both syntactic and semantic linter and rewrite rules.
456+
|Syntactic rules can run on source code without compilation.
457+
|Semantic rules can run on source code that has been compiled with the
458+
|SemanticDB compiler plugin.
459+
|""".stripMargin
460460
)
461461

462462
/** Line wrap prose while keeping markdown code fences unchanged. */

scalafix-core/src/main/scala/scalafix/config/CustomMessage.scala

+12-13
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ object CustomMessage {
1515
implicit val SymbolDecoder: ConfDecoder[CustomMessage[Symbol.Global]] =
1616
decoder[Symbol.Global](field = "symbol")
1717

18-
implicit def CustomMessageEitherDecoder[A, B](
19-
implicit AB: ConfDecoder[Either[CustomMessage[A], CustomMessage[B]]]
18+
implicit def CustomMessageEitherDecoder[A, B](implicit
19+
AB: ConfDecoder[Either[CustomMessage[A], CustomMessage[B]]]
2020
): ConfDecoder[CustomMessage[Either[A, B]]] =
2121
AB.map {
2222
case Right(msg) =>
@@ -31,18 +31,17 @@ object CustomMessage {
3131
case obj: Conf.Obj => {
3232
(obj.get[T](field) |@|
3333
obj.getOption[String]("message") |@|
34-
obj.getOption[String]("id")).map {
35-
case ((value, message0), id) =>
36-
val message =
37-
message0.map(msg =>
38-
if (msg.contains("\n")) {
39-
"\n" + msg.stripMargin
40-
} else {
41-
msg
42-
}
43-
)
34+
obj.getOption[String]("id")).map { case ((value, message0), id) =>
35+
val message =
36+
message0.map(msg =>
37+
if (msg.contains("\n")) {
38+
"\n" + msg.stripMargin
39+
} else {
40+
msg
41+
}
42+
)
4443

45-
new CustomMessage(value, message, id)
44+
new CustomMessage(value, message, id)
4645
}
4746
}
4847
case els =>

scalafix-core/src/main/scala/scalafix/config/Regex.scala

+5-6
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@ class Regex(
1313

1414
object Regex {
1515
implicit val regexDecoder: ConfDecoder[Regex] =
16-
ConfDecoder.instance[Regex] {
17-
case obj: Conf.Obj =>
18-
(obj.get[Pattern]("pattern") |@| obj.getOption[Int]("captureGroup"))
19-
.map {
20-
case (pattern, groupIndex) => new Regex(pattern, groupIndex)
21-
}
16+
ConfDecoder.instance[Regex] { case obj: Conf.Obj =>
17+
(obj.get[Pattern]("pattern") |@| obj.getOption[Int]("captureGroup"))
18+
.map { case (pattern, groupIndex) =>
19+
new Regex(pattern, groupIndex)
20+
}
2221
}
2322

2423
implicit val customMessageRegexDecoder: ConfDecoder[CustomMessage[Regex]] =

scalafix-core/src/main/scala/scalafix/internal/config/LogContext.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ case class LogContext(
99
}
1010

1111
object LogContext {
12-
implicit def generate(
13-
implicit line: sourcecode.Line,
12+
implicit def generate(implicit
13+
line: sourcecode.Line,
1414
file: sourcecode.File,
1515
enclosing: sourcecode.Enclosing
1616
): LogContext = LogContext(line, file, enclosing)

scalafix-core/src/main/scala/scalafix/internal/config/MetaconfigOps.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ object MetaconfigOps {
3131
res.product(configured).map { case (a, b) => b +: a }
3232
}
3333
}
34-
def getKey[T](conf: Conf.Obj, path: String, extraNames: String*)(
35-
implicit ev: ConfDecoder[T]
34+
def getKey[T](conf: Conf.Obj, path: String, extraNames: String*)(implicit
35+
ev: ConfDecoder[T]
3636
): Configured[T] = {
3737
ConfGet.getKey(conf, path +: extraNames) match {
3838
case Some(value) => ev.read(value)

scalafix-core/src/main/scala/scalafix/internal/config/ReaderUtil.scala

+11-12
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,16 @@ object ReaderUtil {
1717
m: Map[String, T],
1818
additionalMessage: PartialFunction[String, String] = PartialFunction.empty
1919
): ConfDecoder[T] =
20-
ConfDecoder.instance[T] {
21-
case Conf.Str(x) =>
22-
m.get(x) match {
23-
case Some(y) =>
24-
Configured.Ok(y)
25-
case None =>
26-
val available = m.keys.mkString(", ")
27-
val extraMsg = additionalMessage.applyOrElse(x, (_: String) => "")
28-
val msg =
29-
s"Unknown input '$x'. Expected one of: $available. $extraMsg"
30-
Configured.NotOk(ConfError.message(msg))
31-
}
20+
ConfDecoder.instance[T] { case Conf.Str(x) =>
21+
m.get(x) match {
22+
case Some(y) =>
23+
Configured.Ok(y)
24+
case None =>
25+
val available = m.keys.mkString(", ")
26+
val extraMsg = additionalMessage.applyOrElse(x, (_: String) => "")
27+
val msg =
28+
s"Unknown input '$x'. Expected one of: $available. $extraMsg"
29+
Configured.NotOk(ConfError.message(msg))
30+
}
3231
}
3332
}

0 commit comments

Comments
 (0)