Imam citing to Hadiths and Islamic traditions further explains the matter as following:
Imam al-Sadiq (A) said that Amir al-mu’minin (A) said: ‘There are three distinguishing features of one accustomed to riya’: he expresses joy and cheerfulness when he is greeted by people; he becomes cheerless and sullen when alone; and he wishes to be praised for everything he does.’
Since this vice is so hidden and subtle that it remains unnoticed by the person himself, he is unaware of the fact that inwardly he is a hypocrite, and he imagines his actions to be pure and untainted. Therefore, the signs of this characteristic have been described so that men should be able to identify their hidden motives by examining their inner self in their light and be able to prevent and treat them accordingly.
An individual may introspect and know that he is not inclined to perform his religious duties when he is alone; even if with great compulsion he forces himself to perform them, or even if he performs them habitually, he does not perform with real sincerity and purity of heart, but rather as a physical exercise; but while performing his prayer in the mosque, in the congregation of the people and in the presence of others, he becomes animated, performing his prayer with utmost joy and enthusiasm. He is inclined to perform long and protracted ruku’s and prostrations; he performs the mustahabb actions properly, caring about their minutest particulars. If one pays a little attention to one’s inner state, one may come to know the reason for this vigor. Why is it so that he spreads the net of his (pretended) piety for catching the attention of people?
He may mislead himself by saying that he is more pleased with praying in the mosque, as it is more meritorious to do so, and that it brings more rewards also. He will convince himself by saying that it is preferable to say prayer in a better way in front of others, in order that they may follow his example and be attracted towards the religion. Man deceives himself by all means and never thinks of correcting himself. For a sick person who considers himself to be sound there is no hope of being cured. The ill-fated man’s innermost being not only secretly aims to parade his good deeds before people, remaining unconscious of its inner urge, but is also bent upon presenting his sin as worship and his conceit as propagation of religion, despite the fact that the performance of the mustahabbat prayers is mustahabb in seclusion.
Why is it that your self always responds in public, and why do you relish weeping out of the fear of God in the gathering of people, though in loneliness in spite of squeezing your eyes you cannot bring out a single tear? Where is the fear of God? Does it grip you in the gatherings of people only? Does it overwhelm you only on the occasion of the Nights of Great Value (ليلة القدر) in front of several thousands of people? Such a man offers one hundred rak’ah’s of namaz and recites the Du’a-i Jawshan-i Kabir and Du’a-i Jawshan-i Saghir in addition to several surahs of the Quran and is not bored and does not feel the slightest weariness. If man performs something purely for the sake of God or for gaining His blessings, or out of fear of hell or in the hope of heaven, why should he desire that his deeds be praised by men and admired by them?
His ears are all the time eager to listen something in his praise, and his heart is after those who observe his devotion and notice how venerable this gentleman is, for he is so punctual about the prayer and is so concerned about the supererogatory duties. If your deeds are meant for God, what does this exaggerated craving mean? If the fear of hell and the hope of heaven force you to perform these deeds, what does this love of publicity mean? You ought to realize that this desire issues from the accursed and abominable tree of riya’. Therefore, try as much as you can to purify yourself of these absurd inclinations (to the extent possible), and try to reform yourself.