aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2015-08-17 17:08:06 +0200
committerStas Vilchik <vilchiks@gmail.com>2015-08-17 17:11:54 +0200
commit862d4a02e215d2b6ae215976f766e761ed9d84d0 (patch)
tree44d65d1e1751b620a3d8b187d14eecc2b455500e /server
parent24f3abee42c9e734418f5ad4359f639bca5eb899 (diff)
downloadsonarqube-862d4a02e215d2b6ae215976f766e761ed9d84d0.tar.gz
sonarqube-862d4a02e215d2b6ae215976f766e761ed9d84d0.zip
SONAR-6765 apply feedback
Diffstat (limited to 'server')
-rw-r--r--server/sonar-web/src/main/js/components/source-viewer/main.js37
-rw-r--r--server/sonar-web/src/test/json/source-viewer-spec/issues-with-precise-location.json9
-rw-r--r--server/sonar-web/test/medium/source-viewer.spec.js6
3 files changed, 31 insertions, 21 deletions
diff --git a/server/sonar-web/src/main/js/components/source-viewer/main.js b/server/sonar-web/src/main/js/components/source-viewer/main.js
index 62129a4e376..42812e6a62f 100644
--- a/server/sonar-web/src/main/js/components/source-viewer/main.js
+++ b/server/sonar-web/src/main/js/components/source-viewer/main.js
@@ -86,7 +86,7 @@ define([
}
this.issues = new Issues();
this.listenTo(this.issues, 'change:severity', this.onIssuesSeverityChange);
- this.listenTo(this.issues, 'locations', this.toggleFlowLocations);
+ this.listenTo(this.issues, 'locations', this.toggleIssueLocations);
this.issueViews = [];
this.loadSourceBeforeThrottled = _.throttle(this.loadSourceBefore, 1000);
this.loadSourceAfterThrottled = _.throttle(this.loadSourceAfter, 1000);
@@ -737,16 +737,16 @@ define([
$(e.currentTarget).tooltip('destroy');
},
- toggleFlowLocations: function (issue) {
+ toggleIssueLocations: function (issue) {
if (this.locationsShowFor === issue) {
- this.hideFlowLocations();
+ this.hideIssueLocations();
} else {
- this.hideFlowLocations();
- this.showFlowLocations(issue);
+ this.hideIssueLocations();
+ this.showIssueLocations(issue);
}
},
- showFlowLocations: function (issue) {
+ showIssueLocations: function (issue) {
this.locationsShowFor = issue;
var primaryLocation = {
msg: issue.get('message'),
@@ -757,25 +757,32 @@ define([
issue.get('executionFlows').forEach(function (flow) {
_locations = [].concat(_locations, flow.locations);
});
- _locations.forEach(this.showFlowLocation, this);
+ _locations.forEach(this.showIssueLocation, this);
},
- showFlowLocation: function (location) {
+ showIssueLocation: function (location, index) {
if (location && location.textRange) {
var line = location.textRange.startLine,
- row = this.$('.source-line-code[data-line-number="' + line + '"]'),
- renderedFlowLocation = this.renderFlowLocation(location);
- row.find('.source-line-issue-locations').append(renderedFlowLocation);
- this.highlightFlowLocationInCode(location);
+ row = this.$('.source-line-code[data-line-number="' + line + '"]');
+
+ if (index > 0 && _.size(location.msg)) {
+ // render location marker only for
+ // secondary locations and execution flows
+ // and only if message is not empty
+ var renderedFlowLocation = this.renderIssueLocation(location);
+ row.find('.source-line-issue-locations').append(renderedFlowLocation);
+ }
+
+ this.highlightIssueLocationInCode(location);
}
},
- renderFlowLocation: function (location) {
+ renderIssueLocation: function (location) {
location.msg = location.msg ? location.msg : ' ';
return this.issueLocationTemplate(location);
},
- highlightFlowLocationInCode: function (location) {
+ highlightIssueLocationInCode: function (location) {
for (var line = location.textRange.startLine; line <= location.textRange.endLine; line++) {
var row = this.$('.source-line-code[data-line-number="' + line + '"]');
@@ -791,7 +798,7 @@ define([
}
},
- hideFlowLocations: function () {
+ hideIssueLocations: function () {
this.locationsShowFor = null;
this.$('.source-line-issue-locations').empty();
this.$('.source-line-code-secondary-issue').removeClass('source-line-code-secondary-issue');
diff --git a/server/sonar-web/src/test/json/source-viewer-spec/issues-with-precise-location.json b/server/sonar-web/src/test/json/source-viewer-spec/issues-with-precise-location.json
index abf37c14c8c..215ed12c651 100644
--- a/server/sonar-web/src/test/json/source-viewer-spec/issues-with-precise-location.json
+++ b/server/sonar-web/src/test/json/source-viewer-spec/issues-with-precise-location.json
@@ -30,7 +30,8 @@
"endLine": 3,
"startOffset": 15,
"endOffset": 20
- }
+ },
+ "msg": "Secondary Location #1"
}
],
"executionFlows": [],
@@ -82,7 +83,8 @@
"endLine": 8,
"startOffset": 6,
"endOffset": 11
- }
+ },
+ "msg": "Secondary Location #1"
}
],
"executionFlows": [],
@@ -134,7 +136,8 @@
"endLine": 18,
"startOffset": 15,
"endOffset": 9
- }
+ },
+ "msg": "Secondary Location #1"
}
],
"executionFlows": [],
diff --git a/server/sonar-web/test/medium/source-viewer.spec.js b/server/sonar-web/test/medium/source-viewer.spec.js
index 544dfa39427..5872dc7c0fe 100644
--- a/server/sonar-web/test/medium/source-viewer.spec.js
+++ b/server/sonar-web/test/medium/source-viewer.spec.js
@@ -42,7 +42,7 @@ define(function (require) {
.checkElementInclude('.source-line-code[data-line-number="3"] .source-line-code-issue', '14 So')
.clickElement('.source-line-with-issues[data-line-number="3"]')
.clickElement('.js-issue-locations')
- .checkElementExist('.source-line-code[data-line-number="3"] .source-viewer-issue-location')
+ .checkElementCount('.source-line-code[data-line-number="3"] .source-viewer-issue-location', 1)
.checkElementCount('.source-line-code[data-line-number="3"] .source-line-code-secondary-issue', 2)
.checkElementInclude('.source-line-code[data-line-number="3"] .source-line-code-secondary-issue', ') 200')
.checkElementInclude('.source-line-code[data-line-number="3"] .source-line-code-secondary-issue', '14 So');
@@ -61,8 +61,8 @@ define(function (require) {
.checkElementInclude('.source-line-code[data-line-number="9"] .source-line-code-issue', 'sion')
.clickElement('.source-line-with-issues[data-line-number="9"]')
.clickElement('.js-issue-locations')
- .checkElementExist('.source-line-code[data-line-number="8"] .source-viewer-issue-location')
- .checkElementExist('.source-line-code[data-line-number="9"] .source-viewer-issue-location')
+ .checkElementCount('.source-line-code[data-line-number="8"] .source-viewer-issue-location', 1)
+ .checkElementNotExist('.source-line-code[data-line-number="9"] .source-viewer-issue-location')
.checkElementCount('.source-line-code[data-line-number="8"] .source-line-code-secondary-issue', 1)
.checkElementCount('.source-line-code[data-line-number="9"] .source-line-code-secondary-issue', 1)
.checkElementInclude('.source-line-code[data-line-number="8"] .source-line-code-secondary-issue', 'ense ')