The quote below is from Donald Carson’s commentary The Gospel according to John and references the following words of Jesus:
Matthew 7:1 “Judge not, that you be not judged.”
John 7:24 “Do not judge by appearances, but judge with right judgment.”
John 7:17 “If anyone’s will is to do God’s will, he will know whether the teaching is from God or whether I am speaking on my own authority.”
“In an age when Matthew 7:1 has displaced John 3:16 as the only verse in the Bible the man in the street is likely to know, it is perhaps worth adding that Matthew 7:1 forbids judgmentalism, not moral discernment. By contrast, John 7:24 demands moral and theological discernment in the context of obedient faith (7:17), while excoriating self-righteous legalism and offering no sanction for censorious heresy-hunting.” (page 317)
Wise words worth pondering.
Context is everything in interpretation.