From 504ca25a446cf67453acc2fcc63d1c5121c7fcf8 Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Thu, 19 Oct 2017 19:48:53 +0200 Subject: [PATCH 1/2] vsoFormatter: don't duplicate output for fixed failures [bugfix] `vso` formatter no longer duplicates output for fixed failures --- src/formatters/vsoFormatter.ts | 6 ++---- test/formatters/vsoFormatterTests.ts | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) 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..2fed2fe1d44 100644 --- a/test/formatters/vsoFormatterTests.ts +++ b/test/formatters/vsoFormatterTests.ts @@ -45,7 +45,7 @@ describe("VSO Formatter", () => { getFailureString(TEST_FILE, 2, 12, "mid failure", "mid-name") + getFailureString(TEST_FILE, 9, 2, "last failure", "last-name"); - const actualResult = formatter.format(failures); + const actualResult = formatter.format(failures, failures); assert.equal(actualResult, expectedResult); }); From 1f52341a862af0f5d4c6dd76c843d568e8c6fef8 Mon Sep 17 00:00:00 2001 From: Klaus Meinhardt Date: Fri, 20 Oct 2017 09:27:34 +0200 Subject: [PATCH 2/2] add separate test --- test/formatters/vsoFormatterTests.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/test/formatters/vsoFormatterTests.ts b/test/formatters/vsoFormatterTests.ts index 2fed2fe1d44..6cb4c7d07f9 100644 --- a/test/formatters/vsoFormatterTests.ts +++ b/test/formatters/vsoFormatterTests.ts @@ -45,7 +45,27 @@ describe("VSO Formatter", () => { getFailureString(TEST_FILE, 2, 12, "mid failure", "mid-name") + getFailureString(TEST_FILE, 9, 2, "last failure", "last-name"); - const actualResult = formatter.format(failures, failures); + const actualResult = formatter.format(failures); + 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); });