"Go, say to Jeroboam, 'Thus says the Lord God of Israel, "Because I exalted you from among the people and made you leader over My people Israel, and tore the kingdom away from the house of David and gave it to you - yet you have not been like My servant David, who kept My commandments and who followed Me with all his heart, to do only that which was right in My sight..." (1 Kings 14:7-8)
How can the prophet say of David that he kept the commandments of God and followed Him with all his heart in light of some of the serious sins that David committed? Adultery, conspiracy, and murder come to mind over the Bathsheba incident. David was a bad father. The census towards the end of his reign displayed a lack of faith on his part. Could it be that David's tender heart - his willingness to repent when confronted about his sin - displayed his general obedience to God? David's willingness to repent is displayed as a result of Nathan's rebuke in 2 Samuel 12.
In New Covenant parlance we would say that we are clothed with Christ's righteousness, therefore we are pleasing to God. Should this effect how we try to understand David doing "only that which was right in My sight" in 1 Kings 14?