There has been some talk recently about how crap the state of Sourceforge is. Sourceforge was really the first popular open source project hosting site, and I did have at least one project hosted there maybe a decade or more ago. It's user interface was always rather jumbled, but it was functional, and it's also something of an achievement for Sourceforge to have stuck around for as long as it has in an industry where ephemerality is the norm.
The allegation is that once the money ran out Sourceforge resorted to silly ads, bundled crapware on downloads and "installers" and even hijacking defunct projects to peddle yet more spam. Their reputation as a hosting site is now in tatters, although such is the nature of search engines that I expect average users will continue to discover downloads on that site.
The thing is that I think the sorry state of Sourceforge is the future of other commercial open source hosting sites, such as Github. If they can't make enough money from private repos then they will inevitably resort to other less savoury methods, like advertising and crapware. Also just the concept of "making enough money" seems alien for certain types of businesses who become fixated upon "growth" and value exfiltration by share holders.
Once a site reaches a Sourceforge-like condition everyone becomes a loser except for the site owner. Naive users continue to download from the site and suffer the consequences, and software projects also lose reputation in an environment in which reputation is really everything.
So I think the long term solution is for developers to host their own projects on their own sites, using web systems such as Gitlab, Gogs and other similar things. Ideally these would be federated in such a manner that a global directory was possible, so that visitors could still browse around for interesting pieces of code under favourable licenses. The only other alternative I can think of would be for open source software project hosting to be run as a non-profit organisation or charity, so that there isn't the need to generate additional income beyond just covering the running costs. Wikipedia provides an existing example of that sort of organisation.