aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2015-03-27 10:33:11 +0100
committerStas Vilchik <vilchiks@gmail.com>2015-03-27 10:43:05 +0100
commit3fff0e8918b8de03e413b357ed46e4adaa71d2ca (patch)
treebac5ac8f53f729ce7e36b2d89032bf205e6fa2c3 /server/sonar-web/src/main/js
parent7bad03950e4ec3e82a5fef2ef50867a2e4ac29e2 (diff)
downloadsonarqube-3fff0e8918b8de03e413b357ed46e4adaa71d2ca.tar.gz
sonarqube-3fff0e8918b8de03e413b357ed46e4adaa71d2ca.zip
show warning when find a duplication in a removed component
Diffstat (limited to 'server/sonar-web/src/main/js')
-rw-r--r--server/sonar-web/src/main/js/source-viewer/popups/duplication-popup.js34
-rw-r--r--server/sonar-web/src/main/js/source-viewer/viewer.js22
2 files changed, 29 insertions, 27 deletions
diff --git a/server/sonar-web/src/main/js/source-viewer/popups/duplication-popup.js b/server/sonar-web/src/main/js/source-viewer/popups/duplication-popup.js
index 4564bfd8d1d..73dbec36ed8 100644
--- a/server/sonar-web/src/main/js/source-viewer/popups/duplication-popup.js
+++ b/server/sonar-web/src/main/js/source-viewer/popups/duplication-popup.js
@@ -42,27 +42,25 @@ define([
},
serializeData: function () {
- var duplications, files, groupedBlocks;
- files = this.model.get('duplicationFiles');
- groupedBlocks = _.groupBy(this.collection.toJSON(), '_ref');
- duplications = _.map(groupedBlocks, function (blocks, fileRef) {
- return {
- blocks: blocks,
- file: files[fileRef]
- };
+ var that = this,
+ files = this.model.get('duplicationFiles'),
+ groupedBlocks = _.groupBy(this.collection.toJSON(), '_ref'),
+ duplications = _.map(groupedBlocks, function (blocks, fileRef) {
+ return {
+ blocks: blocks,
+ file: files[fileRef]
+ };
+ });
+ duplications = _.sortBy(duplications, function (d) {
+ var a = d.file.projectName !== that.model.get('projectName'),
+ b = d.file.subProjectName !== that.model.get('subProjectName'),
+ c = d.file.key !== that.model.get('key');
+ return '' + a + b + c;
});
- duplications = _.sortBy(duplications, (function (_this) {
- return function (d) {
- var a, b, c;
- a = d.file.projectName !== _this.model.get('projectName');
- b = d.file.subProjectName !== _this.model.get('subProjectName');
- c = d.file.key !== _this.model.get('key');
- return '' + a + b + c;
- };
- })(this));
return {
component: this.model.toJSON(),
- duplications: duplications
+ duplications: duplications,
+ inRemovedComponent: this.options.inRemovedComponent
};
}
});
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 9dabf5698c8..72f197f7008 100644
--- a/server/sonar-web/src/main/js/source-viewer/viewer.js
+++ b/server/sonar-web/src/main/js/source-viewer/viewer.js
@@ -142,7 +142,7 @@ define([
.fail(function () {
that.model.set({
source: [
- {line: 0}
+ { line: 0 }
]
});
finalize();
@@ -157,7 +157,7 @@ define([
options = { uuid: this.model.id };
return $.get(url, options).done(function (data) {
that.model.set(data);
- that.model.set({isUnitTest: data.q === 'UTS'});
+ that.model.set({ isUnitTest: data.q === 'UTS' });
});
},
@@ -199,11 +199,11 @@ define([
requestSource: function () {
var that = this,
url = baseUrl + '/api/sources/lines',
- options = _.extend({uuid: this.model.id}, this.linesLimit());
+ options = _.extend({ uuid: this.model.id }, this.linesLimit());
return $.get(url, options).done(function (data) {
var source = (data.sources || []).slice(0);
if (source.length === 0 || (source.length > 0 && _.first(source).line === 1)) {
- source.unshift({line: 0});
+ source.unshift({ line: 0 });
}
source = source.map(function (row) {
return _.extend(row, {
@@ -236,7 +236,7 @@ define([
requestDuplications: function () {
var that = this,
url = baseUrl + '/api/duplications/show',
- options = { uuid : this.model.id };
+ options = { uuid: this.model.id };
return $.get(url, options, function (data) {
var hasDuplications = (data != null) && (data.duplications != null),
duplications = [];
@@ -378,7 +378,7 @@ define([
e.stopPropagation();
$('body').click();
var line = +$(e.currentTarget).data('line-number'),
- row = _.findWhere(this.model.get('source'), {line: line}),
+ row = _.findWhere(this.model.get('source'), { line: line }),
popup = new SCMPopupView({
triggerEl: $(e.currentTarget),
model: new Backbone.Model(row)
@@ -431,14 +431,18 @@ define([
this.clearTooltips();
var index = $(e.currentTarget).data('index'),
line = $(e.currentTarget).data('line-number'),
- blocks = this.model.get('duplications')[index - 1].blocks;
+ blocks = this.model.get('duplications')[index - 1].blocks,
+ inRemovedComponent = _.some(blocks, function (b) {
+ return b._ref == null;
+ });
blocks = _.filter(blocks, function (b) {
var outOfBounds = b.from > line || b.from + b.size < line;
- return (b._ref !== '1') || (b._ref === '1' && outOfBounds);
+ return (b._ref != null) && ((b._ref !== '1') || (b._ref === '1' && outOfBounds));
});
var popup = new DuplicationPopupView({
triggerEl: $(e.currentTarget),
model: this.model,
+ inRemovedComponent: inRemovedComponent,
collection: new Backbone.Collection(blocks)
});
popup.render();
@@ -583,7 +587,7 @@ define([
that.model.set({ hasSourceAfter: true });
}
if (source.length === 0 || (source.length > 0 && _.first(source).line === 1)) {
- source.unshift({line: 0});
+ source.unshift({ line: 0 });
}
source = source.map(function (row) {
return _.extend(row, {