https://kotlinlang.org logo
#getting-started
Title
# getting-started
m

mitch

08/16/2022, 6:53 PM
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

Stefan Oltmann

08/16/2022, 9:22 PM
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

mitch

08/16/2022, 11:20 PM
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

Stefan Oltmann

08/17/2022, 11:22 AM
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

mitch

08/25/2022, 8:37 PM
Thanks, Stefan!
3 Views