Right now, the majority of people writing code are writing code because they're being paid to do so, either by individuals or more likely, a business.
Those people, in turn, are not hiring programmers purely for altruism, they're doing it to achieve some goal, usually profit, increase in efficiency, and so on. They have to cope with estimating the curve for diminishing returns. They can figure out having a product that works 95% of the time, or one that works 96% of the time but costs 2x as much and takes 3x as long to develop may or may not be worth it. ... and ignore for now that developers are pretty bad at estimating project efforts as a whole, much less individual pieces of code.
There's no incentive for these employers to pay their people to produce 'perfect' code. Even in the field of medical devices or self driving cars or a number of other systems, there's still a point of diminishing returns, and largely the business determines it based on market expectations, and adjusts it based on market reactions (no one will buy a self-driving car that crashes 1/5'th of the time, but they might buy one that crashes only 1 in 500,000 times).
So developers aren't going to be given the time and other resources required to write perfect code. There will always be a balance between time, money, and quality, and outside of hobbists and a few industries, that'll never change. Unless there's some requirement that it change.
I think it's very likely that in the near future, we'll have legal regulation regarding software that runs in certain environments; medical and transportation industry is very likely, but also public works like water or power management subsystems. On the other hand, there's really no reason to engage the entertainment or office productivity industry, and that includes cell phones and most personal computer apps.
What form this regulation will take, I can't tell you, but due to the very nature of the process, it can be very difficult to detect flaws. My guess is that it'll be more of a fine-upon-discovery mechanism. Again, not much different than how we work now, with the added difficulty of a legal fine on top of market loss.
Of course, were I in this situation, I would assign the rights of software bundles to do-nothing child corporations that act as defacto owners of the code, and then declare bankruptcy due to the cost of fixing the software AND paying fines. At the same time, child corporation 2.0 has a wholly compatible new app that will fix that issue...
but that's me - I'm a problem solver, and this is just a paperwork issue.