I'll say this: if you aren't writing code in a way that someone else can pick up the project when you leave, then you are being an irresponsible coder.
Code that belongs to the company is ultimately the responsibility of the stockholders and their board. As an at will employee with no equity, I will give them exactly what they ask for in their code.
At each job, I will go above and beyond the call of duty once, to gauge the reaction. At some jobs, I get a cash bonus. At others, I just get a pat on the back. The last two jobs in a row, I was told to not do that again. So I didn't.
Don't be an apologist for bad management. I'm not going to do the right thing if I could get fired for it.