From the perfection of the guidance of the Messenger (صلى الله عليه وسلم) in preserving the truth and maintaining the unity and strength of Ahl al-Sunnah, the followers of the Salaf, is the principle of judging a man by his companionship.
While there are many benefits and wisdoms in this which can be discussed, suffice it to say that this methodology and its application is a mercy upon people in that it provides them a very easy mechanism, or criterion by which to know the reality of people, without having to embroil themselves with such people in disputations and debates about what these people may believe or hold, and especially when they may not have the knowledge to see through their doubts, misconceptions and falsehoods. Thus, it is an easy rule of thumb that can be applied.
All one needs to do is to look at their friendships, allegiances, who they travel to or visit and who travels to and visits them, by which their reality is known. This is especially so in relation to callers, who give lectures and sit on platforms.
The explanation behind this is that the inward states of the heart are bound, by necessity to the outward statements and actions, and what a man holds in his heart, what he believes, what he feels, and what he conceals, all of that must by necessity be expressed outwardly, and while a person may be able to take measures to conceal much of that in his speech and conduct, one of the things that cannot be easily hidden is companionship, and one’s travels and visitations. Likewise, slips of the tongue and facial expressions, they can also reveal a person's realities.
It is related that ʿUthmān (رضي الله عنه) said:
No one concealed something [in his heart] except that Allāh (عز وجل) makes it appear [outwardly] through the expressions of his face and the slips of his tongue.
Today, we can see this from people who write on social media, inadvertently revealing their realities through what they say and post.
Thus, people’s realities, their allegiances and alliances can be deduced from their activities and interactions, which reveal something of what they hold in their hearts, in terms of love, hate, loyalty and disloyalty, and likewise, some elements of their belief.
This is from the greatest of what is detested by the people of innovations and misguidance, as it uncovers their realities and lays them bare. It is why during the 20th century, many attempts were made to demolish this—judging a person by his companionship— and many other important foundations of the Sunnah by groups such as the Muslim Brotherhood and their various offshoots, many of the later ones claiming ascription to Salafiyyah.
01 Abū Hurayrah (رضي الله عنه) said, the Messenger of Allāh (صلى الله عليه وسلم) said: 
المرء على دين خليله فلينظر أحدكم من يخالل
A person is upon the deen of his friend, so let each one of you look at whom he befriends.
02 Abd Allāh bin Masʿūd (رضي الله عنه) said:
Indeed a person walks alongside and accompanies the one whom he loves and who is like him.
03 Abd Allāh bin Masʿūd (رضي الله عنه) said:
Make consideration of the (regions of the) Earth by the names given to them and make consideration of a person by his companion.
04 Abū al-Dardā (رضي الله عنه) said:
It is from the fiqh (understanding of a person) that he [chooses] those whom he walks with, whom he enters upon (visits) and whom he sits with.
05 Ibn Baṭṭāh (رحمه الله) relates from Abū Qilābah that he said:
May Allāh fight the poet who said:
عَنِ المَرءِ لا تَسأَل وَسَل عَن قَرينَهُ *** فَكُلُّ قَرينٍ بِالمُقارِنِ يَقتَدي
Do not ask about a man, but ask about his companion. For every person guides himself by his companion.
After which Ibn Baṭṭāh said:
This poetry is by ʿAdī bin Zayd, and al-Aṣmaʾī said about it, “I have never seen a line of poetry which resembles the Sunnah more than this saying of ʿAdī bin Zaid.”
06 Yaḥyā bin Kathīr (رحمه الله) said:
Sulaymān bin Dāwūd (عليه السلام) said: “Do not pass a judgement over anyone with anything until you see whom he befriends.”
07 Mūsā bin ʿUqbah the Syrian had approached Baghdad and this was mentioned to Imām Aḥmad (رحمه الله) who said:
Look at whose residence he goes to and with whom he resides and finds shelter.
08 Muḥammad bin ʿUbayd al-Ghallābī (رحمه الله) said:
The Ahl al-Ahwā (People of Desires) hide everything except their intimate friendship and companionship.
09 Mu’āḍh bin Mu’āḍh (رحمه الله) said to Yaḥyā bin Saʿīd:
O Abā Saʿīd! A person may hide his viewpoint from us, but he will not be able to hide that in his son, or his friend or in the one whom he sits with.
10 Ibn ʿAwn (رحمه الله) said:
Those who sit with the People of Innovation are more severe upon us than the People of Innovation themselves.
11 Imām al-Awzāʿī (رحمه الله) said:
Whoever hides his innovation from us will not be able to hide his companionship from us.
12 Al-Aʿmash (رحمه الله) said:
They (the Salaf) did not used to ask anything more about a person after having asked about three affairs: Who he walks with, who he enters upon (i.e. visits) and who he associates with amongst the people.
13 Yaḥyā bin Saʿīd al-Qaṭṭān said:
When Sufyān al-Thawrī came to Baṣrah he began to look into the affair of al-Rabīʿ bin Subayh and the people’s estimation of him. He asked them, “What is his madhhab?”, and they said, “His madhhab is but the Sunnah.” He then asked, “Who is his companionship?” and they replied, “The people of Qadr”, so he replied, “In that case he is a Qadari.”
Ibn Baṭṭah (after quoting this) commented:
Allāh’s mercy be upon Sufyān al-Thawrī. He has indeed spoken with wisdom and he spoke the truth. He spoke with knowledge that is in agreement with the Book and the Sunnah and what is necessitated by wisdom and what the people of sure insight know. Allāh the Exalted said: “O you who believe! Take not as (your) bitânah (intimate friendship) those other than you (outside your religion or upon other than the right way) since they will not fail to do their best to corrupt you. They desire to harm you severely.” (3:118)
14 Abū Dawūd al-Sijistānee (رحمه الله) said:
I said to Abū Abd Allāh Aḥmad bin Ḥanbal: I see a man from Ahl al-Sunnah with a man from Ahl al-Bidʿah. Shall I leave his speaking to him? He said, “No, inform him that the man that you saw him with is a person of innovation, so if he leaves him, then speak to him, otherwise treat him the same as him, as Ibn Masʿūd said, ‘A man is like his companion’.”