Skip to content

Commit

Permalink
[#203] Use proper latest version of parse
Browse files Browse the repository at this point in the history
Misc cleanup of definitions and coverage parser system
  • Loading branch information
ryanluker committed Mar 30, 2019
1 parent a4877dd commit a797e57
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 31 deletions.
6 changes: 5 additions & 1 deletion @types/cobertura-parse/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
declare namespace parse {
function parseContent(str: string, cb: (err: Error, data: Array<Section>) => void, absPath: string): void
function parseContent(
str: string,
cb: (err: Error, data: Array<Section>) => void,
absPath: boolean
): void

interface LineDetail {
hit: number,
Expand Down
5 changes: 4 additions & 1 deletion @types/jacoco-parse/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
declare namespace parse {
function parseContent(str: string, cb: (err: Error, data: Array<Section>) => void): void
function parseContent(
str: string,
cb: (err: Error, data: Array<Section>) => void
): void

interface LineDetail {
hit: number,
Expand Down
7 changes: 3 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
},
"dependencies": {
"@cvrg-report/clover-json": "0.3.0",
"cobertura-parse": "1.0.5",
"cobertura-parse": "github:vokal/cobertura-parse#53109a6",
"glob": "7.1.2",
"jacoco-parse": "2.0.1",
"lcov-parse": "1.0.0",
Expand Down
1 change: 0 additions & 1 deletion src/coverage-system/coverageservice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export class CoverageService {
this.sectionFinder,
);
this.coverageParser = new CoverageParser(
configStore,
this.outputChannel,
this.eventReporter,
);
Expand Down
29 changes: 6 additions & 23 deletions src/files/coverageparser.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
import {parseContent as parseContentClover} from "@cvrg-report/clover-json";
import {parseContent as parseContentCobertura} from "cobertura-parse";
import * as glob from "glob";
import {parseContent as parseContentJacoco} from "jacoco-parse";
import {Section, source} from "lcov-parse";
import {OutputChannel, workspace} from "vscode";
import {OutputChannel} from "vscode";

import {Config} from "../extension/config";
import {Reporter} from "../extension/reporter";
import {CoverageFile, CoverageType} from "./coveragefile";

export class CoverageParser {
private configStore: Config;
private outputChannel: OutputChannel;
private eventReporter: Reporter;

constructor(
configStore: Config,
outputChannel: OutputChannel,
eventReporter: Reporter,
) {
this.configStore = configStore;
this.outputChannel = outputChannel;
this.eventReporter = eventReporter;
}
Expand Down Expand Up @@ -68,7 +64,6 @@ export class CoverageParser {

private async convertSectionsToMap(
data: Section[],
fileType: CoverageType,
): Promise<Map<string, Section>> {
const sections = new Map<string, Section>();
const addToSectionsMap = async (section) => {
Expand All @@ -94,13 +89,10 @@ export class CoverageParser {
try {
parseContentCobertura(xmlFile, async (err, data) => {
checkError(err);
const sections = await this.convertSectionsToMap(
data,
CoverageType.COBERTURA,
);
const sections = await this.convertSectionsToMap(data);
this.eventReporter.sendEvent("system", "xmlExtractCobrtura-success");
return resolve(sections);
});
}, true);
} catch (error) {
checkError(error);
}
Expand All @@ -120,10 +112,7 @@ export class CoverageParser {
try {
parseContentJacoco(xmlFile, async (err, data) => {
checkError(err);
const sections = await this.convertSectionsToMap(
data,
CoverageType.JACOCO,
);
const sections = await this.convertSectionsToMap(data);
this.eventReporter.sendEvent("system", "xmlExtractJacoco-success");
return resolve(sections);
});
Expand All @@ -136,10 +125,7 @@ export class CoverageParser {
private async xmlExtractClover(filename: string, xmlFile: string) {
try {
const data = await parseContentClover(xmlFile);
const sections = await this.convertSectionsToMap(
data,
CoverageType.CLOVER,
);
const sections = await this.convertSectionsToMap(data);
this.eventReporter.sendEvent("system", "xmlExtractClover-success");
return sections;
} catch (error) {
Expand All @@ -162,10 +148,7 @@ export class CoverageParser {
try {
source(lcovFile, async (err, data) => {
checkError(err);
const sections = await this.convertSectionsToMap(
data,
CoverageType.LCOV,
);
const sections = await this.convertSectionsToMap(data);
this.eventReporter.sendEvent("system", "lcovExtract-success");
return resolve(sections);
});
Expand Down

0 comments on commit a797e57

Please sign in to comment.