A whistleblowing cop says his Bronx precinct is ruled by an elaborate, color-coded quota system tracking the number of arrests, summonses and “stop-and-frisks” logged by each officer.

In a civil-rights suit filed yesterday, veteran cop Craig Matthews says the quota system in the 42nd Precinct “has pitted police officers against each other, straining professional relationships and diverting resources away from law-enforcement activities.”

He says cops who “comply” with the program “have had their precinct lockers dislodged and overturned, with the lockers sometimes being placed in the shower or their locks being plastered shut.”

“This practice of ‘locker flipping’ has escalated to the point where on-duty police officers are now assigned to guard the precinct’s locker room around the clock,” court papers say.

Matthews, a 14-year veteran, made the stunning revelation in a Manhattan federal court filing that charges he’s “been subjected to a campaign of retaliation and harassment” for telling top brass in the precinct about the “highly developed quota system” employed by “mid-level supervisors” there.

The suit — which targets the city, Police Commissioner Ray Kelly, precinct commander Deputy Inspector Jon Bloch and Lt. Mark Sedran — seeks a court order that they “cease all actions in retaliation for [Matthews’] protected speech,” plus unspecified damages.

The suit was filed the same day Matthews went down to defeat in an election in which he was seeking a second four-year term as the precinct’s union delegate. It also came on a day when he received a poor performance review — scoring just 2.5 out of a possible five points. His suit claims such low scores are retaliation for his complaints to precinct brass.

Matthews declined to comment outside the 42nd Precinct station house yesterday.

His suit says supervisors use color-coded computer reports to track each officer’s numbers, including those for highly controversial “stop-and-frisks” — which one supervisor allegedly described as “worth their weight in gold.”

”Current reports use black ink to identify officers who are meeting quotas, silver ink to identify officers who are meeting only some quotas and red ink to identify officers who are not meeting quotas,” according to court papers.

Matthews says cops “are constantly pressured to meet the quotas, and those who do not are subject to punishment including undesirable assignments, the loss of overtime, denial of leave, separation from partners and poor evaluations.”

NYPD spokesman Paul Browne disputed that the color codes were used to enforce quotas.

“The color codes do not specify quotas, but indicate enforcement activity ,” Browne said. “These are reasonable indicators of police officer activity.”

The city Law Department declined to comment.

Additional reporting by Jamie Schram, Ikimulisa Livingston and Daniel Prendergast