Skip to content

Commit

Permalink
Update scalafmt-core to 2.7.5 (#164)
Browse files Browse the repository at this point in the history
Co-authored-by: Ricardo Martins <ricardocmartins91@gmail.com>
  • Loading branch information
scala-steward and RCMartins committed Feb 21, 2021
1 parent f9bc886 commit d796500
Show file tree
Hide file tree
Showing 16 changed files with 46 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .scalafmt.conf
@@ -1,4 +1,4 @@
version = 2.6.4
version = 2.7.5

project.git = true
project.excludeFilters = [
Expand Down
13 changes: 6 additions & 7 deletions blinky-core/src/main/scala/blinky/internal/Blinky.scala
Expand Up @@ -66,13 +66,12 @@ class Blinky(config: BlinkyConfig) extends SemanticRule("Blinky") {
val (finalPatch, mutantsFound): (Seq[Patch], Seq[Seq[Mutant]]) =
findMutations
.topTreeMutations(doc.tree)
.flatMap {
case (original, MutatedTerms(mutationsFound, needsParens)) =>
val mutantSeq =
mutationsFound
.filterNot(_.structure == original.structure)
.map(mutated => createMutant(original, mutated, fileName))
createPatch(mutantSeq, needsParens = needsParens)
.flatMap { case (original, MutatedTerms(mutationsFound, needsParens)) =>
val mutantSeq =
mutationsFound
.filterNot(_.structure == original.structure)
.map(mutated => createMutant(original, mutated, fileName))
createPatch(mutantSeq, needsParens = needsParens)
}
.unzip

Expand Down
31 changes: 13 additions & 18 deletions blinky-core/src/main/scala/blinky/internal/FindMutations.scala
Expand Up @@ -113,9 +113,8 @@ class FindMutations(activeMutators: Seq[Mutator], implicit val doc: SemanticDocu
matchTerm,
topMainTermMutations(expr).map(mutated => Term.Match(mutated, cases)) ++
cases.zipWithIndex
.flatMap {
case (Case(pat, cond, body), index) =>
topMainTermMutations(body).map(mutated => (Case(pat, cond, mutated), index))
.flatMap { case (Case(pat, cond, body), index) =>
topMainTermMutations(body).map(mutated => (Case(pat, cond, mutated), index))
}
.map { case (mutated, index) => Term.Match(expr, cases.updated(index, mutated)) },
cases.flatMap(caseTerm =>
Expand All @@ -127,9 +126,8 @@ class FindMutations(activeMutators: Seq[Mutator], implicit val doc: SemanticDocu
selectSmallerMutation(
parFunc,
cases.zipWithIndex
.flatMap {
case (Case(pat, cond, body), index) =>
topMainTermMutations(body).map(mutated => (Case(pat, cond, mutated), index))
.flatMap { case (Case(pat, cond, body), index) =>
topMainTermMutations(body).map(mutated => (Case(pat, cond, mutated), index))
}
.map { case (mutated, index) => Term.PartialFunction(cases.updated(index, mutated)) },
cases.flatMap(caseTerm =>
Expand Down Expand Up @@ -176,9 +174,8 @@ class FindMutations(activeMutators: Seq[Mutator], implicit val doc: SemanticDocu
newAnonymous,
inits.zipWithIndex
.flatMap { case (init, index) => initMutateMain(init).map((_, index)) }
.map {
case (mutated, index) =>
Term.NewAnonymous(Template(early, inits.updated(index, mutated), self, stats))
.map { case (mutated, index) =>
Term.NewAnonymous(Template(early, inits.updated(index, mutated), self, stats))
} ++
Seq.empty, //TODO when the top stats are completely done we should update this
inits
Expand Down Expand Up @@ -211,15 +208,13 @@ class FindMutations(activeMutators: Seq[Mutator], implicit val doc: SemanticDocu
init.argss
.map(_.zipWithIndex)
.zipWithIndex
.flatMap {
case (args, index) =>
args.flatMap {
case (arg, indexInner) => topMainTermMutations(arg).map((_, (index, indexInner)))
}
.flatMap { case (args, index) =>
args.flatMap { case (arg, indexInner) =>
topMainTermMutations(arg).map((_, (index, indexInner)))
}
}
.map {
case (mutated, (index, indexInner)) =>
val argsUpdated = init.argss(index).updated(indexInner, mutated)
Init(init.tpe, init.name, init.argss.updated(index, argsUpdated))
.map { case (mutated, (index, indexInner)) =>
val argsUpdated = init.argss(index).updated(indexInner, mutated)
Init(init.tpe, init.name, init.argss.updated(index, argsUpdated))
}
}
4 changes: 2 additions & 2 deletions blinky-core/src/main/scala/blinky/v0/Mutator.scala
Expand Up @@ -164,8 +164,8 @@ object Mutator {
object NonEmptyInterToMutated extends SimpleMutator("NonEmptyInterToMutated") {
override def getMutator(implicit doc: SemanticDocument): MutationResult = {
case Term.Interpolate(Term.Name("s" | "f" | "raw"), lits, names)
if names.nonEmpty || lits.exists {
case Lit.String(str) => str.nonEmpty
if names.nonEmpty || lits.exists { case Lit.String(str) =>
str.nonEmpty
} =>
default(Lit.String(""), Lit.String("mutated!"))
}
Expand Down
4 changes: 2 additions & 2 deletions blinky-core/src/main/scala/blinky/v0/Mutators.scala
Expand Up @@ -23,8 +23,8 @@ object Mutators {
.getOrElse(Configured.Ok(Mutators(list.flatMap(_.get.mutations))))
case Conf.Obj(values) =>
val list =
values.map {
case (mutatorName, conf) => readerMutationsAux(s"$mutatorName.").read(conf)
values.map { case (mutatorName, conf) =>
readerMutationsAux(s"$mutatorName.").read(conf)
}
list
.find(_.isNotOk)
Expand Down
3 changes: 1 addition & 2 deletions ci-tests/examples/example1/src/main/scala/Example.scala
@@ -1,5 +1,5 @@
object Example {
def calc(nOpt: Option[Int]): String = {
def calc(nOpt: Option[Int]): String =
nOpt
.map { n =>
if (n > 5)
Expand All @@ -8,5 +8,4 @@ object Example {
"small"
}
.getOrElse("<empty>")
}
}
3 changes: 2 additions & 1 deletion ci-tests/examples/example2/src/main/scala/Example.scala
@@ -1,4 +1,5 @@
object Example {
def set1: Set[String] /* issue if this type is not explicitly set - SLS 3.2.10 */ = Some(Set("")).getOrElse(Set())
def set1: Set[String] /* issue if this type is not explicitly set - SLS 3.2.10 */ =
Some(Set("")).getOrElse(Set())
val set2: Set[String] = set1
}
@@ -1,7 +1,7 @@
import Utils.Number

object Example {
def calc(nOpt: Option[Int]): String = {
def calc(nOpt: Option[Int]): String =
nOpt
.map { n =>
if (n > Number)
Expand All @@ -10,5 +10,4 @@ object Example {
"small"
}
.getOrElse("<empty>")
}
}
@@ -1,7 +1,7 @@
import Utils.Number

object Example {
def calc(nOpt: Option[Int]): String = {
def calc(nOpt: Option[Int]): String =
nOpt
.map { n =>
if (n > Number)
Expand All @@ -10,5 +10,4 @@ object Example {
"small"
}
.getOrElse("<empty>")
}
}
3 changes: 1 addition & 2 deletions ci-tests/examples/example5/src/main/scala/Example.scala
@@ -1,5 +1,5 @@
object Example {
def calc(nOpt: Option[Int]): String = {
def calc(nOpt: Option[Int]): String =
nOpt
.map { n =>
if (n > 5)
Expand All @@ -8,5 +8,4 @@ object Example {
"small"
}
.getOrElse("<empty>")
}
}
10 changes: 6 additions & 4 deletions ci-tests/examples/example7/src/main/scala/Example.scala
Expand Up @@ -7,8 +7,10 @@ object Example {
case object String extends ValueType

def show(values: List[ValueType]): String =
values.map {
case Number => "<number>"
case String => "<string>"
}.mkString("[", ", ", "]")
values
.map {
case Number => "<number>"
case String => "<string>"
}
.mkString("[", ", ", "]")
}
4 changes: 2 additions & 2 deletions input/src/main/scala/test/GeneralSyntax1.scala
Expand Up @@ -20,8 +20,8 @@ object GeneralSyntax1 {
case _ => false
}

val partial = list.collect {
case true => false
val partial = list.collect { case true =>
false
}

val list2 = list.map(_ => true)
Expand Down
4 changes: 2 additions & 2 deletions input/src/main/scala/test/PartialFunctionsMutators1.scala
Expand Up @@ -15,8 +15,8 @@ object PartialFunctionsMutators1 {
}

val value2 =
List(10, 20).map {
case _ => false
List(10, 20).map { case _ =>
false
}

val value3 =
Expand Down
4 changes: 2 additions & 2 deletions input/src/main/scala/test/PartialFunctionsMutators2.scala
Expand Up @@ -13,7 +13,7 @@ object PartialFunctionsMutators2 {
case 'i' | 'o' => '#'
}

List(Foo("bar", true)).collect {
case Foo("abc" | "bar", _) => 123
List(Foo("bar", true)).collect { case Foo("abc" | "bar", _) =>
123
}
}
4 changes: 2 additions & 2 deletions output/src/main/scala-output/test/GeneralSyntax1.scala
Expand Up @@ -15,8 +15,8 @@ object GeneralSyntax1 {
case _ => if (???) true else false
}

val partial = list.collect {
case true => if (???) true else false
val partial = list.collect { case true =>
if (???) true else false
}

val list2 = list.map(_ => if (???) false else true)
Expand Down
Expand Up @@ -26,8 +26,8 @@ object PartialFunctionsMutators1 {
})

val value2 =
List(10, 20).map {
case _ => false
List(10, 20).map { case _ =>
false
}

val value3 =
Expand Down

0 comments on commit d796500

Please sign in to comment.