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

Commit

Permalink
Fix regression in CheckstyleFormatter backwards compatibility (#4561)
Browse files Browse the repository at this point in the history
  • Loading branch information
adidahiya committed Mar 1, 2019
1 parent 1c400fb commit 25c50e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/formatters/checkstyleFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export class Formatter extends AbstractFormatter {
};
/* tslint:enable:object-literal-sort-keys */

public format(failures: RuleFailure[], _fixes: RuleFailure[], fileNames: string[]): string {
const groupedFailures: { [k: string]: RuleFailure[] } = {};
public format(failures: RuleFailure[], _fixes?: RuleFailure[], fileNames?: string[]): string {
const groupedFailures: { [fileName: string]: RuleFailure[] } = {};
for (const failure of failures) {
const fileName = failure.getFileName();
if (groupedFailures[fileName] !== undefined) {
Expand All @@ -49,6 +49,10 @@ export class Formatter extends AbstractFormatter {
}
}

if (fileNames === undefined) {
fileNames = Object.keys(groupedFailures);
}

const formattedFiles = fileNames.map(fileName => {
const formattedFailures =
groupedFailures[fileName] !== undefined
Expand Down
4 changes: 2 additions & 2 deletions src/language/formatter/abstractFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export abstract class AbstractFormatter implements IFormatter {
public static metadata: IFormatterMetadata;
public abstract format(
failures: RuleFailure[],
fixes: RuleFailure[],
fileNames: string[],
fixes?: RuleFailure[],
fileNames?: string[],
): string;

protected sortFailures(failures: RuleFailure[]): RuleFailure[] {
Expand Down

0 comments on commit 25c50e7

Please sign in to comment.