Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

Commit

Permalink
Merge pull request #45 from codacy/FixJSCoverageReporting
Browse files Browse the repository at this point in the history
Fix js coverage reporting
  • Loading branch information
rtfpessoa committed Sep 7, 2017
2 parents 0ee0002 + ab4d849 commit 41a5e42
Show file tree
Hide file tree
Showing 13 changed files with 4,916 additions and 31 deletions.
15 changes: 0 additions & 15 deletions .buddyrc

This file was deleted.

4 changes: 2 additions & 2 deletions lib/impl/lcov.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@

//TODO: Convert to reduce function
stats.lines.details.forEach(function (detail) {
// If a line is not sent to the service then it is considered to be 0, so no need to be redundant in the payload.
// Codacy needs the 0s to know failed coverage data
// We also can't have a negative number of hits on a line, so exclude those.
if (detail.hit >= 1) {
if (detail.hit >= 0) {
fileStats.coverage[detail.line] = detail.hit;
}
});
Expand Down
5 changes: 3 additions & 2 deletions lib/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
fileReports: Joi.array().required().items(Joi.object({
filename: Joi.string().required().min(1),
total: Joi.number().integer().required().min(0).max(100),
coverage: Joi.object().pattern(/\d/, Joi.number().integer().min(1))
coverage: Joi.object().pattern(/\d/, Joi.number().integer().min(0))
}).required())
}).example({total: 50, fileReports: [{filename: 'filename', total: 10, coverage: {1: 1, 2: 3}}]});

Expand All @@ -21,14 +21,15 @@
ts: 'typescript',
tsx: 'typescript',
coffee: 'coffeescript'
}
};

function sendByLanguage(endpoint, commitId, token, data) {
var reportsByLanguage = lodash.groupBy(data.fileReports, function(elem) {
return languageMap[lodash.head(lodash.takeRight(elem.filename.split('.'), 1))] || 'javascript';
});

var languageResponses = lodash.map(reportsByLanguage, function(fileReports, language) {

var weighedCoverage = lodash.reduce(fileReports, function(accom, elem) {
return accom + (elem.total * Object.keys(elem.coverage).length);
}, 0);
Expand Down

0 comments on commit 41a5e42

Please sign in to comment.