<p>Let's say you work someplace where every change to source code must be associated with a bug-report or feature-request, and there is no way to get that policy reformed.  In such an environment, what is the best way to deal with code refactorings (that is, changes that improve the code but do not fix a bug or add a feature)?</p>

<ul>
<li>Write up a bug-report and associate the refactoring with it.</li>
<li>Write up a feature-request and associate the refactoring with it.</li>
<li>Sneak in the refactorings while working on code that is associated with a bug-report/feature-request.</li>
<li>Just don't do any refactoring.</li>
<li>Other</li>
</ul>

<p>Note that all bug reports and feature descriptions will be visible to managers and customers.</p>

[{'answer_id': 54276, 'author': 'Tim Frey', 'author_id': 1471, 'author_profile': 'https://Stackoverflow.com/users/1471', 'pm_score': 4, 'selected': True, 'text': '<p>I vote for the "sneak in refactorings" approach, which is, I believe, the way refactoring is meant to be done in the first place.  It\'s probably a bad idea to refactor just for the sake of "cleaning up the code."  This means that you\'re making changes for no real reason.  Refactoring is, by definition, modifying the without the intent of fixing bugs or adding features.  If you\'re following the KISS principle, any new feature is going to need at least some refactoring because you\'re not really thinking about how to make the most extensible system possible the first time around.</p>\n'}, {'answer_id': 54283, 'author': 'ColinYounger', 'author_id': 1223, 'author_profile': 'https://Stackoverflow.com/users/1223', 'pm_score': 2, 'selected': False, 'text': "<p>The way we work it is: There must be a good reason to refactor the code, otherwise why?</p>\n\n<p>If the reason is to allow another feature to use the same code, associate the changes with the other feature's request.</p>\n\n<p>If it's to make something faster, create a feature request for faster 'xyz' and associate the changes with that - then the customers see you're improving the product.</p>\n\n<p>If it's to design out a bug, log the bug.</p>\n\n<p>It's worth noting that in my environment, the policy cannot be enforced. But clever managers can get reports of changes and if they don't have a bug\\request reference in the commit text it's followed up.</p>\n"}, {'answer_id': 54291, 'author': 'GateKiller', 'author_id': 383, 'author_profile': 'https://Stackoverflow.com/users/383', 'pm_score': 0, 'selected': False, 'text': "<p>Lets have a look at each option:</p>\n\n<ul>\n<li>Write up a bug-report and associate the refactoring with it.</li>\n</ul>\n\n<p>If you feel that, in your opinion, the original code poses a security risk or potential for crashing or instability. Write a small bug report outlining the danger, and then fix it.</p>\n\n<ul>\n<li>Write up a feature-request and associate the refactoring with it.</li>\n</ul>\n\n<p>It might be harder to reactor code based on a feature request. But you could use valid feature request to do this which leads me onto the next point...</p>\n\n<ul>\n<li>Sneak in the refactorings while working on code that is associated with a bug-report/feature-request.</li>\n</ul>\n\n<p>If there is a valid bug or feature, state that function x had to be change slightly to fix the bug or add the feature.</p>\n\n<ul>\n<li>Just don't do any refactoring.</li>\n</ul>\n\n<p>This seems to suggest the self development through improving an application is not allowed. Developers should be allowed, if not, encourage to explorer new techniques and technologies.</p>\n\n<ul>\n<li>Other</li>\n</ul>\n\n<p>Perhaps you could discuss your improvement at relevant meeting, giving convincing reasons why the changes should be made. Then at least you will have management backing to the change without having to sneak in the code through another method.</p>\n"}, {'answer_id': 54325, 'author': 'Anthony Williams', 'author_id': 5597, 'author_profile': 'https://Stackoverflow.com/users/5597', 'pm_score': 2, 'selected': False, 'text': "<p>If you're working on a block of code, in most cases that's because there's either a bug fix or new feature that requires that block of code to change, and the refactoring is either prior to the change in order to make it easier, or after the change to tidy up the result. In either case, you can associate the refactoring with that bug fix or feature.</p>\n"}, {'answer_id': 54534, 'author': 'Bob Nadler', 'author_id': 2514, 'author_profile': 'https://Stackoverflow.com/users/2514', 'pm_score': 0, 'selected': False, 'text': '<ul>\n<li>Other</li>\n</ul>\n\n<p>If you work at a place with that kind of inflexible (and ridiculous) policy, the best solution is to find another job!</p>\n'}]
['https://Stackoverflow.com/questions/54264', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1175/']