Skip to content

Commit 35e5a64

Browse files
authored
Scala 2.13.3 + sbt-tpolecat, fix all code for activated linting options (monix#1221)
1 parent cd044dc commit 35e5a64

File tree

371 files changed

+1975
-1511
lines changed

Some content is hidden

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

371 files changed

+1975
-1511
lines changed

.scalafmt.conf

+13-35
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,13 @@
11
version = "2.6.4"
22

3-
#
4-
# See http://scalameta.org/scalafmt/#Configuration for details
5-
#
6-
project {
7-
includeFilters = [
8-
".*.\\.scala$"
9-
".*\\..sbt$"
10-
]
11-
}
12-
133
maxColumn = 120
4+
docstrings = ScalaDoc
145

15-
# Vertical alignment, options: none, some, more
16-
#
17-
# This awkward, self-contradictory, configuration ensures that only
18-
# the common sbt tokens get aligned, and not "production" code.
19-
#
20-
align = none
21-
align {
22-
openParenCallSite = false
23-
openParenDefnSite = false
24-
tokens = ["%", ":=", "~=", "<-"]
25-
}
6+
project.git = true
7+
preset = default
8+
9+
# Alignment is cool, until we have to view diffs and solve merge conflicts
10+
align.preset = none
2611

2712
# If true, the margin character | is aligned with the opening triple quote string literals
2813
assumeStandardLibraryStripMargin = true
@@ -31,6 +16,11 @@ assumeStandardLibraryStripMargin = true
3116
#see: http://scalameta.org/scalafmt/#includeCurlyBraceInSelectChains
3217
includeCurlyBraceInSelectChains = false
3318

19+
rewrite.rules = [
20+
SortImports,
21+
AvoidInfix,
22+
]
23+
3424
continuationIndent {
3525
callSite = 2
3626
defnSite = 2
@@ -39,7 +29,6 @@ continuationIndent {
3929

4030
danglingParentheses = false
4131

42-
4332
newlines {
4433
alwaysBeforeTopLevelStatements = false
4534
sometimesBeforeColonInMethodReturnType = true
@@ -61,6 +50,7 @@ optIn {
6150
breaksInsideChains = false
6251
breakChainOnFirstMethodDot = true
6352
configStyleArguments = true
53+
blankLineBeforeDocstring = true
6454
}
6555

6656
runner {
@@ -74,16 +64,4 @@ runner {
7464
}
7565
}
7666

77-
rewrite {
78-
rules = [
79-
SortImports
80-
# if your for has more than one single <- then it gets transformed into a multit-line curly brace one
81-
# PreferCurlyFors
82-
]
83-
}
84-
85-
optIn {
86-
blankLineBeforeDocstring = true
87-
}
88-
89-
lineEndings=preserve
67+
lineEndings=preserve

.travis.yml

+13-13
Original file line numberDiff line numberDiff line change
@@ -10,49 +10,49 @@ matrix:
1010
scala: 2.11.12
1111
env:
1212
- COMMAND=ci-jvm-mima
13-
- SCALAJS_VERSION=0.6.32
13+
- SCALAJS_VERSION=0.6.33
1414
# Scala 2.11, JavaScript
1515
- jdk: oraclejdk8
1616
scala: 2.11.12
1717
env:
1818
- COMMAND=ci-js
19-
- SCALAJS_VERSION=0.6.32
19+
- SCALAJS_VERSION=0.6.33
2020
# Scala 2.12, JVM
2121
- jdk: oraclejdk8
22-
scala: 2.12.10
22+
scala: 2.12.12
2323
env:
2424
- COMMAND=ci-jvm
2525
- SCALAJS_VERSION=
2626
# Scala 2.12, JavaScript
2727
- jdk: oraclejdk8
28-
scala: 2.12.10
28+
scala: 2.12.12
2929
env:
3030
- COMMAND=ci-js
31-
- SCALAJS_VERSION=1.0.0
31+
- SCALAJS_VERSION=1.1.1
3232
# Scala 2.13, JVM
3333
- jdk: oraclejdk8
34-
scala: 2.13.1
34+
scala: 2.13.3
3535
env:
3636
- COMMAND=ci-jvm-all
3737
- SCALAJS_VERSION=
3838
# Scala 2.13, JVM, JDK 11
3939
- jdk: openjdk11
40-
scala: 2.13.1
40+
scala: 2.13.3
4141
env:
4242
- COMMAND=ci-jvm
4343
- SCALAJS_VERSION=
44-
# Scala 2.13, JavaScript 0.6.32
44+
# Scala 2.13, JavaScript 0.6.33
4545
- jdk: oraclejdk8
46-
scala: 2.13.1
46+
scala: 2.13.3
4747
env:
4848
- COMMAND=ci-js
49-
- SCALAJS_VERSION=0.6.32
50-
# Scala 2.13, JavaScript 1.0.0
49+
- SCALAJS_VERSION=0.6.33
50+
# Scala 2.13, JavaScript 1.1.1
5151
- jdk: oraclejdk8
52-
scala: 2.13.1
52+
scala: 2.13.3
5353
env:
5454
- COMMAND=ci-js
55-
- SCALAJS_VERSION=1.0.0
55+
- SCALAJS_VERSION=1.1.1
5656

5757
env:
5858
global:

benchmarks/shared/src/main/scala/monix/benchmarks/ChunkedEvalFilterMapSumBenchmark.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class ChunkedEvalFilterMapSumBenchmark {
7575
def setup(): Unit = {
7676
val chunks = (1 to chunkCount).map(i => Array.fill(chunkSize)(i))
7777
allElements = chunks.flatten
78-
expectedSum = allElements.sum
78+
expectedSum = allElements.sum.toLong
7979
}
8080

8181
@Benchmark
@@ -135,6 +135,7 @@ class ChunkedEvalFilterMapSumBenchmark {
135135
.foldLeftL(0L)(_ + _)
136136

137137
testResult(stream.runSyncUnsafe())
138+
()
138139
}
139140

140141
@Benchmark

benchmarks/shared/src/main/scala/monix/benchmarks/MapParallelObservableBenchmark.scala

+10-4
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ class MapParallelObservableBenchmark {
6565

6666
@Benchmark
6767
def mapOrdered(): Long = {
68-
val stream = Observable.range(0, size).mapParallelOrdered(parallelism)(x => Task.eval(x + 1))
68+
val stream = Observable.range(0, size.toLong).mapParallelOrdered(parallelism)(x => Task.eval(x + 1))
6969
sum(stream)
7070
}
7171

7272
@Benchmark
7373
def mapUnordered(): Long = {
74-
val stream = Observable.range(0, size).mapParallelUnordered(parallelism)(x => Task.eval(x + 1))
74+
val stream = Observable.range(0, size.toLong).mapParallelUnordered(parallelism)(x => Task.eval(x + 1))
7575
sum(stream)
7676
}
7777

@@ -81,10 +81,16 @@ class MapParallelObservableBenchmark {
8181
val scheduler = global
8282
private[this] var sum: Long = 0
8383

84-
def onError(ex: Throwable): Unit =
84+
def onError(ex: Throwable): Unit = {
8585
p.failure(ex)
86-
def onComplete(): Unit =
86+
()
87+
}
88+
89+
def onComplete(): Unit = {
8790
p.success(sum)
91+
()
92+
}
93+
8894
def onNext(elem: Long) = {
8995
sum += elem
9096
Continue

benchmarks/shared/src/main/scala/monix/benchmarks/ObservableConcatMapBenchmark.scala

+10-4
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ class ObservableConcatMapBenchmark {
6060

6161
@Benchmark
6262
def onePerCycle(): Long = {
63-
val stream = Observable.range(0, size).flatMap { x =>
63+
val stream = Observable.range(0, size.toLong).flatMap { x =>
6464
Observable.now(x + 1)
6565
}
6666
sum(stream)
6767
}
6868

6969
@Benchmark
7070
def morePerCycle(): Long = {
71-
val stream = Observable.range(0, size / 1000).flatMap { x =>
71+
val stream = Observable.range(0, size.toLong / 1000).flatMap { x =>
7272
Observable.range(x, x + 1000)
7373
}
7474
sum(stream)
@@ -80,10 +80,16 @@ class ObservableConcatMapBenchmark {
8080
val scheduler = global
8181
private[this] var sum: Long = 0
8282

83-
def onError(ex: Throwable): Unit =
83+
def onError(ex: Throwable): Unit = {
8484
p.failure(ex)
85-
def onComplete(): Unit =
85+
()
86+
}
87+
88+
def onComplete(): Unit = {
8689
p.success(sum)
90+
()
91+
}
92+
8793
def onNext(elem: Long) = {
8894
sum += elem
8995
Continue

benchmarks/shared/src/main/scala/monix/benchmarks/TaskSequenceBenchmark.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class TaskSequenceBenchmark {
8181
@Benchmark
8282
def catsParSequenceN(): Long = {
8383
val tasks = (0 until count).map(_ => IO(1)).toList
84-
val result = tasks.parSequenceN(parallelism).map(_.sum.toLong)
84+
val result = tasks.parSequenceN(parallelism.toLong).map(_.sum.toLong)
8585
result.unsafeRunSync()
8686
}
8787

build.sbt

+40-69
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ val reactiveStreamsVersion = "1.0.3"
5353
val minitestVersion = "2.8.2"
5454
val scalaTestVersion = "3.0.8"
5555
val implicitBoxVersion = "0.2.0"
56+
val kindProjectorVersion = "0.11.0"
57+
val betterMonadicForVersion = "0.3.1"
58+
val silencerVersion = "1.7.1"
59+
val scalaCompatVersion = "2.1.6"
5660
val customScalaJSVersion = Option(System.getenv("SCALAJS_VERSION"))
5761

5862
// The Monix version with which we must keep binary compatibility.
@@ -66,84 +70,51 @@ lazy val doNotPublishArtifact = Seq(
6670
publishArtifact in (Compile, packageBin) := false
6771
)
6872

69-
lazy val warnUnusedImport = Seq(
70-
scalacOptions ++= {
71-
CrossVersion.partialVersion(scalaVersion.value) match {
72-
case Some((2, 11)) =>
73-
Seq("-Ywarn-unused-import")
74-
case _ =>
75-
Seq("-Ywarn-unused:imports")
76-
}
77-
},
78-
scalacOptions in (Compile, console) --= Seq("-Ywarn-unused-import", "-Ywarn-unused:imports"),
79-
scalacOptions in Test --= Seq("-Ywarn-unused-import", "-Ywarn-unused:imports")
80-
)
81-
82-
lazy val sharedSettings = warnUnusedImport ++ Seq(
73+
lazy val sharedSettings = Seq(
8374
organization := "io.monix",
8475
scalaVersion := "2.13.3",
8576
crossScalaVersions := Seq("2.11.12", "2.12.12", "2.13.3"),
8677

87-
scalacOptions ++= Seq(
88-
// warnings
89-
"-unchecked", // able additional warnings where generated code depends on assumptions
90-
"-deprecation", // emit warning for usages of deprecated APIs
91-
"-feature", // emit warning usages of features that should be imported explicitly
92-
// Features enabled by default
93-
"-language:higherKinds",
94-
"-language:implicitConversions",
95-
"-language:experimental.macros",
96-
),
97-
98-
scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
99-
case Some((2, v)) if v <= 12 =>
100-
Seq(
101-
// possibly deprecated options
102-
"-Ywarn-inaccessible",
103-
// absolutely necessary for Iterant
104-
"-Ypartial-unification",
105-
)
106-
case _ =>
107-
Seq(
108-
"-Ymacro-annotations",
109-
)
110-
}),
111-
112-
// Linter
113-
scalacOptions ++= Seq(
114-
// Turns all warnings into errors ;-)
115-
"-Xfatal-warnings",
116-
// Enables linter options
117-
"-Xlint:adapted-args", // warn if an argument list is modified to match the receiver
118-
"-Xlint:nullary-unit", // warn when nullary methods return Unit
119-
"-Xlint:infer-any", // warn when a type argument is inferred to be `Any`
120-
"-Xlint:missing-interpolator", // a string literal appears to be missing an interpolator id
121-
"-Xlint:doc-detached", // a ScalaDoc comment appears to be detached from its element
122-
"-Xlint:private-shadow", // a private field (or class parameter) shadows a superclass field
123-
"-Xlint:type-parameter-shadow", // a local type parameter shadows a type already in scope
124-
"-Xlint:poly-implicit-overload", // parameterized overloaded implicit methods are not visible as view bounds
125-
"-Xlint:option-implicit", // Option.apply used implicit view
126-
"-Xlint:delayedinit-select", // Selecting member of DelayedInit
127-
"-Xlint:package-object-classes", // Class or object defined in package object
128-
),
129-
scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
130-
case Some((2, majorVersion)) if majorVersion <= 12 =>
131-
Seq(
132-
"-Xlint:inaccessible", // warn about inaccessible types in method signatures
133-
"-Xlint:by-name-right-associative", // By-name parameter of right associative operator
134-
"-Xlint:unsound-match" // Pattern match may not be typesafe
78+
/*
79+
// Enable this to debug warnings...
80+
scalacOptions in Compile ++= {
81+
CrossVersion.partialVersion(scalaVersion.value) match {
82+
case Some((2, 13)) => Seq("-Wconf:any:warning-verbose")
83+
case _ => Seq.empty
84+
}
85+
},
86+
*/
87+
88+
// Disabled from the sbt-tpolecat set
89+
scalacOptions in Compile ~= { options: Seq[String] =>
90+
options.filterNot(
91+
Set(
92+
"-Wunused:privates",
93+
"-Ywarn-unused:privates",
94+
"-Ywarn-unused:implicits",
95+
"-Wunused:implicits",
96+
"-Ywarn-unused:imports",
97+
"-Wunused:explicits",
98+
"-Ywarn-unused:params",
99+
"-Wunused:params",
135100
)
136-
case _ =>
137-
Seq.empty
138-
}),
101+
)
102+
},
139103

140-
// Turning off fatal warnings for ScalaDoc, otherwise we can't release.
141-
scalacOptions in (Compile, doc) ~= (_ filterNot (_ == "-Xfatal-warnings")),
104+
// Turning off fatal warnings for doc generation
105+
scalacOptions.in(Compile, doc) ~= filterConsoleScalacOptions,
106+
// Silence everything in auto-generated files
107+
scalacOptions += "-P:silencer:pathFilters=.*[/]src_managed[/].*",
142108

143109
// For working with partially-applied types
144-
addCompilerPlugin("org.typelevel" % "kind-projector" % "0.11.0" cross CrossVersion.full),
110+
addCompilerPlugin("org.typelevel" % "kind-projector" % kindProjectorVersion cross CrossVersion.full),
111+
addCompilerPlugin("com.olegpy" %% "better-monadic-for" % betterMonadicForVersion),
112+
addCompilerPlugin("com.github.ghik" % "silencer-plugin" % silencerVersion cross CrossVersion.full),
113+
114+
libraryDependencies +=
115+
"org.scala-lang.modules" %% "scala-collection-compat" % scalaCompatVersion % "optional;provided",
145116

146-
// ScalaDoc settings
117+
// ScalaDoc settings
147118
autoAPIMappings := true,
148119
scalacOptions in ThisBuild ++= Seq(
149120
// Note, this is used by the doc-source-url feature to determine the

monix-catnap/jvm/src/main/scala_2.12+/monix/catnap/internal/FutureLiftForPlatform.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ package internal
2020

2121
import java.util.concurrent.{CancellationException, CompletableFuture, CompletionException}
2222
import java.util.function.BiFunction
23-
2423
import cats.effect.{Async, Concurrent}
2524

2625
private[catnap] abstract class FutureLiftForPlatform {
@@ -32,7 +31,7 @@ private[catnap] abstract class FutureLiftForPlatform {
3231
F.flatMap(fa) { cf =>
3332
F.cancelable { cb =>
3433
subscribeToCompletable(cf, cb)
35-
F.delay(cf.cancel(true))
34+
F.delay { cf.cancel(true); () }
3635
}
3736
}
3837

@@ -97,5 +96,6 @@ private[catnap] abstract class FutureLiftForPlatform {
9796
}
9897
}
9998
})
99+
()
100100
}
101101
}

0 commit comments

Comments
 (0)