-
Notifications
You must be signed in to change notification settings - Fork 503
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
Load Scalafix migrations once at start-up #1309
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1309 +/- ##
=========================================
- Coverage 67.3% 67.2% -0.11%
=========================================
Files 98 98
Lines 1557 1494 -63
Branches 52 50 -2
=========================================
- Hits 1048 1004 -44
+ Misses 509 490 -19
Continue to review full report at Codecov.
|
This means if anyone used to pass JSON files with scalafix config, their files will no longer work, right? Or is JSON a valid subset of HOCON? |
modules/core/src/main/scala/org/scalasteward/core/edit/EditAlg.scala
Outdated
Show resolved
Hide resolved
|
||
def readResource[F[_]](resource: String)(implicit F: Sync[F]): F[String] = | ||
Resource | ||
.fromAutoCloseable(F.delay(Source.fromResource(resource))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I didn't know about Source.fromResource
!
Resource | ||
.fromAutoCloseable(IO(Source.fromResource(s"org/scalasteward/plugin/$name"))) | ||
.use(src => IO(FileData(name, src.mkString))) | ||
io.readResource[IO](s"org/scalasteward/plugin/$name") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
show
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a big fan of the Show
type class and I don't think we use show
anywhere else in the code base. If we would have an interpolator that ensures the interpolated value is a String
, I'd use it here and probably everywhere else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, let's keep it with s
then :)
@kubukoz Yes, JSON is a subset of HOCON, see https://github.com/lightbend/config/blob/master/HOCON.md#goals--background:
But I changed the name of the key |
I'm waiting for this with #1298 because I had to rebase to borrow |
def readResource[F[_]](resource: String)(implicit F: Sync[F]): F[String] = | ||
Resource | ||
.fromAutoCloseable(F.delay(Source.fromResource(resource))) | ||
.use(src => F.delay(src.mkString)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed this will block (maybe fromResource
too)... shall we add Blocker here?
This changes a few things about the loading of Scalafix migrations:
Default Scalafix migrations are now defined in a new
scalafix-migrations.conf
file that are packaged in the JAR as resource. @kubukoz proposed this idea in Support custom group migrations #1298 (comment) for groupId changes. A big benefit is that default Scalafix migrations are defined in the same format as user-supplied migrations.All Scalafix migrations are now loaded at start-up and a decoding error will lead to Scala Steward exiting immediately. This way we provide rapid feedback if the migrations file contains syntax errors and we avoid repeatedly loading the same migrations again and again.
HOCON is used as file format for Scalafix migrations. I think this is better suited for files that are written by humans since it allows comments for example. If someone feels strongly about this, I can be persuaded to change it back to JSON.