The Gemara said that public desecration of Shabbat is as severe as avodah zarah. As the Rambam wrote, Shabbat is the sign between the Holy One, blessed be He, and us, and one who publicly desecrates Shabbat is like a non-Jew for all his laws. If he desecrates only in private, he is like a Jew.