While developing (either features or bug fixes) I sometimes happen to discover bugs that are not directly related to what I'm working on.  What should I do in that situation.  Just fix it?  Try to remember to fix it later?  Write it down somewhere?  Or enter it into the bug tracking system?

I generally enter it into the bug tracking system and let the process play itself out (i.e. triaging, assigning, etc.).  However I have hardly ever seen another developer enter a bug.  (Why is that?)

If you discover a bug, I can't think of any good reason not to enter it into the bug tracking system, whether you fix it or not.  That's what the bug tracking system is for, after all.

In some cases it might make more sense to report it to a QA person who has more experience dealing with the system, but in any case the bug should be tracked.

It's possible that there might be some reason, valid or not, that developers shouldn't be entering bugs.  One possible reason might be that the bug tracking system is visible to outsiders, and having too many reported bugs looks bad.  That's a very bad reason, which should be addressed in some other way that still allows bugs to be tracked.  Ask your boss.

(Of course if there's a bug in code that you're still working on, and it doesn't show up in anything that's been released, there's no need to track it in the system, though a TODO comment in the source code may be a good idea.  To take an extreme case, "This code won't compile because I haven't yet typed the semicolon at the end of this line" is not a reportable bug.)

As for why other developers don't enter bugs, you'll need to ask them.  They probably should.
