"Defendants undertaking intensive residential drug and alcohol treatment programmes are in a vulnerable position and I have had direct experience of this," Judge McNaughton said.
"In March 2017 I was monitoring a defendant through a treatment programme at Odyssey House. He and his partner, posing as hospital staff and school visitors had stolen credit cards from medical staff and teachers over a period of months and used the stolen credit cards to spend in excess of $50,000 on clothing, jewellery, appliances and computers.
"The defendant's partner had been sentenced to imprisonment but his sentencing had been adjourned to enable him to undertake a long course of treatment at Odyssey House.
"Two days after sentencing was adjourned, a front-page article describing the defendant's offending appeared together with his photograph. There was no reference to the defendant undertaking treatment. The reason for adjourning the sentencing was not mentioned.
"As a direct result of publication of the article, and the photograph, he immediately left the programme. He was in breach of his bail and on the run from the police for some time.
"During that period he committed a serious armed robbery and other offences and was subsequently sentenced to a lengthy term of imprisonment.
"I am concerned that publication of the defendant's identity could have a similar impact in this case given the nature of the defendant's offending which the New Zealand Herald have highlighted more than once and no doubt will do so again if the application to suppress the defendant's identity is declined.
"I am satisfied that there is a real and appreciable risk that the defendant's treatment will be jeopardised if his name is published. I am satisfied that the loss of this opportunity to engage in treatment would amount to extreme hardship."
New Zealand Bar Association President, Clive Elliott QC, criticised the way the Herald on Sunday "broadened its attack on Judge McNaughton to include other cases where the paper has not agreed with the judge", saying it was "disturbing", "personal" and "vindictive".
"If the paper is going to appeal the decision it shouldn't be running its own public process through the newspaper to make its case," he said.
Elliott said a number of concerned lawyers had contacted him about the article.
"Our wish is to condemn the way in which the Herald has conducted itself by publishing the Herald on Sunday story and to reaffirm our confidence in the integrity of District Court judges who are at the coalface of incredibly difficult criminal cases.
"It is all too easy for people who are not confronted with those cases on a daily basis to attack or criticise these judges. Balanced, informed and fair criticism is one thing. Personal attacks and sweeping generalisations are not acceptable."
Herald on Sunday editor Stuart Dye and NZ Herald editor Murray Kirkness said the report was a fair, balanced and accurate report of the District Court judge's decision in open court proceedings.
They rejected allegations the report was vindictive.
"We respect the integrity of the court. Judges' decisions are subject to public scrutiny, and on this occasion the Herald believes reporting on the decision was warranted.
"We will be appealing the decision."