Skip to content

Commit 6811967

Browse files
authored
Merge pull request #952 from tanishiking/update-scalafmt
Update scalafmt to 2.0.0-RC5
2 parents a6b7622 + fc1cc97 commit 6811967

File tree

88 files changed

+538
-313
lines changed

Some content is hidden

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

88 files changed

+538
-313
lines changed

.scalafmt.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
version = 2.0.0-RC5
12
project.git = true
23
docstrings = Javadoc
34
optIn.blankLineBeforeDocstring = true
@@ -8,5 +9,6 @@ optIn.annotationNewlines = true
89
project.excludeFilters = [
910
scalafix-tests/input
1011
scalafix-tests/output
12+
scalafix-tests/shared/src/main/scala/test/PrettyTest.scala
1113
scalafix-sbt/src/main/scala/scalafix/internal/sbt/ScalafixRuleNames.scala
1214
]

project/plugins.sbt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.2.2")
22
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
33
addSbtPlugin(
4-
"io.get-coursier" % "sbt-coursier" % coursier.util.Properties.version)
4+
"io.get-coursier" % "sbt-coursier" % coursier.util.Properties.version
5+
)
56
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.2")
67
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.3.2")
78
// exclude is a workaround for https://github.com/sbt/sbt-assembly/issues/236#issuecomment-294452474

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ object MainCallbackImpl {
2323
underlying.report(
2424
diagnostic.message,
2525
diagnostic.position,
26-
diagnostic.severity)
26+
diagnostic.severity
27+
)
2728
} else {
2829
underlying.lint(diagnostic)
2930
}
@@ -41,7 +42,8 @@ object MainCallbackImpl {
4142
RuleDiagnostic(
4243
Diagnostic(id = "", msg, pos, "", sev),
4344
RuleName.empty,
44-
None)
45+
None
46+
)
4547
)
4648
underlying.reportDiagnostic(diagnostic)
4749
}

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,20 @@ final case class ScalafixArgumentsImpl(args: Args = Args.default)
3636
copy(args = args.copy(rules = rules.asScala.toList))
3737

3838
override def withToolClasspath(
39-
classLoader: URLClassLoader): ScalafixArguments =
39+
classLoader: URLClassLoader
40+
): ScalafixArguments =
4041
copy(args = args.copy(toolClasspath = classLoader))
4142

4243
override def withPaths(paths: util.List[Path]): ScalafixArguments =
4344
copy(
4445
args = args.copy(
45-
files = paths.asScala.iterator.map(AbsolutePath(_)(args.cwd)).toList)
46+
files = paths.asScala.iterator.map(AbsolutePath(_)(args.cwd)).toList
47+
)
4648
)
4749

4850
override def withExcludedPaths(
49-
matchers: util.List[PathMatcher]): ScalafixArguments =
51+
matchers: util.List[PathMatcher]
52+
): ScalafixArguments =
5053
copy(args = args.copy(exclude = matchers.asScala.toList))
5154

5255
override def withWorkingDirectory(path: Path): ScalafixArguments = {
@@ -72,7 +75,8 @@ final case class ScalafixArgumentsImpl(args: Args = Args.default)
7275
}
7376

7477
override def withParsedArguments(
75-
args: util.List[String]): ScalafixArguments = {
78+
args: util.List[String]
79+
): ScalafixArguments = {
7680
if (args.isEmpty) this
7781
else {
7882
val decoder = Args.decoder(this.args)
@@ -94,8 +98,9 @@ final case class ScalafixArgumentsImpl(args: Args = Args.default)
9498
override def withClasspath(path: util.List[Path]): ScalafixArguments =
9599
copy(
96100
args = args.copy(
97-
classpath = Classpath(
98-
path.asScala.iterator.map(AbsolutePath(_)(args.cwd)).toList))
101+
classpath =
102+
Classpath(path.asScala.iterator.map(AbsolutePath(_)(args.cwd)).toList)
103+
)
99104
)
100105

101106
override def withSourceroot(path: Path): ScalafixArguments = {
@@ -104,7 +109,8 @@ final case class ScalafixArgumentsImpl(args: Args = Args.default)
104109
}
105110

106111
override def withMainCallback(
107-
callback: ScalafixMainCallback): ScalafixArguments =
112+
callback: ScalafixMainCallback
113+
): ScalafixArguments =
108114
copy(args = args.copy(callback = callback))
109115

110116
override def withCharset(charset: Charset): ScalafixArguments =
@@ -126,7 +132,8 @@ final case class ScalafixArgumentsImpl(args: Args = Args.default)
126132
}
127133

128134
override def withScalacOptions(
129-
options: util.List[String]): ScalafixArguments =
135+
options: util.List[String]
136+
): ScalafixArguments =
130137
copy(args = args.copy(scalacOptions = options.asScala.toList))
131138

132139
override def withScalaVersion(version: String): ScalafixArguments =

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ object ScalafixDiagnosticImpl {
1818
underlying
1919
case _ =>
2020
throw new IllegalArgumentException(
21-
"Unexpected diagnostic: " + scalafixDiagnostic.toString)
21+
"Unexpected diagnostic: " + scalafixDiagnostic.toString
22+
)
2223
}
2324
}
2425
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ final class ScalafixRuleImpl(rule: v1.Rule) extends ScalafixRule {
1313
case _: v1.SyntacticRule => ScalafixRuleKind.SYNTACTIC
1414
case _ =>
1515
throw new IllegalArgumentException(
16-
s"Rule '$rule' is neither semantic or syntactic")
16+
s"Rule '$rule' is neither semantic or syntactic"
17+
)
1718
}
1819
override def isLinter: Boolean = rule.isLinter
1920
override def isRewrite: Boolean = rule.isRewrite

scalafix-cli/src/main/scala/scalafix/internal/jgit/JGitDiff.scala

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,22 @@ object JGitDiff {
4444

4545
def edits(file: FileHeader): ModifiedFile = {
4646
val changes =
47-
file.toEditList.asScala.map(edit =>
48-
GitChange(edit.getBeginB, edit.getEndB))
47+
file.toEditList.asScala
48+
.map(edit => GitChange(edit.getBeginB, edit.getEndB))
4949

5050
ModifiedFile(path(file.getNewPath), changes.toList)
5151
}
5252
val diffs =
53-
getDiff(repository, oldTree, newTree).flatMap(file =>
54-
file.getChangeType match {
55-
case ADD => List(NewFile(path(file.getNewPath)))
56-
case MODIFY => List(edits(file))
57-
case RENAME => List(edits(file))
58-
case COPY => List(edits(file))
59-
case DELETE => Nil
60-
})
53+
getDiff(repository, oldTree, newTree).flatMap(
54+
file =>
55+
file.getChangeType match {
56+
case ADD => List(NewFile(path(file.getNewPath)))
57+
case MODIFY => List(edits(file))
58+
case RENAME => List(edits(file))
59+
case COPY => List(edits(file))
60+
case DELETE => Nil
61+
}
62+
)
6163

6264
Configured.Ok(DiffDisable(diffs))
6365
}
@@ -76,7 +78,8 @@ object JGitDiff {
7678

7779
private def resolve(
7880
repo: Repository,
79-
revstr: String): Either[String, ObjectId] = {
81+
revstr: String
82+
): Either[String, ObjectId] = {
8083
try {
8184
Option(repo.resolve(revstr)) match {
8285
case Some(id) => Right(id)
@@ -101,7 +104,8 @@ object JGitDiff {
101104

102105
private def iterator(
103106
repository: Repository,
104-
id: ObjectId): Either[String, AbstractTreeIterator] = {
107+
id: ObjectId
108+
): Either[String, AbstractTreeIterator] = {
105109
try {
106110
val walk = new RevWalk(repository)
107111
val tree = walk.parseTree(id)
@@ -119,7 +123,8 @@ object JGitDiff {
119123
private def getDiff(
120124
repository: Repository,
121125
oldTree: AbstractTreeIterator,
122-
newTree: AbstractTreeIterator): List[FileHeader] = {
126+
newTree: AbstractTreeIterator
127+
): List[FileHeader] = {
123128

124129
val diffFmt = new DiffFormatter(NullOutputStream.INSTANCE)
125130
diffFmt.setRepository(repository)

scalafix-core/src/main/scala/org/langmeta/internal/ScalametaInternals.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ object ScalametaInternals {
4141
def formatMessage(
4242
pos: Position,
4343
severity: String,
44-
message: String): String = {
44+
message: String
45+
): String = {
4546
if (pos != Position.None) {
4647
val input = pos.input
4748
val startLine = pos.startLine + 1

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,40 @@ import scalafix.v0.Symbol
88
class CustomMessage[T](
99
val value: T,
1010
val message: Option[String],
11-
val id: Option[String])
11+
val id: Option[String]
12+
)
1213

1314
object CustomMessage {
1415
implicit val SymbolDecoder: ConfDecoder[CustomMessage[Symbol.Global]] =
1516
decoder[Symbol.Global](field = "symbol")
1617

1718
implicit def CustomMessageEitherDecoder[A, B](
18-
implicit AB: ConfDecoder[Either[CustomMessage[A], CustomMessage[B]]])
19-
: ConfDecoder[CustomMessage[Either[A, B]]] =
19+
implicit AB: ConfDecoder[Either[CustomMessage[A], CustomMessage[B]]]
20+
): ConfDecoder[CustomMessage[Either[A, B]]] =
2021
AB.map {
2122
case Right(msg) =>
2223
new CustomMessage(Right(msg.value), msg.message, msg.id)
2324
case Left(msg) => new CustomMessage(Left(msg.value), msg.message, msg.id)
2425
}
2526

26-
def decoder[T](field: String)(
27-
implicit ev: ConfDecoder[T]): ConfDecoder[CustomMessage[T]] =
27+
def decoder[T](
28+
field: String
29+
)(implicit ev: ConfDecoder[T]): ConfDecoder[CustomMessage[T]] =
2830
ConfDecoder.instance[CustomMessage[T]] {
2931
case obj: Conf.Obj => {
3032
(obj.get[T](field) |@|
3133
obj.getOption[String]("message") |@|
3234
obj.getOption[String]("id")).map {
3335
case ((value, message0), id) =>
3436
val message =
35-
message0.map(msg =>
36-
if (msg.contains("\n")) {
37-
"\n" + msg.stripMargin
38-
} else {
39-
msg
40-
})
37+
message0.map(
38+
msg =>
39+
if (msg.contains("\n")) {
40+
"\n" + msg.stripMargin
41+
} else {
42+
msg
43+
}
44+
)
4145

4246
new CustomMessage(value, message, id)
4347
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ package scalafix.internal.config
33
case class LogContext(
44
line: sourcecode.Line,
55
file: sourcecode.File,
6-
enclosing: sourcecode.Enclosing) {
6+
enclosing: sourcecode.Enclosing
7+
) {
78
override def toString: String = enclosing.value.replaceAll(" .*", "")
89
}
910

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ object MetaconfigOps {
3131
}
3232
}
3333
def getKey[T](conf: Conf.Obj, path: String, extraNames: String*)(
34-
implicit ev: ConfDecoder[T]): Configured[T] = {
34+
implicit ev: ConfDecoder[T]
35+
): Configured[T] = {
3536
ConfGet.getKey(conf, path +: extraNames) match {
3637
case Some(value) => ev.read(value)
3738
case None => ConfError.missingField(conf, path).notOk

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ case class PrintStreamReporter(
1717
override private[scalafix] def report(
1818
message: String,
1919
position: Position,
20-
severity: LintSeverity): Unit = {
20+
severity: LintSeverity
21+
): Unit = {
2122
val formatted = position.formatMessage(severity.toString, message)
2223
out.println(formatted)
2324
}

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

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ trait ScalafixMetaconfigReaders {
9797

9898
def parseReplaceSymbol(
9999
from: String,
100-
to: String): Configured[(Symbol.Global, Symbol.Global)] =
100+
to: String
101+
): Configured[(Symbol.Global, Symbol.Global)] =
101102
symbolGlobalReader.read(Conf.Str(from)) |@|
102103
symbolGlobalReader.read(Conf.Str(to))
103104

@@ -110,10 +111,12 @@ trait ScalafixMetaconfigReaders {
110111
}
111112

112113
def ruleConfDecoderSyntactic(
113-
singleRuleDecoder: ConfDecoder[Rule]): ConfDecoder[Rule] =
114+
singleRuleDecoder: ConfDecoder[Rule]
115+
): ConfDecoder[Rule] =
114116
ruleConfDecoder(singleRuleDecoder)
115117
def ruleConfDecoder(
116-
singleRuleDecoder: ConfDecoder[Rule]): ConfDecoder[Rule] = {
118+
singleRuleDecoder: ConfDecoder[Rule]
119+
): ConfDecoder[Rule] = {
117120
ConfDecoder.instance[Rule] {
118121
case Conf.Lst(values) =>
119122
MetaconfigOps
@@ -153,8 +156,9 @@ trait ScalafixMetaconfigReaders {
153156
}
154157
}
155158

156-
def castReader[From, To](ConfDecoder: ConfDecoder[From])(
157-
implicit ev: ClassTag[To]): ConfDecoder[To] = ConfDecoder.flatMap {
159+
def castReader[From, To](
160+
ConfDecoder: ConfDecoder[From]
161+
)(implicit ev: ClassTag[To]): ConfDecoder[To] = ConfDecoder.flatMap {
158162
case x if ev.runtimeClass.isInstance(x) =>
159163
Configured.Ok(x.asInstanceOf[To])
160164
case x =>
@@ -183,7 +187,8 @@ trait ScalafixMetaconfigReaders {
183187
ConfError
184188
.typeMismatch(
185189
"Symbol.Global",
186-
Conf.Str(s"$els: ${els.productPrefix}"))
190+
Conf.Str(s"$els: ${els.productPrefix}")
191+
)
187192
.notOk
188193
}
189194
val toParse = SymbolOps.inferTrailingDot(path)
@@ -212,21 +217,24 @@ trait ScalafixMetaconfigReaders {
212217
}
213218

214219
implicit lazy val PatternDecoder: ConfDecoder[Pattern] = {
215-
ConfDecoder.stringConfDecoder.flatMap(pattern =>
216-
try {
217-
Configured.Ok(Pattern.compile(pattern, Pattern.MULTILINE))
218-
} catch {
219-
case ex: PatternSyntaxException =>
220-
Configured.NotOk(ConfError.message(ex.getMessage))
221-
})
220+
ConfDecoder.stringConfDecoder.flatMap(
221+
pattern =>
222+
try {
223+
Configured.Ok(Pattern.compile(pattern, Pattern.MULTILINE))
224+
} catch {
225+
case ex: PatternSyntaxException =>
226+
Configured.NotOk(ConfError.message(ex.getMessage))
227+
}
228+
)
222229
}
223230

224231
implicit lazy val CustomMessagePattern: ConfDecoder[CustomMessage[Pattern]] =
225232
CustomMessage.decoder(field = "pattern")
226233

227234
implicit def EitherConfDecoder[A, B](
228235
implicit A: ConfDecoder[A],
229-
B: ConfDecoder[B]): ConfDecoder[Either[A, B]] = {
236+
B: ConfDecoder[B]
237+
): ConfDecoder[Either[A, B]] = {
230238
def wrapLeft(a: A): Either[A, B] = Left(a)
231239
def wrapRight(b: B): Either[A, B] = Right(b)
232240
ConfDecoder.instance[Either[A, B]] {
@@ -237,7 +245,8 @@ trait ScalafixMetaconfigReaders {
237245
NotOk(
238246
ConfError
239247
.message(
240-
"Failed to decode configuration for either of the following types:")
248+
"Failed to decode configuration for either of the following types:"
249+
)
241250
.combine(err)
242251
)
243252
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ trait ScalafixReporter {
1010
private[scalafix] def report(
1111
message: String,
1212
position: Position,
13-
severity: LintSeverity): Unit
13+
severity: LintSeverity
14+
): Unit
1415
private[scalafix] def lint(d: RuleDiagnostic): Unit
1516
final def info(message: String, position: Position = Position.None): Unit =
1617
report(message, position, LintSeverity.Info)
@@ -25,7 +26,8 @@ object ScalafixReporter {
2526
def report(
2627
message: String,
2728
position: Position,
28-
severity: LintSeverity): Unit = ()
29+
severity: LintSeverity
30+
): Unit = ()
2931
def lint(d: RuleDiagnostic): Unit = ()
3032
}
3133
def default: ScalafixReporter = PrintStreamReporter.default

0 commit comments

Comments
 (0)