]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5760 Component Viewer fails to show a big files
authorStas Vilchik <vilchiks@gmail.com>
Mon, 20 Oct 2014 09:44:26 +0000 (11:44 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Mon, 20 Oct 2014 11:26:57 +0000 (13:26 +0200)
server/sonar-web/src/main/coffee/component-viewer/main.coffee
server/sonar-web/src/main/coffee/component-viewer/source.coffee
server/sonar-web/src/main/hbs/component-viewer/cw-source.hbs
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index e6da45caa2f2b316d79a254281f5215e633e2b5d..5ba64c236a0f2014d5b9c8e7a1fc68e5f085db97 100644 (file)
@@ -65,6 +65,8 @@ define [
 
   SCROLL_OFFSET = 10
 
+  LINES_LIMIT = 3000
+
 
 
   class ComponentViewer extends utils.mixOf Marionette.Layout, IssuesMixin, CoverageMixin, DuplicationsMixin, SCMMixin
@@ -201,10 +203,15 @@ define [
       $.get API_MEASURES, data, (data) =>
         measuresList = data[0].msr || []
         measures = @component.get 'measures'
+        lines = null
         measuresList.forEach (m) ->
           measures[m.key] = m.frmt_val || m.data
+          lines = m.val if m.key == 'ncloc'
         @component.set 'measures', measures
-        @augmentWithNclocData()
+        if lines < LINES_LIMIT
+          @augmentWithNclocData()
+        else
+          delete measures['ncloc_data']
 
 
     requestTrends: (key, period) ->
index bad93f7bc93fe2567700b4c8d42264e80a2755b7..423a555c3a38de7726e947a762fb4952d597d962 100644 (file)
@@ -22,6 +22,7 @@ define [
   $ = jQuery
 
   API_COVERAGE_TESTS = "#{baseUrl}/api/tests/test_cases"
+  LINES_LIMIT = 3000
   ISSUES_LIMIT = 100
 
 
@@ -91,6 +92,7 @@ define [
         $(expand).insertBefore rows.first()
 
       lines = _.size @model.get 'source'
+      lines = Math.min lines, LINES_LIMIT
       lastShown = rows.last().data('line-number')
       if lastShown < lines
         expand = @expandTemplate from: lastShown, to: lines, settings: @options.main.settings.toJSON()
@@ -274,16 +276,17 @@ define [
       source.forEach (sourceLine) =>
         show = false
         line = sourceLine.lineNumber
-        @showBlocks.forEach (block) ->
-          show = true if block.from <= line && block.to >= line
-        _.extend sourceLine, show: show
+        if line <= LINES_LIMIT
+          @showBlocks.forEach (block) ->
+            show = true if block.from <= line && block.to >= line
+          _.extend sourceLine, show: show
       source
 
 
     prepareSource: ->
       source = @model.get 'formattedSource'
       if source?
-        @augmentWithShow source
+        _.first @augmentWithShow(source), LINES_LIMIT
 
 
     getStatColumnsCount: ->
@@ -313,3 +316,5 @@ define [
       showZeroLine: @showZeroLine()
       issuesLimit: ISSUES_LIMIT
       issuesLimitReached: @model.get('activeIssues')?.length > ISSUES_LIMIT
+      linesLimit: LINES_LIMIT
+      linesLimitReached: _.size(@model.get 'source') > LINES_LIMIT
index 96f27fd2125a7cf2451626e74b7c1c4c4a0fda65..33c9134e6e43d41e8c1c1c22af7c83d4f0ee5056 100644 (file)
@@ -4,14 +4,18 @@
 
 {{else}}
 
-  {{#if state.duplicationsInDeletedFiles}}
-    <p class="marginbottom10 js-duplications-in-deleted-files">{{t 'duplications.dups_found_on_deleted_resource'}}</p>
+  {{#if linesLimitReached}}
+    <p class="message-alert marginbottom10">{{tp 'component_viewer.lines_limit_reached' linesLimit}}</p>
   {{/if}}
 
   {{#if issuesLimitReached}}
     <p class="message-alert marginbottom10">{{tp 'component_viewer.issues_limit_reached' issuesLimit}}</p>
   {{/if}}
 
+  {{#if state.duplicationsInDeletedFiles}}
+    <p class="marginbottom10 js-duplications-in-deleted-files">{{t 'duplications.dups_found_on_deleted_resource'}}</p>
+  {{/if}}
+
   <table class="code">
     {{#if showZeroLine}}
       <tr class="row row-hidden" data-line-number="0" id="{{uid}}-0">
index bd72fe78a4434d8481585685ec61b921fe8d48c5..71963578715030a8c0cf893486d76b71435a362d 100644 (file)
@@ -2726,6 +2726,7 @@ component_viewer.more_actions=More Actions
 component_viewer.new_window=Open in New Window
 component_viewer.get_permalink=Get Permalink
 component_viewer.covered_lines=Covered Lines
+component_viewer.lines_limit_reached=For performance reasons, only the {0} first lines will be displayed.
 component_viewer.issues_limit_reached=For usability reasons, only the {0} first issues will be fully displayed. Remaining issues will simply be underlined.
 component_viewer.issues_limit_reached_tooltip={0}\n\nRefine your filter to be able to see the details of this issue.
 component_viewer.cannot_show=We're sorry, but something went wrong. Please try back in a few minutes and contact support if the problem persists.