In any decent society, majority of citizens, when noticing a piece of trash on their way, would pick it up and throw it in a garbage can. They do it because it is the right thing to do, and does not take that much extra effort.
Don’t take this too literally (yeah, depends on what kind of trash it is, it’s size, stinkiness, consistency, etc.), but the idea is that people go about their business towards some goal or task, and then they notice something that is not right, that is totally unrelated and not really in their way, but they just fix it anyway.
Software development is social. A team working together is kind of a small society with it’s own common beliefs and principles, practices and rituals. Wouldn’t the same “being a good citizen” principles of the human society apply to developing software and be beneficial to the team?
Robert C. Martin describes “the boy scout rule” and advocates to “Always check a module in cleaner than when you checked it out.”, as well as not “littering” in the first place. As he points out, it’s just “common decency”, and I think of it as “being a good citizen”. It should be applicable to everything we do in the society/team.
Working in a team, I frequently encourage the “picking up the trash” behavior that goes beyond the coding aspect. For example, one recent real life example of “trash” manifestation we’ve run into was when some testing of a functional change was not done, because “extra setup” was required that apparently would take days to achieve. Team decided to look for reasons and justifications of why that particular test was not necessary. Even if there was a perfectly reasonable justification of not performing more comprehensive test in this specific case, the “picking up the trash” behavior would be for the team to at least investigate why this resource intensive setup was needed to test the part of our product and to communicate to the team that we have a gap in our test environment setup. Maybe I am too picky, but seems like a reasonable expectation to me.