Jesus tells us not to judge sinfully but to render proper judgments. If a pastor speaks false doctrine he should be rebuked by everyone. If someone is openly sinning they also should be rebuked.
(John 7:24 NIV) Stop judging by mere appearances, and make a right judgment."
Paul said this,
(1 Corinthians 5:9-13 NIV) I have written you in my letter not to associate with sexually immoral people-- {10} not at all meaning the people of this world who are immoral, or the greedy and swindlers, or idolaters. In that case you would have to leave this world. {11} But now I am writing you that you must not associate with anyone who calls himself a brother but is sexually immoral or greedy, an idolater or a slanderer, a drunkard or a swindler. With such a man do not even eat. {12} What business is it of mine to judge those outside the church? Are you not to judge those inside? {13} God will judge those outside. "Expel the wicked man from among you."