I've been lucky in my developer career path that I've always wrote my code from scratch.
I have also been unlucky for the same reason because the first big thing I wrote was kind of like what you described. Zero testing, 1000 line long functions, etc.
Nowadays I can barely write any code without writing a test for it beforehand. I can't make myself write a function longer than 20 lines.