]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5209 Duplications feedback
authorStas Vilchik <vilchiks@gmail.com>
Wed, 11 Jun 2014 09:52:20 +0000 (15:52 +0600)
committerStas Vilchik <vilchiks@gmail.com>
Wed, 11 Jun 2014 09:52:28 +0000 (15:52 +0600)
sonar-server/src/main/coffee/component-viewer/duplication-popup.coffee
sonar-server/src/main/coffee/component-viewer/source.coffee
sonar-server/src/main/hbs/component-viewer/source.hbs

index 1ee535a16dd4e4ac524d40bbd42f9d7922fe6f5b..f8cd287028bfc9072cb24fcafadc6b020743a1a5 100644 (file)
@@ -37,8 +37,8 @@ define [
 
     serializeData: ->
       files = @options.main.source.get('duplicationFiles')
-      blocks = _.groupBy @collection.toJSON(), '_ref'
-      duplications = _.map blocks, (blocks, fileRef) ->
+      groupedBlocks = _.groupBy @collection.toJSON(), '_ref'
+      duplications = _.map groupedBlocks, (blocks, fileRef) ->
         blocks: blocks
         file: files[fileRef]
       duplications: duplications
index 2e1b4d8a6770c996b4b878b219c3e1f3c87e7aa1..ffac6cb717d13f19e7cf8d4019542b8564b2a507 100644 (file)
@@ -136,10 +136,14 @@ define [
       e.stopPropagation()
       $('body').click()
       index = $(e.currentTarget).data 'index'
+      line = $(e.currentTarget).closest('[data-line-number]').data 'line-number'
+      blocks = @model.get('duplications')[index - 1].blocks
+      blocks = _.filter blocks, (b) ->
+        (b._ref != '1') || (b._ref == '1' && b.from > line) || (b._ref == '1' && b.from + b.size <= line)
       popup = new DuplicationPopupView
         triggerEl: $(e.currentTarget)
         main: @options.main
-        collection: new Backbone.Collection @model.get('duplications')[index - 1].blocks
+        collection: new Backbone.Collection blocks
       popup.render()
 
 
index b4f9c67709f891b40cefc486b4dc5cb308697e22..938afe0a446af1b9c8d30fa9c7be273cbe2cf4a7 100644 (file)
       <tr class="row"
           data-line-number="{{lineNumber}}">
 
-        {{#if ../../settings.duplications}}
-          <td class="stat duplications">
-            {{#each duplications}}
-              <span class="duplication {{#if this}}duplication-exists{{/if}}" data-index="{{this}}"></span>
-            {{/each}}
-          </td>
-        {{/if}}
-
         {{#if ../../settings.scm}}
           <td class="stat {{#if scm}}scm{{/if}}">
             {{#if scm}}
           </td>
         {{/if}}
 
+        {{#if ../../settings.duplications}}
+          <td class="stat duplications">
+            {{#each duplications}}
+              <span class="duplication {{#if this}}duplication-exists{{/if}}" data-index="{{this}}"></span>
+            {{/each}}
+          </td>
+        {{/if}}
+
         {{#if ../../settings.coverage}}
           <td class="stat {{#if coverage}}coverage-{{#if coverage.covered}}green{{else}}red{{/if}}{{/if}}">
             {{#if coverage}}