Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed [Codacy] coverage examples and improved unknown coverage handling #2102

Merged
merged 4 commits into from
Sep 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/all-badge-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,12 @@ const allBadgeExamples = [
},
{
title: 'Codacy coverage',
previewUrl: '/codacy/coverage/c44df2d9c89a4809896914fd1a40bedd.svg',
previewUrl: '/codacy/coverage/59d607d0e311408885e418004068ea58.svg',
},
{
title: 'Codacy branch coverage',
previewUrl:
'/codacy/coverage/c44df2d9c89a4809896914fd1a40bedd/master.svg',
'/codacy/coverage/59d607d0e311408885e418004068ea58/master.svg',
},
{
title: 'Docker Automated build',
Expand Down
9 changes: 7 additions & 2 deletions services/codacy/codacy-coverage.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@ module.exports = class CodacyCoverage extends LegacyService {
return
}
try {
badgeData.text[1] = res
badgeData.colorscheme = coveragePercentageColor(parseInt(res))
const coverage = parseInt(res)
if (Number.isNaN(coverage)) {
badgeData.text[1] = 'unknown'
} else {
badgeData.text[1] = res
badgeData.colorscheme = coveragePercentageColor(coverage)
}
sendBadge(format, badgeData)
} catch (e) {
badgeData.text[1] = 'invalid'
Expand Down
7 changes: 7 additions & 0 deletions services/codacy/codacy.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ t.create('Coverage')
})
)

t.create('Coverage unknown')
.get('/coverage/e27821fb6289410b8f58338c7e0bc686.json')
.expectJSON({
name: 'coverage',
value: 'unknown',
})

t.create('Coverage on branch')
.get('/coverage/59d607d0e311408885e418004068ea58/master.json')
.expectJSONTypes(
Expand Down