Lately, judges have been pushing back. So far in 2015, state supreme courts in California, Massachusetts and New York have struck down residency laws.

The Massachusetts ruling, issued on Aug. 28, invalidated a residency restriction in the town of Lynn — and by extension, similar restrictions in about 40 other communities statewide — in part because it swept up so many offenders, regardless of the actual risk they posed. Acting against a whole class presents “grave societal and constitutional implications,” the justices wrote. That unanimous ruling was based on the State Constitution.

The California Supreme Court went further, holding that a San Diego residency restriction, which effectively barred paroled sex offenders from 97 percent of available housing, violated the United States Constitution.

Far from protecting children and communities, the California court found, blanket restrictions in fact create a greater safety risk by driving more sex offenders into homelessness, which makes them both harder to monitor and less likely to get essential rehabilitative services like medical treatment, psychotherapy and job assistance.

Residency laws often lead people to live apart from their families, obliterating what is for many the most stabilizing part of their lives.

If the state wants to block someone from living in certain areas, the California court said, it must make that decision on a case-by-case basis.