2021-11-18 22:05:49 +05:30
|
|
|
export const parseCodeclimateMetrics = (issues = [], blobPath = '') => {
|
2021-03-08 18:12:59 +05:30
|
|
|
return issues.map((issue) => {
|
2021-11-18 22:05:49 +05:30
|
|
|
// the `file_path` attribute from the artifact is returned as `file` by GraphQL
|
|
|
|
const issuePath = issue.file_path || issue.path;
|
2020-07-28 23:09:34 +05:30
|
|
|
const parsedIssue = {
|
|
|
|
name: issue.description,
|
2021-11-18 22:05:49 +05:30
|
|
|
path: issuePath,
|
|
|
|
urlPath: `${blobPath}/${issuePath}#L${issue.line}`,
|
2021-03-11 19:13:27 +05:30
|
|
|
...issue,
|
2020-07-28 23:09:34 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
if (issue?.location?.path) {
|
2021-11-18 22:05:49 +05:30
|
|
|
let parseCodeQualityUrl = `${blobPath}/${issue.location.path}`;
|
2020-07-28 23:09:34 +05:30
|
|
|
parsedIssue.path = issue.location.path;
|
|
|
|
|
|
|
|
if (issue?.location?.lines?.begin) {
|
|
|
|
parsedIssue.line = issue.location.lines.begin;
|
|
|
|
parseCodeQualityUrl += `#L${issue.location.lines.begin}`;
|
|
|
|
} else if (issue?.location?.positions?.begin?.line) {
|
|
|
|
parsedIssue.line = issue.location.positions.begin.line;
|
|
|
|
parseCodeQualityUrl += `#L${issue.location.positions.begin.line}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
parsedIssue.urlPath = parseCodeQualityUrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
return parsedIssue;
|
|
|
|
});
|
|
|
|
};
|