I drive a 2002 VW Golf TDI, which I bought new. For the life of the vehicle it has averaged 44.2 miles per gallon. When I first bought the car, my work commute was almost all highway mies so I got a consistent 50 MPG. After I moved and got a new job, my commute was almost entirely city driving and I got about 43 MPG except for long road trips. At some point my mileage dropped to 40 MPG for no apparent reason, probably coinciding with the check engine light going on. My mileage got worse and stayed at around 37 MPG for two years except for long road trips. Then I had a temperature sensor replaced, which made the check engine light turn off. Mileage went back to about 43 MPG average. I still get about 50 MPG on the highway.
How did I pass state inspection with a check engine light on? The check engine light didn't go on all the time, it would just turn on sometimes. I took the car to the shop, had them clear the codes, then drove it for the required time and hoped that the light didn't turn on during before I took took it back to the shop for an inspection. I got lucky.