diff --git a/src/formatters/vsoFormatter.ts b/src/formatters/vsoFormatter.ts index fd8d9b7e080..fcc8a01428a 100644 --- a/src/formatters/vsoFormatter.ts +++ b/src/formatters/vsoFormatter.ts @@ -34,10 +34,8 @@ export class Formatter extends AbstractFormatter { }; /* tslint:enable:object-literal-sort-keys */ - public format(failures: RuleFailure[], warnings: RuleFailure[] = []): string { - const all = failures.concat(warnings); - - const outputLines = all.map((failure: RuleFailure) => { + public format(failures: RuleFailure[]): string { + const outputLines = failures.map((failure: RuleFailure) => { const fileName = failure.getFileName(); const failureString = failure.getFailure(); const lineAndCharacter = failure.getStartPosition().getLineAndCharacter(); diff --git a/test/formatters/vsoFormatterTests.ts b/test/formatters/vsoFormatterTests.ts index db4b528fae6..6cb4c7d07f9 100644 --- a/test/formatters/vsoFormatterTests.ts +++ b/test/formatters/vsoFormatterTests.ts @@ -49,6 +49,26 @@ describe("VSO Formatter", () => { assert.equal(actualResult, expectedResult); }); + it("does not duplicate output for fixed failures", () => { + const maxPosition = sourceFile.getFullWidth(); + + const failures = [ + createFailure(sourceFile, 0, 1, "first failure", "first-name", undefined, "error"), + createFailure(sourceFile, 32, 36, "mid failure", "mid-name", undefined, "error"), + createFailure(sourceFile, maxPosition - 1, maxPosition, "last failure", "last-name", undefined, "error"), + ]; + + const expectedResult = + getFailureString(TEST_FILE, 1, 1, "first failure", "first-name") + + getFailureString(TEST_FILE, 2, 12, "mid failure", "mid-name") + + getFailureString(TEST_FILE, 9, 2, "last failure", "last-name"); + + const fixed = failures.slice(); + + const actualResult = formatter.format(failures, fixed); + assert.equal(actualResult, expectedResult); + }); + it("handles no failures", () => { const result = formatter.format([]); assert.equal(result, "\n");