In general, any time you have a commitment active on the "We Give" side of the box, that terminates because you declared war, that's a tarnished reputation. This includes all active trade deals, RoPs, alliances, MPPs, and Peace Treaties with time remaining. Note that if you are MPPed with Civ A, and Civ B attacks Civ A triggering the MPP, it's YOU declaring war on Civ B and you take the reputation hit.
Whether or not you broke a deal, attacking ANYTHING on the SAME TURN that you declare war is a dishonorable sneak attack. This is the bit that trips up most people. It doesn't matter if you declare before attacking - in a turn-based game, it doesn't matter when during the turn you declare.
The only honorable way to declare war is to declare it in diplomacy, and DO NOT ATTACK YET - the other civ must have the first move. Once a turn passes, THEN you can attack without it being considered a sneak attack or a black mark on your reputation.
If the OTHER civ is the one that makes the actual declaration of war, anything goes and you get no reputation hit.