Rapper DMX walked into a New York City courtroom of his own free will, and he walked out on house arrest -- and that was after the judge cut him a serious break.

TMZ reported that X "dodged a bullet" after he not only showed up to a court hearing 30 minutes late, but he also failed four drug tests for marijuana and cocaine.

Rick Davis / Splash News

DMX is currently out on bail from a tax evasion case and one of the conditions is that he has to stay clean of drugs. X also violated another term of the bail by leaving the state of New York without court permission. He reportedly flew to St. Louis recently for personal reasons.

Rather than sending him to jail, which the judge could have easily done, the judge made DMX wear an ankle monitor to make sure he doesn't stray again.

"The judge was pretty clear, telling X he couldn't even go out to mow his own lawn," TMZ reported.

Rick Davis / Splash News

On July 13, the "Rough Ryders Anthem" rapper was arrested and charged with 14 counts of tax evasion. On July 14, he pled not guilty to the charges and posted a $500,000 bail.

In the charging documents, the U.S. Attorney's Office said DMX had concealed his income for several years and owed the federal government about $2 million. The feds allege that X avoided bank accounts and used surrogates to hide his money. He also lived mostly on cash.

MediaPunch/REX/Shutterstock

Documents also show that in 2011 and 2012, he made nearly $900,000, but listed his income as "unknown." The following year he said he made $10,000, but authorities believe he actually made $250,000.

If he was to be convicted on all 14 counts, he could face up to 44 years in federal prison.