aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2015-03-02 13:12:11 +0100
committerStas Vilchik <vilchiks@gmail.com>2015-03-02 15:20:45 +0100
commit71606c2451d08d0c6c35970afc88b20d76bc3928 (patch)
tree1d93596bc3d483cd6b4a7bea33526ed46c4cb497 /server
parent0940aa7ec60e0499fa0b3c279fb640585035f339 (diff)
downloadsonarqube-71606c2451d08d0c6c35970afc88b20d76bc3928.tar.gz
sonarqube-71606c2451d08d0c6c35970afc88b20d76bc3928.zip
SONAR-5884 show ut and it coverage separately
Diffstat (limited to 'server')
-rw-r--r--server/sonar-web/src/main/hbs/source-viewer/source-viewer.hbs17
-rw-r--r--server/sonar-web/src/main/js/source-viewer/source.js13
-rw-r--r--server/sonar-web/src/main/js/source-viewer/viewer.js35
3 files changed, 58 insertions, 7 deletions
diff --git a/server/sonar-web/src/main/hbs/source-viewer/source-viewer.hbs b/server/sonar-web/src/main/hbs/source-viewer/source-viewer.hbs
index 0f239f255df..7e57cd08867 100644
--- a/server/sonar-web/src/main/hbs/source-viewer/source-viewer.hbs
+++ b/server/sonar-web/src/main/hbs/source-viewer/source-viewer.hbs
@@ -17,10 +17,19 @@
{{/ifSCMChanged2}}
</td>
- <td class="source-meta source-line-coverage {{#notNull coverageStatus}}source-line-{{coverageStatus}}{{/notNull}}"
- data-line-number="{{line}}" {{#notNull coverageStatus}}title="{{t 'source_viewer.tooltip' coverageStatus}}" data-placement="right" data-toggle="tooltip"{{/notNull}}>
- <div class="source-line-bar"></div>
- </td>
+ {{#if ../hasCoverage}}
+ <td class="source-meta source-line-coverage {{#notNull coverageStatus}}source-line-{{coverageStatus}}{{/notNull}}"
+ data-line-number="{{line}}" {{#notNull coverageStatus}}title="{{t 'source_viewer.tooltip.ut' coverageStatus}}" data-placement="right" data-toggle="tooltip"{{/notNull}}>
+ <div class="source-line-bar"></div>
+ </td>
+ {{/if}}
+
+ {{#if ../hasITCoverage}}
+ <td class="source-meta source-line-coverage {{#notNull itCoverageStatus}}source-line-{{itCoverageStatus}}{{/notNull}}"
+ data-line-number="{{line}}" {{#notNull itCoverageStatus}}title="{{t 'source_viewer.tooltip.it' itCoverageStatus}}" data-placement="right" data-toggle="tooltip"{{/notNull}}>
+ <div class="source-line-bar"></div>
+ </td>
+ {{/if}}
{{#if ../hasDuplications}}
<td class="source-meta source-line-duplications {{#if duplicated}}source-line-duplicated{{/if}}"
diff --git a/server/sonar-web/src/main/js/source-viewer/source.js b/server/sonar-web/src/main/js/source-viewer/source.js
index 3413cbb9ec7..364e33ec2ce 100644
--- a/server/sonar-web/src/main/js/source-viewer/source.js
+++ b/server/sonar-web/src/main/js/source-viewer/source.js
@@ -26,6 +26,7 @@ define(function () {
return {
hasSource: false,
hasCoverage: false,
+ hasITCoverage: false,
hasDuplications: false,
hasSCM: false,
@@ -88,6 +89,18 @@ define(function () {
});
}
this.set({ hasDuplications: hasDuplications });
+ },
+
+ hasCoverage: function (source) {
+ return _.some(source, function (line) {
+ return line.coverageStatus != null;
+ });
+ },
+
+ hasITCoverage: function (source) {
+ return _.some(source, function (line) {
+ return line.itCoverageStatus != null;
+ });
}
});
diff --git a/server/sonar-web/src/main/js/source-viewer/viewer.js b/server/sonar-web/src/main/js/source-viewer/viewer.js
index 0afd5d76a5a..a65afb3d98f 100644
--- a/server/sonar-web/src/main/js/source-viewer/viewer.js
+++ b/server/sonar-web/src/main/js/source-viewer/viewer.js
@@ -180,6 +180,20 @@ define([
return status;
},
+ getItCoverageStatus: function (row) {
+ var status = null;
+ if (row.itLineHits > 0) {
+ status = 'partially-covered';
+ }
+ if (row.itLineHits > 0 && row.itConditions === row.itCoveredConditions) {
+ status = 'covered';
+ }
+ if (row.itLineHits === 0 || row.itCoveredConditions === 0) {
+ status = 'uncovered';
+ }
+ return status;
+ },
+
requestSource: function () {
var that = this,
url = baseUrl + '/api/sources/lines',
@@ -190,12 +204,17 @@ define([
source.unshift({line: 0});
}
source = source.map(function (row) {
- return _.extend(row, { coverageStatus: that.getCoverageStatus(row) });
+ return _.extend(row, {
+ coverageStatus: that.getCoverageStatus(row),
+ itCoverageStatus: that.getItCoverageStatus(row)
+ });
});
var firstLine = _.first(source).line,
linesRequested = options.to - options.from + 1;
that.model.set({
source: source,
+ hasCoverage: that.model.hasCoverage(source),
+ hasITCoverage: that.model.hasITCoverage(source),
hasSourceBefore: firstLine > 1,
hasSourceAfter: data.sources.length === linesRequested
});
@@ -573,10 +592,15 @@ define([
source.unshift({line: 0});
}
source = source.map(function (row) {
- return _.extend(row, { coverageStatus: that.getCoverageStatus(row) });
+ return _.extend(row, {
+ coverageStatus: that.getCoverageStatus(row),
+ itCoverageStatus: that.getItCoverageStatus(row)
+ });
});
that.model.set({
source: source,
+ hasCoverage: that.model.hasCoverage(source),
+ hasITCoverage: that.model.hasITCoverage(source),
hasSourceBefore: (data.sources.length === that.LINES_AROUND) && (_.first(source).line > 0)
});
that.addIssuesPerLineMeta(that.issues);
@@ -611,10 +635,15 @@ define([
that.model.set({ hasSourceBefore: true });
}
source = source.map(function (row) {
- return _.extend(row, { coverageStatus: that.getCoverageStatus(row) });
+ return _.extend(row, {
+ coverageStatus: that.getCoverageStatus(row),
+ itCoverageStatus: that.getItCoverageStatus(row)
+ });
});
that.model.set({
source: source,
+ hasCoverage: that.model.hasCoverage(source),
+ hasITCoverage: that.model.hasITCoverage(source),
hasSourceAfter: data.sources.length === that.LINES_AROUND
});
that.addIssuesPerLineMeta(that.issues);