Question reads. . . A good friend who points out mistakes and imperfections and rebukes evil is to be respected as if he reveals a secret of hidden treasure.
A good friend that points out mistakes and evil can me a man of God that has been blessed with discernment, or in other words, to spiritually sense what is ungoldly. . . and the secret of hidden treasures is found in Proverbs 2:4-5 where the words say. . .
"If thou searchest her as silver, and searchest for her as hid treasures; Then shall thou understand the fear of the Lord, and find the knowledge of God."
Being I strive my best possible to be a man of God, that is my answer spiritually speaking.