I’m working on a large code base where we’re upgra...
# getting-started
m
I’m working on a large code base where we’re upgrading from Kotlin 1.5 to 1.7. We have a ton of non-exhaustive `when`s and unnecessary
?.
making variables look nullable causing type mismatches. Are there any best practices on how to do these upgrades incrementally? As an aside, is there a more appropriate channel for this post? Feels like we need a #versions or #upgrading Thanks
s
The term you are looking for is migration 😉
❤️ 2
If you want to bring version A to version B you usually google for a "migration guide" and you will find what you are looking for.
mind blown 1
m
Ha, thanks!
I think we need a #migration channel. 😁
So, are there any tricks to migration? I wish there was something analogous to ktlint to fix some of these. Or, a way to ignore the non-exhaustive
when
issue until someone edits a file.
s
You can add the SonarLint and Detekt plugin to the mix. I use them in addition to the built-in IDEA inspections. Most of these have an autofix feature. You can also look at the bottom entries on the "Refactor" menu of IDEA. There are some migration assistants like "Migrate to AppCompat..." and so on. But yes, most of the stuff you will need to do by hand following the migration guides. JetBrains often puts links to migration guides in the release notes - so watch out for these.
m
Thanks, Stefan!