This is not a denial of justification by faith as I heard one liberal scholar say at a gathering, calling it a “Pharisee psalm.”
“The Lord dealt with me according to my righteousness;
according to the cleanness of my hands he rewarded me” (2 Samuel 22:21).
David says plainly, and often, “I have sinned” (2 Samuel 24:17).
This means it is possible to please the Lord, renouncing sin and walking uprightly.