Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Commit

Permalink
adding a pmd formatter for tslint
Browse files Browse the repository at this point in the history
  • Loading branch information
Build committed Apr 1, 2014
1 parent b4c4e86 commit 52ceab2
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/formatters/pmdFormatter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2013 Palantir Technologies, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/// <reference path='../../lib/tslint.d.ts' />

export class Formatter extends Lint.Formatters.AbstractFormatter {
public format(failures: Lint.RuleFailure[]): string {
var output = "<pmd version=\"tslint\">";
for (var i = 0; i < failures.length; ++i) {
var failure = failures[i];
var fileName = failure.getFileName();
var failureString = failure.getFailure();

var lineAndCharacter = failure.getStartPosition().getLineAndCharacter();
var line = lineAndCharacter.line() + 1;
var character = lineAndCharacter.character() + 1;

output += "<file name=\"" + fileName;
output += "\"><violation begincolumn=\"" + character;
output += "\" beginline=\"" + line;
output += "\" priority=\"1\"";
output += " rule=\"" + failureString + "\"> </violation></file>";
}
output += "</pmd>";
return output;
}
}

0 comments on commit 52ceab2

Please sign in to comment.