Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run RedundantParens #13

Open
wants to merge 1 commit into
base: 0.4.9
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
project.git = true
rewrite.rules = [RedundantParens]
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ final case class NodeMetrics(address: Address,
// Average metrics present in both latest and current.
val updated = for {
latest ← latestNode.metrics
current ← currentNode.metrics if (latest sameAs current)
current ← currentNode.metrics if latest sameAs current
} yield {
current :+ latest
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ object JsonQueryExamples extends Specification {
"List of IPs in cluster2" in {
val ips = for {
cluster @ JObject(x) <- json \ "data_center"
if (x contains JField("name", JString("cluster2")))
if x contains JField("name", JString("cluster2"))
JField("ip", JString(ip)) <- (cluster \\ "ip").obj
} yield {
ip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ trait DocumentCleaner {

for {
node <- ems
images: Elements = node.getElementsByTag("img") if (images.size == 0)
images: Elements = node.getElementsByTag("img") if images.size == 0
} {
val tn: TextNode = new TextNode(node.text, doc.baseUri)
node.replaceWith(tn)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ private[annotator] object ModifierChecker {
("private", "protected"),
if (withPrivate) ("private", "override") else ("", "")
)
for ((bad1, bad2) <- illegalCombinations if (bad1 == text &&
for ((bad1, bad2) <- illegalCombinations if bad1 == text &&
owner.hasModifierPropertyScala(bad2)) ||
(bad2 == text &&
owner.hasModifierPropertyScala(bad1))) {
(bad2 == text &&
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This indent is a scalafmt bug: https://github.com/olafurpg/scalafmt/issues/579

owner.hasModifierPropertyScala(bad1)) {
proccessError(
ScalaBundle.message("illegal.modifiers.combination", bad1, bad2),
element,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ class PartitionStateMachine(controller: KafkaController) extends Logging {
// try to move all partitions in NewPartition or OfflinePartition state to OnlinePartition state except partitions
// that belong to topics to be deleted
for ((topicAndPartition, partitionState) <- partitionState
if (!controller.deleteTopicManager.isTopicQueuedUpForDeletion(
topicAndPartition.topic))) {
if !controller.deleteTopicManager.isTopicQueuedUpForDeletion(
topicAndPartition.topic)) {
if (partitionState.equals(OfflinePartition) ||
partitionState.equals(NewPartition))
handleStateChange(topicAndPartition.topic,
Expand Down
2 changes: 1 addition & 1 deletion repos/lila/modules/setup/src/main/ValidFen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ object ValidFen {
def apply(strict: Boolean)(fen: String): Option[ValidFen] =
for {
parsed ← chess.format.Forsyth <<< fen
if (parsed.situation playable strict)
if parsed.situation playable strict
validated = chess.format.Forsyth >> parsed
} yield ValidFen(validated, parsed.situation)
}
2 changes: 1 addition & 1 deletion repos/sbt/main/src/main/scala/sbt/EvaluateTask.scala
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ object EvaluateTask {
}
}

for ((key, msg, ex) <- keyed if (msg.isDefined || ex.isDefined)) {
for ((key, msg, ex) <- keyed if msg.isDefined || ex.isDefined) {
val msgString =
(msg.toList ++ ex.toList.map(ErrorHandling.reducedToString))
.mkString("\n\t")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ trait MatchAnalysis extends MatchApproximation {
// with Nil and List().
val result = mutable.Buffer[CounterExample]()
for (example <- examples
if (!result.exists(example coveredBy _))) result += example
if !result.exists(example coveredBy _)) result += example
result.toList
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -855,8 +855,8 @@ abstract class RefChecks
}

// Check the remainder for invalid absoverride.
for (member <- rest; if (member.isAbstractOverride &&
member.isIncompleteIn(clazz))) {
for (member <- rest; if member.isAbstractOverride &&
member.isIncompleteIn(clazz)) {
val other = member.superSymbolIn(clazz)
val explanation =
if (other != NoSymbol)
Expand Down
2 changes: 1 addition & 1 deletion repos/scala/test/files/run/reify_for1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import scala.tools.reflect.Eval
object Test extends App {
reify {
val sumOfSquares1 =
(for (i <- 1 to 100; if (i % 3 == 0)) yield Math.pow(i, 2)).sum
(for (i <- 1 to 100; if i % 3 == 0) yield Math.pow(i, 2)).sum
val sumOfSquares2 = (1 to 100).filter(_ % 3 == 0).map(Math.pow(_, 2)).sum
assert(sumOfSquares1 == sumOfSquares2)
}.eval
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class DefaultPromiseTest {
private def promiseChain(p: PromiseId): Option[(ChainId, Chain)] = {
val found: Iterable[(ChainId, Chain)] = for ((cid, c) <- chains;
p0 <- c.promises;
if (p0 == p))
if p0 == p)
yield ((cid, c))
found.toList match {
case Nil => None
Expand Down
2 changes: 1 addition & 1 deletion repos/scala/test/junit/scala/math/BigDecimalTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class BigDecimalTest {
BigDecimal.exact(0.1f),
BigDecimal.decimal((0.1f).toDouble)
)
for (a <- different; b <- different if (a ne b))
for (a <- different; b <- different if a ne b)
assert(a != b,
"BigDecimal representations of Double mistakenly conflated")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class ObservableMapSpec[K, V]
// The `for` loop implements operation equivalent to `map.retain`
// without throwing ConcurrentModificationException.
// compareInstances(map.retain((i, str) => i % 2 == 0), map, true)
for (k <- map.keys.toArray if (k % 2 != 0)) { map.remove(k) }
for (k <- map.keys.toArray if k % 2 != 0) { map.remove(k) }
map should equal(
ObservableMap((10 to 20).filter(_ % 2 == 0).map(i => (i, i.toString))))
removedEntries.toList.sortWith(_._1 < _._1) should equal(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ class TypedSimilarityTest extends WordSpec with Matchers {
seq =>
seq.map { case (from, to) => (from, 1.0) }.toMap
}
for ((k1, v1) <- matrix if (k1 % 2 == 0);
(k2, v2) <- matrix if (k2 % 2 == 1))
for ((k1, v1) <- matrix if k1 % 2 == 0;
(k2, v2) <- matrix if k2 % 2 == 1)
yield
((k1, k2) -> (dot(v1, v2) / scala.math.sqrt(
dot(v1, v1) * dot(v2, v2))))
Expand All @@ -108,8 +108,8 @@ class TypedSimilarityTest extends WordSpec with Matchers {
seq =>
seq.map { case (from, to, weight) => (from, weight) }.toMap
}
for ((k1, v1) <- matrix if (k1 % 2 == 0);
(k2, v2) <- matrix if (k2 % 2 == 1))
for ((k1, v1) <- matrix if k1 % 2 == 0;
(k2, v2) <- matrix if k2 % 2 == 1)
yield
((k1, k2) -> (dot(v1, v2) / scala.math.sqrt(
dot(v1, v1) * dot(v2, v2))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ class JoinTest extends AsyncTest[RelationalTestDB] {
lazy val bs = TableQuery[B]

val q1 = for {
(a, b) <- as joinLeft bs on (_.id.? === _.id) if (b.isEmpty)
(a, b) <- as joinLeft bs on (_.id.? === _.id) if b.isEmpty
} yield (a.id)
val q2 =
bs.joinLeft(as).on(_.id === _.id).filter(_._2.isEmpty).map(_._1.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ class MainTest extends AsyncTest[JdbcTestDB] { mainTest =>
}.flatMap { _ =>
val q4 = for {
u <- users
o <- u.orders if (o.orderID === (for {
o <- u.orders if o.orderID === (for {
o2 <- orders filter (o.userID === _.userID)
} yield o2.orderID).max)
} yield o2.orderID).max
} yield (u.first, o.orderID)
q4.result.statements.toSeq.length.should(_ >= 1)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging {

/** Set JAR files to distribute to the cluster. */
def setJars(jars: Seq[String]): SparkConf = {
for (jar <- jars if (jar == null))
for (jar <- jars if jar == null)
logWarning("null jar passed to SparkContext constructor")
set("spark.jars", jars.filter(_ != null).mkString(","))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ private[spark] class MetricsConfig(conf: SparkConf) extends Logging {
propertyCategories = subProperties(properties, INSTANCE_REGEX)
if (propertyCategories.contains(DEFAULT_PREFIX)) {
val defaultProperty = propertyCategories(DEFAULT_PREFIX).asScala
for ((inst, prop) <- propertyCategories if (inst != DEFAULT_PREFIX);
(k, v) <- defaultProperty if (prop.get(k) == null)) {
for ((inst, prop) <- propertyCategories if inst != DEFAULT_PREFIX;
(k, v) <- defaultProperty if prop.get(k) == null) {
prop.put(k, v)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ private class PartitionCoalescer(maxPartitions: Int,
}
}
} else {
for (p <- prev.partitions if (!initialHash.contains(p))) {
for (p <- prev.partitions if !initialHash.contains(p)) {
// throw every partition into group
pickBin(p).arr += p
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class AlgebraicTest extends SpireProperties {
def genRational: Gen[Rational] =
for {
n <- genBigInt
d <- genBigInt if (d.signum != 0)
d <- genBigInt if d.signum != 0
} yield Rational(n, d)

def genRationalPoly: Gen[Polynomial[Rational]] =
Expand Down Expand Up @@ -284,7 +284,7 @@ class AlgebraicTest extends SpireProperties {
for {
RationalAlgebraic(lhsA, lhsQ) <- genRationalAlgebraic(depth + 1)
RationalAlgebraic(rhsA, rhsQ) <- genRationalAlgebraic(depth + 1)
if (rhsQ.signum != 0)
if rhsQ.signum != 0
} yield RationalAlgebraic(lhsA / rhsA, lhsQ / rhsQ)

def genNeg(depth: Int): Gen[RationalAlgebraic] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ private object GlobalFlag {
// Search for Scala objects annotated with GlobalFlagVisible:
// Since Scala object classnames end with $, filter by name first
// before attempting to load the class.
for (info <- ClassPath.browse(loader) if (info.name endsWith "$")) try {
for (info <- ClassPath.browse(loader) if info.name endsWith "$") try {
val cls = info.load()
if (cls.isAnnotationPresent(markerClass)) {
get(info.name.dropRight(1)) match {
Expand Down