Finally, a judge has injected some sanity into the debate over egregious pension spiking in Merced, Alameda and, most significantly, Contra Costa counties.

Judge David Flinn on Friday concluded that the long-standing practice of counting unused leave time in retirement pay calculations violates state law and past court rulings. His determination lays the groundwork for the next key decision: What to do about the abuse?

So far, Flinn has gotten it right. The notion that employees can save up unused vacation time for years, cash it out at termination and count it as final-year income for pension calculations is absurd.

In Contra Costa, for example, the counting of banked vacation time spikes pensions as much as 15 percent of an employee's salary. It's the worst of a series of abusive practices retiring workers have been allowed to use to boost their incomes for the rest of their lives.

As Flinn concluded, such manipulation distorts the system, can lead to starting pensions greater than workers' final salaries and was never the intent of the state Legislature, which wrote the pension laws.

The practice has been going on for more than a decade. In Contra Costa, separate attorneys, in 1997 and 2009, warned the pension board that the spiking violated the law and court rulings. The board, then dominated by labor-friendly members, twice ignored that advice.

The issue resurfaced in 2012, when the Legislature and Gov. Jerry Brown reached agreement on changes to state pension laws. As the lawmakers tried to jam through the bill, this paper exposed a loophole that would have legitimized the pension-spiking abuses.

In response, at the last moment, separate legislation was passed to instead end the practices, to require compliance with past state law and court decisions. The action affects 20 county-level pension systems across the state, but Contra Costa's practices are the worst.

Labor unions sued to block implementation of the new law. Flinn, a Contra Costa judge, is hearing a consolidation of similar cases from Merced, Alameda and his own county. Having determined that the pension spiking has for years violated the law, he must now decide what to do about the ill-gotten gains.

The unions have argued that even if the practice were improper, workers have relied on pension board assurances that it was legitimate. But that ignores the plight of the taxpayers, who fund almost the entire cost of this illegal abuse.

We urge Judge Flinn to keep that in mind as he moves to the next stage.