God examines the heart to determine its condition. It is the "Intention motivating the sin" he can examine.
King David committed adultery and murder yet god declared him righteous.
Annanias and his wife were killed on the spot by the hand of god for lying about the proceeds of a feild they had sold.
God did not call him righteous when he was unrepentant, but sent the prophet to him, and said prophet condemned him. Subsequently, God judged him. Then, after he had repented, he was restored unto fellowship with God. In fact, (1Ki 15:5) because David did what was right in the eyes of Jehovah, and did not turn aside from all that He commanded him all the days of his life, except in the matter of Uriah the Hittite."
In another passage it adds to this one, and includes the numbering of the children of Israel by David, for which God punished not only David, but killed many Israelites for David's sin. Does that fit into your understanding of a "loving" God? It doesn't for most!
Does not the scripture state that they lied to the Spirit? David didn't. Also, doesn't the NT scriptures state that we are to judge and discipline the errant believer before the other believers, so that the rest of the believers will fear and learn? That indeed was the result of the Ananias death stuff, as stated in the Word in that same account, isn't it?
David was His king whom He had blessed, for he was a foreshadowing of Christ's kingship, thus God was lenient. Others would consider killing Israelites for David's sin as harsh, but it wasn't. It also broke God's heart, that passage says. God killed a newborn baby because of David's sin regarding Uriah. That doesn't fit into people's picture of God either, does it? Interesting to note that God didn't judge Aaron when he sinned about the idol deal, or the murmurring against Moses event. And he sinned more than once, and egregiously too, but God only judged Miriam in the one such instance, and the common israelits in the other instance. Every wonder why? He was a type of Christ, a foreshadowing of Christ's spiritual priesthood. So to simply take a passage and come to exclusive understandings of it is not only spiritual problem prone, it is also against the express injunction of God's Word. For that one, and the scripture which states that truth in such incredibly clear words, read some of my other posts on other threads.