Deuteronomy 17:2

The Judicial Procedure for Idolatry

2 "If a man or woman among you in one of your towns that the Lord your God will give you is discovered doing evil in the sight of the Lord your God and violating His covenant

Deuteronomy 17:2 Meaning and Commentary

Deuteronomy 17:2

If there be found among you, within any of thy gates which the
Lord thy God giveth thee
In any of their cities in the land of Canaan:

man or woman that hath wrought wickedness in the sight of the Lord thy
God:
as all that is wrought is in the sight of the omniscient God; here it means not any kind of wickedness, for there is none lives without committing sin of one sort or another, all which is known to God the searcher of hearts, but such wickedness as is after described:

in transgressing his covenant;
that is, his law, and particularly the first table of it, which respects divine worship, and which is in the nature of a marriage contract or covenant; which, as that is transgressed by adultery committed by either party, so the covenant between God and Israel was transgressed by idolatry, which is spiritual adultery, and going a whoring after other gods, as it follows:

Deuteronomy 17:2 In-Context

1 "You must not sacrifice to the Lord your God an ox or sheep with a defect or any serious flaw, for that is detestable to the Lord your God.
2 "If a man or woman among you in one of your towns that the Lord your God will give you is discovered doing evil in the sight of the Lord your God and violating His covenant
3 and has gone to worship other gods by bowing down to the sun, moon, or all the stars in the sky-which I have forbidden-
4 and if you are told or hear [about it], you must investigate it thoroughly. If the report turns out to be true that this detestable thing has happened in Israel,
5 you must bring out to your gates that man or woman who has done this evil thing and stone them to death.
Holman Christian Standard Bible ® Copyright © 2003, 2002, 2000, 1999 by Holman Bible Publishers.  Used by permission.  All rights reserved.