Skip to content

Commit

Permalink
update actions
Browse files Browse the repository at this point in the history
  • Loading branch information
MeilCli authored May 10, 2021
1 parent cdf8bb7 commit beb1660
Show file tree
Hide file tree
Showing 3 changed files with 1,298 additions and 4 deletions.
146 changes: 142 additions & 4 deletions dist/transformer-junit.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,18 @@ var JunitTransformer = /** @class */ (function (_super) {
attrValueProcessor: function (value, _) { return he.decode(value); },
});
var junitTestSuites = [];
for (var _i = 0, _a = junitResult.testsuites; _i < _a.length; _i++) {
var testSuites = _a[_i];
junitTestSuites.push.apply(junitTestSuites, this.parseTestSuites(testSuites.testsuite));
if (junitResult.testsuites != undefined) {
for (var _i = 0, _a = junitResult.testsuites; _i < _a.length; _i++) {
var testSuites = _a[_i];
junitTestSuites.push.apply(junitTestSuites, this.parseTestSuites(testSuites.testsuite));
}
}
else {
// for cpplint
var testSuites = junitResult;
if (testSuites.testsuite != undefined) {
junitTestSuites.push.apply(junitTestSuites, this.parseTestSuites(testSuites.testsuite));
}
}
return convert_1.convertJunitToLintResult(junitTestSuites);
};
Expand Down Expand Up @@ -140,6 +149,9 @@ var JunitTransformer = /** @class */ (function (_super) {
if (testMessages == undefined) {
return [];
}
if (typeof testMessages == "string") {
return [{ message: testMessages, body: testMessages }];
}
var result = [];
for (var _i = 0, testMessages_1 = testMessages; _i < testMessages_1.length; _i++) {
var testMessage = testMessages_1[_i];
Expand Down Expand Up @@ -190,7 +202,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.convertJunitToLintResult = void 0;
var junit_handler_default_1 = __webpack_require__(2019);
var junit_handler_eslint_1 = __webpack_require__(4788);
var handlers = [new junit_handler_eslint_1.EslintJunitHandler(), new junit_handler_default_1.DefaultJunitHandler()];
var junit_handler_cpplint_1 = __webpack_require__(9850);
var handlers = [new junit_handler_eslint_1.EslintJunitHandler(), new junit_handler_cpplint_1.CpplintJunitHandler(), new junit_handler_default_1.DefaultJunitHandler()];
function convertJunitToLintResult(testSuites) {
for (var _i = 0, handlers_1 = handlers; _i < handlers_1.length; _i++) {
var handler = handlers_1[_i];
Expand All @@ -203,6 +216,131 @@ function convertJunitToLintResult(testSuites) {
exports.convertJunitToLintResult = convertJunitToLintResult;


/***/ }),

/***/ 9850:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {


var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.CpplintJunitHandler = void 0;
var he = __importStar(__webpack_require__(6492));
var CpplintJunitHandler = /** @class */ (function () {
function CpplintJunitHandler() {
}
CpplintJunitHandler.prototype.match = function (testSuites) {
if (testSuites.length == 0) {
return false;
}
return testSuites[0].name == "cpplint";
};
CpplintJunitHandler.prototype.handle = function (testSuites) {
var result = [];
this.handleTestSuites(result, testSuites);
return result;
};
CpplintJunitHandler.prototype.handleTestSuites = function (result, testSuites) {
for (var _i = 0, testSuites_1 = testSuites; _i < testSuites_1.length; _i++) {
var testSuite = testSuites_1[_i];
this.handleTestSuite(result, testSuite);
}
};
CpplintJunitHandler.prototype.handleTestSuite = function (result, testSuite) {
this.handleTestCases(result, testSuite.testCases);
this.handleTestSuites(result, testSuite.testSuites);
};
CpplintJunitHandler.prototype.handleTestCases = function (result, testCases) {
for (var _i = 0, testCases_1 = testCases; _i < testCases_1.length; _i++) {
var testCase = testCases_1[_i];
this.handleTestCase(result, testCase);
}
};
CpplintJunitHandler.prototype.handleTestCase = function (result, testCase) {
for (var _i = 0, _a = testCase.failures; _i < _a.length; _i++) {
var failure = _a[_i];
for (var _b = 0, _c = this.parseBody(failure.body); _b < _c.length; _b++) {
var message = _c[_b];
result.push({
path: testCase.name,
message: message[1],
level: message[3] == 5 ? "failure" : 3 <= message[3] ? "warning" : "notice",
rule: message[2],
startLine: message[0],
startColumn: undefined,
endLine: undefined,
endColumn: undefined,
});
}
}
for (var _d = 0, _e = testCase.errors; _d < _e.length; _d++) {
var error = _e[_d];
for (var _f = 0, _g = this.parseBody(error.body); _f < _g.length; _f++) {
var message = _g[_f];
result.push({
path: testCase.name,
message: message[1],
level: message[3] == 5 ? "failure" : 3 <= message[3] ? "warning" : "notice",
rule: message[2],
startLine: message[0],
startColumn: undefined,
endLine: undefined,
endColumn: undefined,
});
}
}
};
CpplintJunitHandler.prototype.parseBody = function (body) {
var result = [];
for (var _i = 0, _a = body.split(/(\r\n)|\n|\r/g); _i < _a.length; _i++) {
var line = _a[_i];
if (line == undefined || line.length == 0) {
continue;
}
var rawStartLine = line.replace(/^(\d+):\s(.+)\s\[(.+?)\]\s\[(\d)\]$/, "$1");
var rawMessage = line.replace(/^(\d+):\s(.+)\s\[(.+?)\]\s\[(\d)\]$/, "$2");
var rawRule = line.replace(/^(\d+):\s(.+)\s\[(.+?)\]\s\[(\d)\]$/, "$3");
var rawConfidence = line.replace(/^(\d+):\s(.+)\s\[(.+?)\]\s\[(\d)\]$/, "$4");
if (rawStartLine.length == 0 ||
rawMessage.length == 0 ||
rawRule.length == 0 ||
rawConfidence.length == 0) {
continue;
}
var startLine = parseInt(rawStartLine);
var message = he.decode(rawMessage);
var rule = he.decode(rawRule);
var confidence = parseInt(rawConfidence);
if (Number.isInteger(startLine) == false || Number.isInteger(confidence) == false) {
continue;
}
result.push([startLine == 0 ? 1 : startLine, message, rule, confidence]);
}
return result;
};
return CpplintJunitHandler;
}());
exports.CpplintJunitHandler = CpplintJunitHandler;


/***/ }),

/***/ 2019:
Expand Down
Loading

0 comments on commit beb1660

Please sign in to comment.