I heard a lot of time about unnecessary refactoring: "we don't need it right now" or "why did you change that, if it worked before also". Personally, for me, clean code and refactoring are the same part of the development process, as working on a new feature. As Robert C. Martin wrote in his book "Clean Code: A Handbook of Agile Software Craftsmanship":
If you see something that could be fixed/refactored now, do not leave these fixes for future or for someone else. Just do it!
I remember this phrase very well when I read his book and I try to take care of such thinking. Nevertheless, I determined for myself when refactoring is really unnecessary. Here is my listing:
Code already perfect (of course, it's utopia)
You are not enough experienced in technologies or in project structure to do that, so better do nothing
Ask someone more experienced as you could be an option, but you need to find this person first.
- Your employer requires you to do only what he/she says
This is a bad option for your further career as you become a monkey that is doing what is requested. Professionals always know how to do their job and understand which problems missing refactoring or fixes can be caused in future.
If you are very limited in time and have not enough time to test your changes, this could be also an option to avoid some refactoring.
- The project is completely bull-shit
If you see that you are working on legacy code and there is absolutely no chance to improve it, then do not waste your time and nerves. If it's possible, I suggest you switch to another project/company. If you do not have such an opportunity, I regret you very much.
That was my listing I made for myself, but you can have something more to say.