File tree 9 files changed +85
-27
lines changed 9 files changed +85
-27
lines changed Original file line number Diff line number Diff line change
1
+ name : CI
2
+ on :
3
+ push :
4
+ pull_request :
5
+ jobs :
6
+ build :
7
+ runs-on : ubuntu-latest
8
+ steps :
9
+ - uses : actions/checkout@v4
10
+ - uses : actions/setup-java@v4
11
+ with :
12
+ distribution : temurin
13
+ java-version : 8
14
+ cache : sbt
15
+ - uses : sbt/setup-sbt@v1
16
+ - run : sbt +test
17
+ format :
18
+ runs-on : ubuntu-latest
19
+ steps :
20
+ - uses : actions/checkout@v4
21
+ - uses : actions/setup-java@v4
22
+ with :
23
+ distribution : temurin
24
+ java-version : 8
25
+ - uses : sbt/setup-sbt@v1
26
+ - run : sbt scalafmtSbtCheck +scalafmtCheckAll
Original file line number Diff line number Diff line change
1
+ name : Release
2
+ on :
3
+ push :
4
+ branches : [main]
5
+ tags : ["*"]
6
+ jobs :
7
+ publish :
8
+ runs-on : ubuntu-latest
9
+ steps :
10
+ - uses : actions/checkout@v4
11
+ with :
12
+ fetch-depth : 0
13
+ - uses : actions/setup-java@v4
14
+ with :
15
+ distribution : temurin
16
+ java-version : 8
17
+ cache : sbt
18
+ - uses : sbt/setup-sbt@v1
19
+ - run : sbt ci-release
20
+ env :
21
+ PGP_PASSPHRASE : ${{ secrets.PGP_PASSPHRASE }}
22
+ PGP_SECRET : ${{ secrets.PGP_SECRET }}
23
+ SONATYPE_PASSWORD : ${{ secrets.SONATYPE_PASSWORD }}
24
+ SONATYPE_USERNAME : ${{ secrets.SONATYPE_USERNAME }}
Original file line number Diff line number Diff line change 1
- version = "3.7.15"
2
- runner.dialect = scala213
1
+ version = 3.9 .2
2
+ runner.dialect = scala213
3
+ maxColumn = 120
Original file line number Diff line number Diff line change @@ -4,38 +4,32 @@ Repository of custom scalafix rules for Iterable projects.
4
4
5
5
## Usage
6
6
7
- This library is not published anywhere yet, so you'll first need to build and publish locally with:
8
- ```
9
- sbt publishLocal
7
+ See the tags on this repo to find the the latest version or the version you want to use. You can use the rules in your project by adding a dependency to the ` scalafix-rules ` artifact:
8
+
9
+ ``` scala
10
+ ThisBuild / libraryDependencies += " com.iterable" %% " scalafix-rules" % " 0.1.0" % ScalafixConfig
10
11
```
11
- Then you can reference the published library version in your project.
12
12
13
- For example, you can run version ` 0.1.0 ` of ` NoFutureTraverse ` dynamically in the ` sbt ` console:
13
+ This will make the rules available to reference in your ` .scalafix.conf ` file.
14
+
15
+ You can also run directly from the sbt console without including it in your build.
16
+ For example, to run version ` 0.1.0 ` of ` NoFutureTraverse ` dynamically in the ` sbt ` console:
14
17
15
18
```
16
19
scalafix dependency:[email protected] ::scalafix-rules:0.1.0
17
20
```
18
21
19
- Replace the version ` 0.1.0 ` with the version you published.
20
-
21
- To run the rules by default with ` scalafix ` or ` scalafixAll ` , you'll need to add a library dependency in ` build.sbt ` :
22
+ ### NoFutureTraverse
22
23
23
- ``` scala
24
- ThisBuild / libraryDependencies += " com.iterable" %% " scalafix-rules" % " 0.1.0" % ScalafixConfig
25
- ```
26
-
27
- Then you can add the rules in your ` .scalafix.conf ` file, e.g.:
24
+ Disallows the use of ` Future.traverse ` in your Scala code, to prevent a potentially unbounded number of concurrent tasks from being run at once.
28
25
29
26
``` hocon
30
27
rules = [
31
28
# ...
32
- NoFutureTraverse # validate that Future.traverse is not used
29
+ NoFutureTraverse
33
30
]
34
31
35
- # Configuration for the NoFutureTraverse rule
36
32
NoFutureTraverse {
37
- isError = true
33
+ isError = true # Whether to treat violations as errors (default: true)
38
34
}
39
35
```
40
-
41
-
Original file line number Diff line number Diff line change @@ -10,7 +10,14 @@ inThisBuild(
10
10
licenses := List (
11
11
" Apache-2.0" -> url(" http://www.apache.org/licenses/LICENSE-2.0" )
12
12
),
13
- developers := List ()
13
+ developers := List (
14
+ Developer (
15
+ " gmethvin" ,
16
+ " Greg Methvin" ,
17
+
18
+ new URL (" https://github.com/gmethvin" )
19
+ )
20
+ )
14
21
)
15
22
)
16
23
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import scala.concurrent.Await
8
8
import scala .concurrent .ExecutionContext .Implicits .global
9
9
import scala .concurrent .duration ._
10
10
11
+ /* scalafmt: { newlines.source = fold } */
11
12
object FutureSequenceTest {
12
13
val futures = List (Future { " hello" }, Future { " world" })
13
14
val result = Future .sequence(futures).map(_.mkString) // assert: NoFutureTraverse
Original file line number Diff line number Diff line change @@ -8,8 +8,9 @@ import scala.concurrent.Await
8
8
import scala .concurrent .ExecutionContext .Implicits .global
9
9
import scala .concurrent .duration ._
10
10
11
+ /* scalafmt: { newlines.source = fold } */
11
12
object FutureTraverseTest {
12
13
val items = List (" hello" , " world" )
13
- val result = Future .traverse(items)(item => Future (item.length)).map(_.sum) // assert: NoFutureTraverse
14
- println(Await .result(result , 1 .second))
14
+ val sum = Future .traverse(items)(item => Future (item.length)).map(_.sum) // assert: NoFutureTraverse
15
+ println(Await .result(sum , 1 .second))
15
16
}
Original file line number Diff line number Diff line change 1
1
addSbtPlugin(" com.github.sbt" % " sbt-ci-release" % " 1.9.2" )
2
2
addSbtPlugin(" ch.epfl.scala" % " sbt-scalafix" % " 0.13.0" )
3
+ addSbtPlugin(" org.scalameta" % " sbt-scalafmt" % " 2.5.4" )
3
4
dependencyOverrides += " ch.epfl.scala" % " scalafix-interfaces" % " 0.13.0"
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import scalafix.lint._
8
8
import scalafix .v1 ._
9
9
10
10
case class NoFutureTraverseConfig (
11
- isError : Boolean = false
11
+ isError : Boolean = false
12
12
)
13
13
object NoFutureTraverseConfig {
14
14
implicit val surface : Surface [NoFutureTraverseConfig ] =
@@ -21,7 +21,8 @@ class NoFutureTraverse(config: NoFutureTraverseConfig) extends SemanticRule("NoF
21
21
22
22
case class Deprecation (position : Position , name : String ) extends Diagnostic {
23
23
override def message = s " $name is deprecated "
24
- override def severity = if (config.isError) LintSeverity .Error else LintSeverity .Warning
24
+ override def severity =
25
+ if (config.isError) LintSeverity .Error else LintSeverity .Warning
25
26
}
26
27
27
28
def this () = this (NoFutureTraverseConfig ())
@@ -31,8 +32,10 @@ class NoFutureTraverse(config: NoFutureTraverseConfig) extends SemanticRule("NoF
31
32
.getOrElse(" NoFutureTraverse" )(this .config)
32
33
.map(c => new NoFutureTraverse (c))
33
34
34
- val futureTraverse = SymbolMatcher .normalized(" scala.concurrent.Future.traverse" )
35
- val futureSequence = SymbolMatcher .normalized(" scala.concurrent.Future.sequence" )
35
+ val futureTraverse =
36
+ SymbolMatcher .normalized(" scala.concurrent.Future.traverse" )
37
+ val futureSequence =
38
+ SymbolMatcher .normalized(" scala.concurrent.Future.sequence" )
36
39
37
40
override def fix (implicit doc : SemanticDocument ): Patch = {
38
41
doc.tree.collect {
You can’t perform that action at this time.
0 commit comments