Ibn Hazm said:
“Whoever is tested with self-admiration, let him think of his faults; if he admires his virtues, let him think of his bad manners and attitude. If he cannot find any, to the point that he thinks that he has no faults, then he should realise that his problem is chronic and that he is the most imperfect of men, and he has the most faults and least discernment. That is because he is feeble-minded and ignorant, and there is no fault worse than these two, because the wise man is the one who can see faults in himself and tries to overcome them, whereas the foolish man is the one who is ignorant of his own faults.
If you admire your opinions, then think of the number of times you got it wrong; remember them and do not forget them. Think of every time you expressed your opinions and it turned out to be wrong, and someone else got it right and you were mistaken.
If you admire your knowledge, then remember that it is not from yourself; rather it is a pure gift from Allaah (swt) that was given to you by your Lord, so do not respond to it in a way that angers Him, for He may cause you to forget it by means of a problem with which He may test you, which my result in you forgetting what you have learned and memorised.
If you are impressed by your brothers’ praise for you, the think of the criticism of your enemies; then your self-admiration will disperse. If you have no enemies, there is nothing good in you; there is no one whose status is lower than the one who has no enemy.
It is no more than the status of the one who has no blessing from Allaah (swt) for which he is to be envied, may Allaah keep us safe and sound. If you think little of your faults, then think of them if people found out about them. Imagine people finding out about them, then you will be embarrassed and will recognise your shortcomings.”
[Al-Akhlaaq Was-Siyar, p. 71]