'<%= pkg.assets %>js/templates/quality-gates.js': [
'<%= pkg.sources %>hbs/quality-gates/**/*.hbs'
]
- '<%= pkg.assets %>js/templates/component-viewer.js': [
- '<%= pkg.sources %>hbs/component-viewer/**/*.hbs'
- ]
'<%= pkg.assets %>js/templates/source-viewer.js': [
'<%= pkg.sources %>hbs/source-viewer/**/*.hbs'
]
+++ /dev/null
-define [
- 'backbone.marionette'
- 'templates/component-viewer'
- 'common/popup'
- 'component-viewer/utils'
-], (
- Marionette
- Templates
- Popup
- utils
-) ->
-
- $ = jQuery
-
-
- class CoveragePopupView extends Popup
- template: Templates['cw-coverage-popup']
-
-
- events:
- 'click a[data-key]': 'goToFile'
-
-
- onRender: ->
- source = @options.main.sourceView.$el
- sourceOffset = source.offset()
- trigger = @options.triggerEl
- triggerOffset = trigger.offset()
- @$el.detach().appendTo(source).css
- top: triggerOffset.top - sourceOffset.top + source.scrollTop()
- left: triggerOffset.left - sourceOffset.left + source.scrollLeft() + trigger.outerWidth()
- @attachCloseEvents()
-
-
- goToFile: (e) ->
- el = $(e.currentTarget)
- key = el.data 'key'
- method = el.data 'method'
- files = @model.get 'files'
- @options.main.addTransition 'coverage', _.map files, (file) ->
- x = utils.splitLongName file.longName
- key: file.key
- name: x.name
- subname: x.dir
- active: file.key == key
- @options.main.state.unset 'activeHeaderTab'
- @options.main.state.unset 'activeHeaderItem'
- @options.main._open key
- @options.main.on 'loaded', =>
- @options.main.off 'loaded'
- @options.main.headerView.enableBar('tests').done =>
- if method?
- @options.main.headerView.enableUnitTest method
-
-
- serializeData: ->
- files = @model.get 'files'
- tests = _.groupBy @model.get('tests'), '_ref'
- testFiles = _.map tests, (testSet, fileRef) ->
- file: files[fileRef]
- tests: testSet
- testFiles: testFiles
- row: @options.row
+++ /dev/null
-define [
- 'backbone.marionette'
- 'templates/component-viewer'
- 'common/popup'
- 'component-viewer/utils'
-], (
- Marionette
- Templates
- Popup
- utils
-) ->
-
- $ = jQuery
-
-
- class CoveredFilesPopupView extends Popup
- template: Templates['cw-covered-files-popup']
-
-
- events:
- 'click a[data-key]': 'goToFile'
-
-
- goToFile: (e) ->
- key = $(e.currentTarget).data 'key'
- files = @collection.toJSON()
- @options.main.addTransition 'covers', _.map files, (file) ->
- x = utils.splitLongName file.longName
- key: file.key
- name: x.name
- subname: x.dir
- active: file.key == key
- @options.main._open key
-
-
- serializeData: ->
- items = @collection.toJSON().map (file) ->
- _.extend file, utils.splitLongName file.longName
- sortedItems = _.sortBy items, 'name'
- items: sortedItems
- test: @options.test
+++ /dev/null
-define [
- 'backbone.marionette'
- 'templates/component-viewer'
- 'common/popup'
- 'component-viewer/utils'
-], (
- Marionette
- Templates
- Popup
- utils
-) ->
-
- $ = jQuery
-
-
- class DuplicationPopupView extends Popup
- template: Templates['cw-duplication-popup']
-
-
- events:
- 'click a[data-key]': 'goToFile'
-
-
- onRender: ->
- source = @options.main.sourceView.$el
- sourceOffset = source.offset()
- trigger = @options.triggerEl
- triggerOffset = trigger.offset()
- @$el.detach().appendTo(source).css
- top: triggerOffset.top - sourceOffset.top + source.scrollTop()
- left: triggerOffset.left - sourceOffset.left + source.scrollLeft() + trigger.outerWidth()
- @attachCloseEvents()
-
-
- goToFile: (e) ->
- key = $(e.currentTarget).data 'key'
- line = $(e.currentTarget).data 'line'
- files = @options.main.source.get('duplicationFiles')
- options = @collection.map (item) ->
- file = files[item.get('_ref')]
- x = utils.splitLongName file.name
- key: file.key
- name: x.name
- subname: x.dir
- component:
- projectName: file.projectName
- subProjectName: file.subProjectName
- active: file.key == key
- options = _.uniq options, (item) -> item.key
- @options.main.addTransition 'duplication', options
- if key == @options.main.component.get 'key'
- @options.main.scrollToLine line
- @options.main.workspaceView.render()
- else
- @options.main._open key
- @options.main.on 'sized', =>
- @options.main.off 'sized'
- @options.main.scrollToLine line
-
-
- serializeData: ->
- files = @options.main.source.get('duplicationFiles')
- groupedBlocks = _.groupBy @collection.toJSON(), '_ref'
- duplications = _.map groupedBlocks, (blocks, fileRef) ->
- blocks: blocks
- file: files[fileRef]
- duplications = _.sortBy duplications, (d) =>
- a = d.file.projectName != @options.main.component.get 'projectName'
- b = d.file.subProjectName != @options.main.component.get 'subProjectName'
- c = d.file.key != @options.main.component.get 'key'
- '' + a + b + c
-
- component: @options.main.component.toJSON()
- duplications: duplications
+++ /dev/null
-define [
- 'backbone.marionette'
- 'templates/component-viewer'
-
- 'component-viewer/header/basic-header'
- 'component-viewer/header/issues-header'
- 'component-viewer/header/coverage-header'
- 'component-viewer/header/duplications-header'
- 'component-viewer/header/scm-header'
- 'component-viewer/header/tests-header'
- 'component-viewer/header/more-actions'
-
- 'common/handlebars-extensions'
-], (
- Marionette
- Templates
-
- BasicHeaderView
- IssuesHeaderView
- CoverageHeaderView
- DuplicationsHeaderView
- SCMHeaderView
- TestsHeaderView
- MoreActionsView
-) ->
-
- $ = jQuery
-
- API_FAVORITE = "#{baseUrl}/api/favourites"
- API_EXTENSION = "#{baseUrl}/resource/extension"
- BARS = [
- { scope: 'basic', view: BasicHeaderView }
- { scope: 'issues', view: IssuesHeaderView }
- { scope: 'coverage', view: CoverageHeaderView }
- { scope: 'duplications', view: DuplicationsHeaderView }
- { scope: 'scm', view: SCMHeaderView }
- { scope: 'tests', view: TestsHeaderView }
- ]
-
-
- class extends Marionette.Layout
- template: Templates['cw-header']
-
-
- regions:
- barRegion: '.component-viewer-header-expanded-bar'
-
-
- ui:
- expandLinks: '.component-viewer-header-measures-expand'
- expandedBar: '.component-viewer-header-expanded-bar'
- spinnerBar: '.component-viewer-header-expanded-bar[data-scope=spinner]'
- unitTests: '.js-unit-test'
-
-
- events:
- 'click .js-favorite': 'toggleFavorite'
- 'click .js-actions': 'showMoreActions'
- 'click .js-extension-close': 'closeExtension'
- 'click .js-permalink': 'getPermalink'
- 'click @ui.expandLinks': 'showExpandedBar'
- 'click .js-toggle-issues': 'toggleIssues'
- 'click .js-toggle-coverage': 'toggleCoverage'
- 'click .js-toggle-duplications': 'toggleDuplications'
- 'click .js-toggle-scm': 'toggleSCM'
-
-
- initialize: (options) ->
- options.main.settings.on 'change', => @changeSettings()
- @state = options.main.state
- @component = options.main.component
- @settings = options.main.component
-
-
- onRender: ->
- @delegateEvents()
- activeHeaderTab = @state.get 'activeHeaderTab'
- activeHeaderItem = @state.get 'activeHeaderItem'
- if activeHeaderTab
- if _.findWhere(BARS, scope: activeHeaderTab)?
- @enableBar(activeHeaderTab).done =>
- if activeHeaderItem
- @enableBarItem activeHeaderItem, @silentUpdate
- else
- @showExtension activeHeaderTab
- @silentUpdate = false
-
-
- toggleFavorite: ->
- component = @component
- if component.get 'fav'
- $.ajax
- url: "#{API_FAVORITE}/#{component.get 'key'}"
- type: 'DELETE'
- .done =>
- component.set 'fav', false
- @render()
- else
- $.ajax
- url: API_FAVORITE
- type: 'POST'
- data: key: component.get 'key'
- .done =>
- component.set 'fav', true
- @render()
-
-
- showMoreActions: (e) ->
- e.stopPropagation()
- $('body').click()
- view = new MoreActionsView main: @options.main
- view.render().$el.appendTo @$el
-
-
- showExtension: (key) ->
- bar = @ui.expandedBar
- bar.html('<i class="spinner spinner-margin"></i>').addClass 'active'
- @ui.expandLinks.removeClass 'active'
- $.get API_EXTENSION, id: @options.main.component.get('key'), tab: key, (r) =>
- bar.html r
-
-
- closeExtension: (e) ->
- e.preventDefault()
- @ui.expandedBar.html('').removeClass 'active'
-
-
- showBarSpinner: ->
- @ui.spinnerBar.addClass 'active'
-
-
- hideBarSpinner: ->
- @ui.spinnerBar.removeClass 'active'
-
-
- resetBars: ->
- @state.set 'activeHeaderTab', null
- @ui.expandLinks.removeClass 'active'
- @ui.expandedBar.removeClass 'active'
- @barRegion.reset()
- @options.main.fitIntoElement()
-
-
- enableBar: (scope) ->
- @ui.expandedBar.html('<i class="spinner spinner-margin"></i>').addClass 'active'
- requests = []
- unless @state.get 'hasMeasures'
- requests.push @options.main.requestMeasures @options.main.key
- if @component.get('isUnitTest') && !@state.get('hasTests')
- requests.push @options.main.requestTests @options.main.key
- $.when.apply($, requests).done =>
- @state.set 'activeHeaderTab', scope
- bar = _.findWhere BARS, scope: scope
- @barRegion.show new bar.view
- main: @options.main, state: @state, component: @component, settings: @settings, source: @model, header: @
- @ui.expandedBar.addClass 'active'
- @ui.expandLinks.filter("[data-scope=#{scope}]").addClass 'active'
- @options.main.fitIntoElement()
-
-
- enableBarItem: (item, silent = false) ->
- $item = @$(item)
- if $item.length > 0
- if silent then @$(item).addClass('active') else @$(item).click()
- else
- @options.main.hideAllLines()
-
-
- showExpandedBar: (e) ->
- el = $(e.currentTarget)
- active = el.is '.active'
- @resetBars()
- unless active
- el.addClass 'active'
- scope = el.data 'scope'
- @enableBar(scope).done =>
- @$('.js-filter-unresolved-issues').click() if scope == 'issues'
- @$('.js-filter-lines-to-cover').click() if scope == 'coverage'
- @$('.js-filter-duplications').click() if scope == 'duplications'
- @$('.js-filter-modified-lines').click() if scope == 'scm'
-
-
- changeSettings: ->
- @$('.js-toggle-issues').toggleClass 'active', @options.main.settings.get 'issues'
- @$('.js-toggle-coverage').toggleClass 'active', @options.main.settings.get 'coverage'
- @$('.js-toggle-duplications').toggleClass 'active', @options.main.settings.get 'duplications'
- @$('.js-toggle-scm').toggleClass 'active', @options.main.settings.get 'scm'
-
-
- toggleSetting: (e, show, hide) ->
- @showBlocks = []
- active = $(e.currentTarget).is '.active'
- if active
- hide.call @options.main, true
- else
- show.call @options.main, true
-
-
- toggleIssues: (e) -> @toggleSetting e, @options.main.showIssues, @options.main.hideIssues
- toggleCoverage: (e) -> @toggleSetting e, @options.main.showCoverage, @options.main.hideCoverage
- toggleDuplications: (e) -> @toggleSetting e, @options.main.showDuplications, @options.main.hideDuplications
- toggleSCM: (e) -> @toggleSetting e, @options.main.showSCM, @options.main.hideSCM
- toggleWorkspace: (e) -> @toggleSetting e, @options.main.showWorkspace, @options.main.hideWorkspace
-
-
- showTimeChangesSpinner: ->
- @$('.component-viewer-header-time-changes').html '<i class="spinner spinner-margin"></i>'
-
-
- unsetFilter: ->
- @options.main.resetIssues()
- @options.main.showAllLines()
- @state.unset 'activeHeaderItem'
- @$('.item.active').removeClass 'active'
- @render()
-
-
- filterLines: (e, methodName, extra) ->
- @$('.component-viewer-header-expanded-bar-section-list .active').removeClass 'active'
- $(e.currentTarget).addClass 'active'
- method = @options.main[methodName]
- method.call @options.main, extra
-
-
- serializeShowBlocks: ->
- blocks = @options.main.sourceView.showBlocks.map (b) -> "#{b.from},#{b.to}"
- blocks.join ';'
-
-
- getPermalink: ->
- params = []
- params.push key: 'component', value: @options.main.component.get 'key'
- settings = []
- _.map @options.main.settings.toJSON(), (v, k) -> settings.push k if v
- params.push key: 'settings', value: settings.join ','
- params.push key: 'blocks', value: @serializeShowBlocks()
- activeHeaderTab = @state.get 'activeHeaderTab'
- if activeHeaderTab
- params.push key: 'tab', value: activeHeaderTab
- activeHeaderItem = @state.get 'activeHeaderItem'
- if activeHeaderItem
- params.push key: 'item', value: activeHeaderItem
- highlightedLine = @options.main.sourceView.highlightedLine
- period = @state.get 'period'
- if period?
- params.push key: 'period', value: period.get 'key'
- if @options.main.currentIssue
- params.push key: 'currentIssue', value: @options.main.currentIssue
- if highlightedLine
- params.push key: 'line', value: highlightedLine
- hash = params.map((d) -> "#{d.key}=#{encodeURIComponent(d.value)}" ).join '&'
-
- windowParams = 'resizable=1,scrollbars=1,status=1'
- window.open "#{baseUrl}/component/index##{hash}", @options.main.component.get('name'), windowParams
-
-
-
- serializeData: ->
- component = @component.toJSON()
- if component.measures
- component.measures.maxIssues = Math.max(
- component.measures.fBlockerIssues || 0
- component.measures.fCriticalIssues || 0
- component.measures.fMajorIssues || 0
- component.measures.fMinorIssues || 0
- component.measures.fInfoIssues || 0
- )
-
- settings: @options.main.settings.toJSON()
- state: @state.toJSON()
- showSettings: @showSettings
- component: component
- currentIssue: @options.main.currentIssue
+++ /dev/null
-define [
- 'backbone.marionette'
-], (
- Marionette
-) ->
-
- class extends Marionette.ItemView
-
- initialize: (options) ->
- super
- @main = options.main
- @state = options.state
- @component = options.component
- @settings = options.settings
- @source = options.source
- @header = options.header
-
-
- serializeData: ->
- _.extend super,
- state: @state.toJSON()
- component: @component.toJSON()
- settings: @settings.toJSON()
- periods: @main.periods.toJSON()
\ No newline at end of file
+++ /dev/null
-define [
- 'backbone.marionette'
- 'templates/component-viewer'
- 'component-viewer/header/base-header'
-], (
- Marionette
- Templates
- BaseHeaderView
-) ->
-
- $ = jQuery
-
-
- class extends BaseHeaderView
- template: Templates['cw-basic-header']
-
-
- events:
- 'click .js-filter-lines': 'filterByLines'
- 'click .js-filter-ncloc': 'filterByNcloc'
-
-
- filterByLines: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterByLines'
- @state.set 'activeHeaderItem', '.js-filter-lines'
-
-
- filterByNcloc: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterByNcloc'
- @state.set 'activeHeaderItem', '.js-filter-ncloc'
+++ /dev/null
-define [
- 'backbone.marionette'
- 'templates/component-viewer'
- 'component-viewer/header/base-header'
- 'component-viewer/time-changes-popup'
-], (
- Marionette
- Templates
- BaseHeaderView
- TimeChangesPopupView
-) ->
-
- $ = jQuery
-
-
- class extends BaseHeaderView
- template: Templates['cw-coverage-header']
-
-
- events:
- 'click .js-coverage-time-changes': 'coverageTimeChanges'
-
- 'click .js-filter-lines-to-cover': 'filterByLinesToCover'
- 'click .js-filter-uncovered-lines': 'filterByUncoveredLines'
- 'click .js-filter-branches-to-cover': 'filterByBranchesToCover'
- 'click .js-filter-uncovered-branches': 'filterByUncoveredBranches'
-
- 'click .js-filter-lines-to-cover-it': 'filterByLinesToCoverIT'
- 'click .js-filter-uncovered-lines-it': 'filterByUncoveredLinesIT'
- 'click .js-filter-branches-to-cover-it': 'filterByBranchesToCoverIT'
- 'click .js-filter-uncovered-branches-it': 'filterByUncoveredBranchesIT'
-
- 'click .js-filter-lines-to-cover-overall': 'filterByLinesToCoverOverall'
- 'click .js-filter-uncovered-lines-overall': 'filterByUncoveredLinesOverall'
- 'click .js-filter-branches-to-cover-overall': 'filterByBranchesToCoverOverall'
- 'click .js-filter-uncovered-branches-overall': 'filterByUncoveredBranchesOverall'
-
-
- coverageTimeChanges: (e) ->
- e.stopPropagation()
- $('body').click()
- popup = new TimeChangesPopupView
- triggerEl: $(e.currentTarget)
- main: @options.main
- bottom: true
- popup.render()
- popup.on 'change', (period) => @main.enablePeriod period, '.js-filter-lines-to-cover'
-
-
- filterByLinesToCover: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterByLinesToCover'
- @state.set 'activeHeaderItem', '.js-filter-lines-to-cover'
-
-
- filterByUncoveredLines: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterByUncoveredLines'
- @state.set 'activeHeaderItem', '.js-filter-uncovered-lines'
-
-
- filterByBranchesToCover: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterByBranchesToCover'
- @state.set 'activeHeaderItem', '.js-filter-branches-to-cover'
-
-
- filterByUncoveredBranches: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterByUncoveredBranches'
- @state.set 'activeHeaderItem', '.js-filter-uncovered-branches'
-
-
- filterByLinesToCoverIT: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterByLinesToCoverIT'
- @state.set 'activeHeaderItem', '.js-filter-lines-to-cover-it'
-
-
- filterByUncoveredLinesIT: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterByUncoveredLinesIT'
- @state.set 'activeHeaderItem', '.js-filter-uncovered-lines-it'
-
-
- filterByBranchesToCoverIT: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterByBranchesToCoverIT'
- @state.set 'activeHeaderItem', '.js-filter-branches-to-cover-it'
-
-
- filterByUncoveredBranchesIT: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterByUncoveredBranchesIT'
- @state.set 'activeHeaderItem', '.js-filter-uncovered-branches-it'
-
-
- filterByLinesToCoverOverall: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterByLinesToCoverOverall'
- @state.set 'activeHeaderItem', '.js-filter-lines-to-cover-overall'
-
-
- filterByUncoveredLinesOverall: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterByUncoveredLinesOverall'
- @state.set 'activeHeaderItem', '.js-filter-uncovered-lines-overall'
-
-
- filterByBranchesToCoverOverall: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterByBranchesToCoverOverall'
- @state.set 'activeHeaderItem', '.js-filter-branches-to-cover-overall'
-
-
- filterByUncoveredBranchesOverall: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterByUncoveredBranchesOverall'
- @state.set 'activeHeaderItem', '.js-filter-uncovered-branches-overall'
-
-
- serializeData: ->
- _.extend super, period: @state.get('period')?.toJSON()
+++ /dev/null
-define [
- 'backbone.marionette'
- 'templates/component-viewer'
- 'component-viewer/header/base-header'
-], (
- Marionette
- Templates
- BaseHeaderView
-) ->
-
- $ = jQuery
-
-
- class extends BaseHeaderView
- template: Templates['cw-duplications-header']
-
-
- events:
- 'click .js-filter-duplications': 'filterByDuplications'
-
-
- filterByDuplications: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterByDuplications'
- @state.set 'activeHeaderItem', '.js-filter-duplications'
+++ /dev/null
-define [
- 'backbone.marionette'
- 'templates/component-viewer'
- 'component-viewer/header/base-header'
- 'component-viewer/time-changes-popup'
-], (
- Marionette
- Templates
- BaseHeaderView
- TimeChangesPopupView
-) ->
-
- $ = jQuery
-
-
- class extends BaseHeaderView
- template: Templates['cw-issues-header']
-
-
- events:
- 'click .js-issues-bulk-change': 'issuesBulkChange'
- 'click .js-issues-time-changes': 'issuesTimeChanges'
-
- 'click .js-filter-current-issue': 'filterByCurrentIssue'
- 'click .js-filter-all-issues': 'filterByAllIssues'
- 'click .js-filter-rule': 'filterByRule'
- 'click .js-filter-fixed-issues': 'filterByFixedIssues'
- 'click .js-filter-unresolved-issues': 'filterByUnresolvedIssues'
- 'click .js-filter-false-positive-issues': 'filterByFalsePositiveIssues'
- 'click .js-filter-open-issues': 'filterByOpenIssues'
- 'click .js-filter-BLOCKER-issues': 'filterByBlockerIssues'
- 'click .js-filter-CRITICAL-issues': 'filterByCriticalIssues'
- 'click .js-filter-MAJOR-issues': 'filterByMajorIssues'
- 'click .js-filter-MINOR-issues': 'filterByMinorIssues'
- 'click .js-filter-INFO-issues': 'filterByInfoIssues'
-
-
- initialize: (options) ->
- super
- window.onBulkIssues = =>
- $('#modal').dialog 'close'
- options.main.requestIssues(options.main.key).done ->
- options.main.render()
-
-
- issuesBulkChange: ->
- issues = @source.get('activeIssues')?.map (issue) -> issue.key
- if issues.length > 0
- count = Math.min issues.length, 200
- url = "#{baseUrl}/issues/bulk_change_form?issues=#{_.first(issues, count).join()}"
- openModalWindow url, {}
-
-
- issuesTimeChanges: (e) ->
- e.stopPropagation()
- $('body').click()
- popup = new TimeChangesPopupView
- triggerEl: $(e.currentTarget)
- main: @options.main
- bottom: true
- prefix: t 'component_viewer.added'
- popup.render()
- popup.on 'change', (period) => @main.enablePeriod period, '.js-filter-unresolved-issues'
-
-
- filterByCurrentIssue: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterByCurrentIssue'
- @state.set 'activeHeaderItem', '.js-filter-current-issues'
-
-
- filterByAllIssues: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterByAllIssues'
- @state.set 'activeHeaderItem', '.js-filter-all-issues'
-
-
- filterByFixedIssues: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterByFixedIssues'
- @state.set 'activeHeaderItem', '.js-filter-fixed-issues'
-
-
- filterByUnresolvedIssues: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterByUnresolvedIssues'
- @state.set 'activeHeaderItem', '.js-filter-unresolved-issues'
-
-
- filterByFalsePositiveIssues: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterByFalsePositiveIssues'
- @state.set 'activeHeaderItem', '.js-filter-false-positive-issues'
-
-
- filterByOpenIssues: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterByOpenIssues'
- @state.set 'activeHeaderItem', '.js-filter-open-issues'
-
-
- filterByRule: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- rule = $(e.currentTarget).data 'rule'
- @header.filterLines e, 'filterByRule', rule
- @state.set 'activeHeaderItem', ".js-filter-rule[data-rule='#{rule}']"
- setTimeout (=> @scrollToRule rule), 0
-
-
- filterByBlockerIssues: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterByBlockerIssues'
- @state.set 'activeHeaderItem', '.js-filter-BLOCKER-issues'
-
-
- filterByCriticalIssues: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterByCriticalIssues'
- @state.set 'activeHeaderItem', '.js-filter-CRITICAL-issues'
-
-
- filterByMajorIssues: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterByMajorIssues'
- @state.set 'activeHeaderItem', '.js-filter-MAJOR-issues'
-
-
- filterByMinorIssues: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterByMinorIssues'
- @state.set 'activeHeaderItem', '.js-filter-MINOR-issues'
-
-
- filterByInfoIssues: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterByInfoIssues'
- @state.set 'activeHeaderItem', '.js-filter-INFO-issues'
-
-
- scrollToRule: (rule) ->
- ruleEl = @$('.js-filter-rule').filter("[data-rule=\"#{rule}\"]")
- container = ruleEl.closest '.component-viewer-header-expanded-bar-section-list'
- topOffset = ruleEl.offset().top - container.offset().top
- if topOffset > container.height()
- container.scrollTop topOffset
-
-
- serializeData: ->
- _.extend super,
- period: @state.get('period')?.toJSON()
- hasIssues: @state.get('severities')?.length || @state.get('rules')?.length
+++ /dev/null
-define [
- 'backbone.marionette'
- 'templates/component-viewer'
-], (
- Marionette
- Templates
-) ->
-
- $ = jQuery
-
-
- class extends Marionette.ItemView
- className: 'component-viewer-header-more-actions'
- template: Templates['cw-more-actions']
-
-
- events:
- 'click .js-new-window': 'openNewWindow'
- 'click .js-full-source': 'showFullSource'
- 'click .js-raw-source': 'showRawSource'
- 'click .js-extension': 'showExtension'
-
-
- onRender: ->
- $('body').on 'click.component-viewer-more-actions', =>
- $('body').off 'click.component-viewer-more-actions'
- @close()
-
-
- openNewWindow: ->
- @options.main.headerView.getPermalink()
-
-
- showFullSource: ->
- @options.main.showAllLines()
-
-
- showRawSource: ->
- @options.main.showRawSources()
-
- showExtension: (e) ->
- key = $(e.currentTarget).data 'key'
- @options.main.headerView.showExtension key
-
-
- serializeData: ->
- _.extend super,
- state: @options.main.state.toJSON()
+++ /dev/null
-define [
- 'backbone.marionette'
- 'templates/component-viewer'
- 'component-viewer/header/base-header'
- 'component-viewer/time-changes-popup'
-], (
- Marionette
- Templates
- BaseHeaderView
- TimeChangesPopupView
-) ->
-
- $ = jQuery
-
-
- class extends BaseHeaderView
- template: Templates['cw-scm-header']
-
-
- events:
- 'click .js-scm-time-changes': 'scmTimeChanges'
- 'click .js-filter-modified-lines': 'filterBySCM'
-
-
- scmTimeChanges: (e) ->
- e.stopPropagation()
- $('body').click()
- popup = new TimeChangesPopupView
- triggerEl: $(e.currentTarget)
- main: @options.main
- bottom: true
- popup.render()
- popup.on 'change', (period) => @main.enablePeriod period, '.js-filter-modified-lines'
-
-
- filterBySCM: (e) ->
- return @header.unsetFilter() if $(e.currentTarget).is('.active')
- @header.filterLines e, 'filterBySCM'
- @state.set 'activeHeaderItem', '.js-filter-modified-lines'
-
-
- serializeData: ->
- _.extend super, period: @state.get('period')?.toJSON()
+++ /dev/null
-define [
- 'backbone.marionette'
- 'templates/component-viewer'
- 'component-viewer/header/base-header'
- 'component-viewer/covered-files-popup'
-], (
- Marionette
- Templates
- BaseHeaderView
- CoveredFilesPopupView
-) ->
-
- $ = jQuery
- API_TESTS_COVERED_FILES = "#{baseUrl}/api/tests/covered_files"
-
-
- class extends BaseHeaderView
- template: Templates['cw-tests-header']
-
-
- ui:
- unitTests: '.js-unit-test'
-
-
- events:
- 'click @ui.unitTests': 'showCoveredFiles'
- 'click .js-sort-tests-duration': 'sortTestsByDuration'
- 'click .js-sort-tests-name': 'sortTestsByName'
-
-
- initialize: ->
- super
- @tests = _.sortBy @component.get('tests'), 'name'
- @activeSort = '.js-sort-tests-name'
-
-
- onRender: ->
- @header.enableUnitTest = (testName) =>
- test = @ui.unitTests.filter("[data-name=#{testName}]")
- container = test.closest '.component-viewer-header-expanded-bar-section-list'
- topOffset = test.offset().top - container.offset().top
- if topOffset > container.height()
- container.scrollTop topOffset
- test.click()
- @$(@activeSort).addClass 'active-link' if @activeSort
-
-
- onClose: ->
- delete @header.enableUnitTest
-
-
- showCoveredFiles: (e) ->
- e.stopPropagation()
- $('body').click()
- testName = $(e.currentTarget).data 'name'
- test = _.findWhere @component.get('tests'), name: testName
- key = @component.get('key')
- $.get API_TESTS_COVERED_FILES, key: key, test: testName, (data) =>
- popup = new CoveredFilesPopupView
- triggerEl: $(e.currentTarget)
- collection: new Backbone.Collection data.files
- test: test
- main: @main
- popup.render()
-
-
- sortTestsByDuration: ->
- @activeSort = '.js-sort-tests-duration'
- @tests = _.sortBy @tests, 'durationInMs'
- @render()
-
-
- sortTestsByName: ->
- @activeSort = '.js-sort-tests-name'
- @tests = _.sortBy @tests, 'name'
- @render()
-
-
- hasCoveragePerTestData: ->
- hasData = false
- @component.get('tests').forEach (test) ->
- hasData = true if test.coveredLines
- hasData
-
-
- serializeData: ->
- _.extend super,
- tests: @tests
- hasCoveragePerTestData: @hasCoveragePerTestData()
+++ /dev/null
-define [
- 'backbone.marionette'
- 'templates/component-viewer'
- 'common/popup'
- 'issue/manual-issue-view'
-], (
- Marionette
- Templates
- Popup
- ManualIssueView
-) ->
-
- $ = jQuery
-
-
- class extends Popup
- template: Templates['cw-line-options-popup']
-
-
- events:
- 'click .js-get-permalink': 'getPermalink'
- 'click .js-add-manual-issue': 'addManualIssue'
-
-
- onRender: ->
- source = @options.main.sourceView.$el
- sourceOffset = source.offset()
- trigger = @options.triggerEl
- triggerOffset = trigger.offset()
- @$el.detach().appendTo(source).css
- top: triggerOffset.top - sourceOffset.top + source.scrollTop()
- left: triggerOffset.left - sourceOffset.left + source.scrollLeft() + trigger.outerWidth()
- @attachCloseEvents()
-
-
- getPermalink: (e) ->
- e.preventDefault()
- @options.main.headerView.getPermalink()
-
-
- addManualIssue: (e) ->
- e.preventDefault()
- line = @options.row.data 'line-number'
- component = @options.main.component.get 'key'
- manualIssueView = new ManualIssueView
- line: line
- component: component
- rules: @options.main.state.get 'manual_rules'
- manualIssueView.render().$el.appendTo @options.row.find('.source-line-code')
- manualIssueView.on 'add', (issue) =>
- issues = @options.main.source.get('issues') || []
- activeIssues = @options.main.source.get('activeIssues') || []
- showIssues = @options.main.settings.get 'issues'
- issues.push issue
- if showIssues then activeIssues.push issue else activeIssues = [issue]
- @options.main.source.set 'issues', issues
- @options.main.source.set 'activeIssues', activeIssues
- @options.main.settings.set 'issues', true
- @options.main.sourceView.render()
-
-
- serializeData: ->
- _.extend super,
- state: @options.main.state.toJSON()
+++ /dev/null
-define [
- 'backbone'
- 'backbone.marionette'
- 'templates/component-viewer'
-
- 'component-viewer/models/state'
- 'component-viewer/models/component'
- 'component-viewer/models/period'
-
- 'component-viewer/mixins/main-issues'
- 'component-viewer/mixins/main-coverage'
- 'component-viewer/mixins/main-duplications'
- 'component-viewer/mixins/main-scm'
-
- 'component-viewer/workspace'
- 'component-viewer/source'
- 'component-viewer/header'
- 'component-viewer/utils'
-], (
- Backbone
- Marionette
- Templates
-
- State
- Component
- Period
-
- IssuesMixin
- CoverageMixin
- DuplicationsMixin
- SCMMixin
-
- WorkspaceView
- SourceView
- HeaderView
- utils
-) ->
-
- $ = jQuery
-
- API_COMPONENT = "#{baseUrl}/api/components/app"
- API_SOURCES = "#{baseUrl}/api/sources/show"
- API_RAW_SOURCES = "#{baseUrl}/api/sources/raw"
- API_MEASURES = "#{baseUrl}/api/resources"
- API_TESTS = "#{baseUrl}/api/tests/show"
-
- SOURCE_METRIC_LIST = 'accessors,classes,functions,statements,' +
- 'ncloc,ncloc_data,lines,generated_ncloc,generated_lines,' +
- 'complexity,function_complexity,' +
- 'comment_lines,comment_lines_density,public_api,public_undocumented_api,public_documented_api_density'
-
- COVERAGE_METRIC_LIST = 'coverage,line_coverage,lines_to_cover,covered_lines,uncovered_lines,' +
- 'branch_coverage,conditions_to_cover,uncovered_conditions,' +
- 'it_coverage,it_line_coverage,it_lines_to_cover,it_covered_lines,it_uncovered_lines,' +
- 'it_branch_coverage,it_conditions_to_cover,it_uncovered_conditions,' +
- 'overall_coverage,overall_line_coverage,overall_lines_to_cover,overall_covered_lines,overall_uncovered_lines,' +
- 'overall_branch_coverage,overall_conditions_to_cover,overall_uncovered_conditions'
-
- ISSUES_METRIC_LIST = 'blocker_violations,critical_violations,major_violations,minor_violations,info_violations,' +
- 'false_positive_issues'
-
- DUPLICATIONS_METRIC_LIST = 'duplicated_lines_density,duplicated_blocks,duplicated_files,duplicated_lines'
-
- TESTS_METRIC_LIST = 'tests,test_success_density,test_failures,test_errors,skipped_tests,test_execution_time'
-
- SCROLL_OFFSET = 10
-
- LINES_LIMIT = 3000
-
-
-
- class ComponentViewer extends utils.mixOf Marionette.Layout, IssuesMixin, CoverageMixin, DuplicationsMixin, SCMMixin
- className: 'component-viewer'
- template: Templates['cw-layout']
-
-
- regions:
- workspaceRegion: '.component-viewer-workspace'
- headerRegion: '.component-viewer-header'
- sourceRegion: '.component-viewer-source'
-
-
- initialize: (options) ->
- @settings = new Backbone.Model @getDefaultSettings()
- if options.settings?
- options.settings = JSON.parse(options.settings) if typeof options.settings == 'string'
- @settings.set options.settings
- @settings.set 'scm', !!localStorage.getItem('componentViewerSCM')
- @shouldStoreSettings = options.shouldStoreSettings
- @elementToFit = options.elementToFit
-
- @state = new State()
-
- @component = new Component()
- @component.set options.component if options.component?
-
- @workspace = new Backbone.Collection()
- @workspaceView = new WorkspaceView
- collection: @workspace
- main: @
-
- @source = new Backbone.Model()
- @sourceView = new SourceView
- model: @source
- main: @
-
- @headerView = new HeaderView
- model: @source
- main: @
-
- @periods = new Backbone.Collection [], model: Period
-
-
- getDefaultSettings: ->
- issues: false
- coverage: false
- duplications: false
- scm: false
- workspace: false
-
-
- storeSettings: ->
- scm = if @settings.get('scm') then 'scm' else ''
- localStorage.setItem 'componentViewerSCM', scm
- if @shouldStoreSettings
- localStorage.setItem 'componentViewerSettings', JSON.stringify @settings.toJSON()
-
-
- fitIntoElement: ->
- return unless @elementToFit
- source = @$(@sourceRegion.$el)
- workspace = @$(@workspaceRegion.$el)
-
- width = @elementToFit.width()
- height = @elementToFit.height()
- return if width == 0 || height == 0
-
- availableWidth = width - workspace.outerWidth(true) - 20
- availableHeight = height - @$(@headerRegion.$el).outerHeight(true)
-
- source.removeClass 'overflow'
- source.width(availableWidth).height availableHeight
- source.addClass 'overflow'
- workspace.removeClass 'overflow'
- workspace.height availableHeight
- workspace.addClass 'overflow'
-
-
- onRender: ->
- @workspaceRegion.show @workspaceView
- @$el.toggleClass 'component-viewer-workspace-enabled', @settings.get 'workspace'
- @sourceRegion.show @sourceView
- @headerRegion.show @headerView
- @fitIntoElement()
- resizeEvent = 'resize.componentViewer'
- $(window).off(resizeEvent).on resizeEvent, =>
- setTimeout (=> @fitIntoElement()), 100
-
-
- requestComponent: (key, clear = false, full = true) ->
- STATE_FIELDS = ['canBulkChange', 'canMarkAsFavourite', 'canCreateManualIssue',
- 'tabs', 'manual_rules', 'extensions']
- COMPONENT_FIELDS = ['key', 'longName', 'name', 'path', 'q', 'project', 'projectName', 'subProject',
- 'subProjectName', 'measures', 'fav']
-
- $.get API_COMPONENT, key: key, (data) =>
- # Component
- @component.clear() if clear
- COMPONENT_FIELDS.forEach (f) => @component.set f, data[f]
- if data.path?
- @component.set 'dir', utils.splitLongName(data.path).dir
- @component.set 'isUnitTest', data.q == 'UTS'
-
-
- # State
- stateAttributes = {}
- STATE_FIELDS.forEach (f) -> stateAttributes[f] = data[f]
- rules = data.rules.map (r) -> key: r[0], name: r[1], count: r[2]
- stateAttributes.rules = _.sortBy rules, 'name'
- severities = data.severities.map (r) -> key: r[0], name: r[1], count: r[2]
- stateAttributes.severities = utils.sortSeverities severities
- if full
- @state.clear silent: true
- @state.set _.defaults stateAttributes, @state.defaults
- else
- @state.set stateAttributes
-
- if full
- # Periods
- @periods.reset [{label: t('none')}]
- data.periods.forEach (p) =>
- d = moment p[2]
- p = @periods.add key: p[0], label: p[1], sinceDate: d.toDate()
-
-
- requestMeasures: (key, period = null) ->
- @state.set 'hasMeasures', true
- return @requestTrends(key, period) if period?
- unless @component.get 'isUnitTest'
- metrics = [SOURCE_METRIC_LIST, COVERAGE_METRIC_LIST, ISSUES_METRIC_LIST, DUPLICATIONS_METRIC_LIST].join ','
- else
- metrics = [ISSUES_METRIC_LIST, TESTS_METRIC_LIST].join ','
- data = resource: key, metrics: metrics
- $.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
- if lines < LINES_LIMIT
- @augmentWithNclocData()
- else
- delete measures['ncloc_data']
-
-
- requestTrends: (key, period) ->
- unless @component.get 'isUnitTest'
- metrics = COVERAGE_METRIC_LIST
- else
- metrics = ''
- metrics = metrics.split(',').map((m) -> "new_#{m}").join ','
- data = resource: key, metrics: metrics, includetrends: true
- $.get API_MEASURES, data, (data) =>
- measuresList = data[0].msr || []
- measures = @component.get 'measures'
- measuresList.forEach (m) ->
- key = m.key.substr(4)
- variation = "fvar#{period}"
- measures[key] = m[variation]
- @component.set 'measures', measures
-
-
- requestSource: (key) ->
- $.get API_SOURCES, key: key, (data) =>
- @source.clear()
- formattedSource = _.map data.sources, (item) => lineNumber: item[0], code: item[1]
- @source.set
- source: data.sources
- formattedSource: formattedSource
-
-
- augmentWithNclocData: ->
- nclocDataRaw = @component.has('measures') && @component.get('measures')['ncloc_data']
- if nclocDataRaw?
- formattedSource = @source.get 'formattedSource'
- nclocData = nclocDataRaw.split(';').map (item) ->
- tokens = item.split '='
- lineNumber: +tokens[0]
- executable: tokens[1] == '1'
- nclocData.forEach (n) ->
- line = _.findWhere formattedSource, lineNumber: n.lineNumber
- line.executable = n.executable
- @source.set 'formattedSource', formattedSource
-
-
- requestTests: (key) ->
- $.get API_TESTS, key: key, (data) =>
- @state.set 'hasTests', true
- @component.set 'tests', _.sortBy data.tests, 'name'
-
-
- open: (key) ->
- @workspace.reset []
- @_open key, false
-
-
- _open: (key, showFullSource = true) ->
- @key = key
- @sourceView.showSpinner()
- source = @requestSource key
- component = @requestComponent key
- @currentIssue = null
- component.done =>
- @updateWorkspaceComponents()
- @state.set 'removed', false
- source.always =>
- if source.status == 403
- @state.set 'sourceSecurity', true
- @state.set 'hasSource', (source.status != 404)
- @render()
- @showAllLines() if showFullSource
- if @settings.get('issues')
- @showIssues()
- else
- @hideIssues()
- @trigger 'sized'
- if @settings.get('coverage') then @showCoverage() else @hideCoverage()
- if @settings.get('duplications') then @showDuplications() else @hideDuplications()
- if @settings.get('scm') then @showSCM() else @hideSCM()
- @trigger 'loaded'
- .fail (r) =>
- if component.status == 404
- @state.set 'removed', true
- @state.set 'removedMessage', _.pluck(r.responseJSON.errors, 'msg').join '. '
- @state.set 'hasSource', false
- @render()
- @trigger 'loaded'
- else @cannotOpen()
-
-
- updateWorkspaceComponents: ->
- @workspace.where(key: @component.get('key')).forEach (model) =>
- model.set 'component': @component.toJSON()
-
- @workspace.each (w) =>
- options = w.get('options')
- _.where(options, key: @component.get('key')).forEach (model) =>
- model.component = @component.toJSON()
- w.set 'options', options
-
-
- cannotOpen: ->
- @$el.html "<div class='message-error'>#{t 'component_viewer.cannot_show'}</div>"
-
-
- toggleWorkspace: (store = false) ->
- if @settings.get 'workspace' then @hideWorkspace() else @showWorkspace()
- @fitIntoElement()
- @storeSettings() if store
-
-
- showWorkspace: (store = false) ->
- @settings.set 'workspace', true
- @storeSettings() if store
- @$el.addClass 'component-viewer-workspace-enabled'
- @workspaceView.render()
-
-
- hideWorkspace: (store = false) ->
- @settings.set 'workspace', false
- @storeSettings() if store
- @$el.removeClass 'component-viewer-workspace-enabled'
- @workspaceView.render()
-
-
- showAllLines: ->
- @sourceView.resetShowBlocks()
- @sourceView.showBlocks.push from: 0, to: _.size @source.get 'source'
- @sourceView.render()
-
-
- hideAllLines: ->
- @sourceView.resetShowBlocks()
- @sourceView.render()
-
-
- showRawSources: ->
- key = encodeURIComponent @component.get 'key'
- url = "#{API_RAW_SOURCES}?key=#{key}"
- location.href = url
-
-
- enablePeriod: (periodKey, activeHeaderItem) ->
- period = if periodKey == '' then null else @periods.findWhere key: periodKey
- @state.set 'period', period
- $.when(@requestMeasures(@key, period?.get('key')), @requestIssuesPeriod(@key, period?.get('key')), @requestSCM(@key)).done =>
- if activeHeaderItem?
- @state.set 'activeHeaderItem', activeHeaderItem
- @headerView.render()
-
-
- addTransition: (transition, options) ->
- @workspace.add
- key: @component.get 'key'
- component: @component.toJSON()
- transition: transition
- options: options
- active: false
-
-
- scrollToLine: (line) ->
- row = @sourceView.$(".source-line[data-line-number=#{line}]")
- unless row.length > 0
- unless @scrolled
- setTimeout (=> @scrollToLine(line)), 100
- return
- @scrolled = line
- d = row.offset().top - @$(@sourceRegion.$el).offset().top + @$(@sourceRegion.$el).scrollTop() - SCROLL_OFFSET
- @scrollPlusDelta d
-
-
- scrollPlusDelta: (delta) ->
- @$(@sourceRegion.$el).scrollTop delta
-
-
- _filterByLines: (predicate) ->
- formattedSource = @source.get 'formattedSource'
- @sourceView.resetShowBlocks()
- formattedSource.forEach (line) =>
- if predicate line
- ln = line.lineNumber
- @sourceView.addShowBlock ln, ln
- @sourceView.render()
-
-
- filterByLines: ->
- @resetIssues()
- @showAllLines()
-
-
- filterByNcloc: ->
- @resetIssues()
- @_filterByLines (line) -> line?.executable
+++ /dev/null
-define [], () ->
-
- $ = jQuery
- API_COVERAGE = "#{baseUrl}/api/coverage/show"
- LINES_AROUND_COVERED_LINE = 1
-
-
- class CoverageMixin
-
- requestCoverage: (key, type = 'UT') ->
- $.get API_COVERAGE, key: key, type: type, (data) =>
- return unless data?.coverage?
- @state.set 'hasCoverage', true
- @source.set coverage: data.coverage
- @augmentWithCoverage data.coverage
-
-
- augmentWithCoverage: (coverage) ->
- formattedSource = @source.get 'formattedSource'
- coverage.forEach (c) ->
- line = _.findWhere formattedSource, lineNumber: c[0]
- return unless line?
- line.coverage =
- covered: c[1]
- testCases: c[2]
- branches: c[3]
- coveredBranches: c[4]
- line.coverageStatus = 'partially-covered'
- line.coverageStatus = 'covered' if c[1] && c[3] == c[4]
- line.coverageStatus = 'uncovered' if !c[1] || c[4] == 0
- if line.coverage.branches? && line.coverage.coveredBranches?
- line.coverage.branchCoverageStatus = 'covered' if line.coverage.branches == line.coverage.coveredBranches
- line.coverage.branchCoverageStatus = 'partially-covered' if line.coverage.branches > line.coverage.coveredBranches
- line.coverage.branchCoverageStatus = 'uncovered' if line.coverage.coveredBranches == 0
- @source.set 'formattedSource', formattedSource
-
-
- showCoverage: (store = false) ->
- @settings.set 'coverage', true
- @storeSettings() if store
- unless @state.get 'hasCoverage'
- @requestCoverage(@key).done => @sourceView.render()
- else
- @sourceView.render()
-
-
- hideCoverage: (store = false) ->
- @settings.set 'coverage', false
- @storeSettings() if store
- @sourceView.render()
-
-
- filterByCoverage: (predicate) ->
- requests = [@requestCoverage(@key)]
- if @settings.get('issues') && !@state.get('hasIssues')
- requests.push @requestIssues @key
- $.when.apply($, requests).done =>
- @resetIssues()
- @_filterByCoverage(predicate)
-
-
- filterByCoverageIT: (predicate) ->
- requests = [@requestCoverage(@key, 'IT')]
- if @settings.get('issues') && !@state.get('hasIssues')
- requests.push @requestIssues @key
- $.when.apply($, requests).done =>
- @resetIssues()
- @_filterByCoverage(predicate)
-
-
- filterByCoverageOverall: (predicate) ->
- requests = [@requestCoverage(@key, 'OVERALL')]
- if @settings.get('issues') && !@state.get('hasIssues')
- requests.push @requestIssues @key
- $.when.apply($, requests).done =>
- @resetIssues()
- @_filterByCoverage(predicate)
-
-
- _filterByCoverage: (predicate) ->
- period = @state.get('period')
- if period
- periodDate = period.get 'sinceDate'
- p = predicate
- predicate = (line) =>
- line?.scm?.date? && (new Date(line.scm.date) >= periodDate) && p(line)
-
- formattedSource = @source.get 'formattedSource'
- @settings.set 'coverage', true
- @sourceView.resetShowBlocks()
- formattedSource.forEach (line) =>
- if predicate line
- ln = line.lineNumber
- @sourceView.addShowBlock ln - LINES_AROUND_COVERED_LINE, ln + LINES_AROUND_COVERED_LINE
- @sourceView.render()
-
-
- # Unit Tests
- filterByLinesToCover: ->
- @filterByCoverage (line) -> line?.coverage?.covered?
-
-
- filterByUncoveredLines: ->
- @filterByCoverage (line) -> line?.coverage?.covered? && !line.coverage.covered
-
-
- filterByBranchesToCover: ->
- @filterByCoverage (line) -> line?.coverage?.branches?
-
-
- filterByUncoveredBranches: ->
- @filterByCoverage (line) -> line?.coverage?.branches? && line.coverage.coveredBranches? &&
- line.coverage.branches > line.coverage.coveredBranches
-
-
- # Integration Tests
- filterByLinesToCoverIT: ->
- @filterByCoverageIT (line) -> line?.coverage?.covered?
-
-
- filterByUncoveredLinesIT: ->
- @filterByCoverageIT (line) -> line?.coverage?.covered? && !line.coverage.covered
-
-
- filterByBranchesToCoverIT: ->
- @filterByCoverageIT (line) -> line?.coverage?.branches?
-
-
- filterByUncoveredBranchesIT: ->
- @filterByCoverageIT (line) -> line?.coverage?.branches? && line.coverage.coveredBranches? &&
- line.coverage.branches > line.coverage.coveredBranches
-
-
- # Overall
- filterByLinesToCoverOverall: ->
- @filterByCoverageOverall (line) -> line?.coverage?.covered?
-
-
- filterByUncoveredLinesOverall: ->
- @filterByCoverageOverall (line) -> line?.coverage?.covered? && !line.coverage.covered
-
-
- filterByBranchesToCoverOverall: ->
- @filterByCoverageOverall (line) -> line?.coverage?.branches?
-
-
- filterByUncoveredBranchesOverall: ->
- @filterByCoverageOverall (line) -> line?.coverage?.branches? && line.coverage.coveredBranches? &&
- line.coverage.branches > line.coverage.coveredBranches
+++ /dev/null
-define [], () ->
-
- $ = jQuery
- API_DUPLICATIONS = "#{baseUrl}/api/duplications/show"
- LINES_AROUND_DUPLICATION = 1
-
-
- class DuplicationsMixin
-
- requestDuplications: (key) ->
- $.get API_DUPLICATIONS, key: key, (data) =>
- return unless data?.duplications?
- @state.set 'hasDuplications', true
- @source.set duplications: data.duplications
- @source.set duplicationFiles: data.files
- @skipRemovedFiles()
- @augmentWithDuplications data.duplications
-
-
- skipRemovedFiles: ->
- duplications = @source.get 'duplications'
- deletedFiles = false
- duplications = _.map duplications, (d) ->
- blocks = _.filter d.blocks, (b) -> b._ref
- deletedFiles = true if blocks.length != d.blocks.length
- blocks: blocks
- @source.set 'duplications', duplications
- @state.set 'duplicationsInDeletedFiles', deletedFiles
-
-
- augmentWithDuplications: (duplications) ->
- formattedSource = @source.get 'formattedSource'
- return unless formattedSource
- formattedSource.forEach (line) ->
- lineDuplications = []
- duplications.forEach (d, i) ->
- duplicated = false
- d.blocks.forEach (b) ->
- if b._ref == '1'
- lineFrom = b.from
- lineTo = b.from + b.size
- duplicated = true if line.lineNumber >= lineFrom && line.lineNumber <= lineTo
- lineDuplications.push if duplicated then i + 1 else false
- line.duplications = lineDuplications
- @source.set 'formattedSource', formattedSource
-
-
- showDuplications: (store = false) ->
- @settings.set 'duplications', true
- @storeSettings() if store
- unless @state.get 'hasDuplications'
- @requestDuplications(@key).done => @sourceView.render()
- else
- @sourceView.render()
-
-
- hideDuplications: (store = false) ->
- @settings.set 'duplications', false
- @storeSettings() if store
- @sourceView.render()
-
-
- # Duplications
- filterByDuplications: ->
- requests = [@requestDuplications(@key)]
- if @settings.get('issues') && !@state.get('hasIssues')
- requests.push @requestIssues @key
- $.when.apply($, requests).done =>
- @_filterByDuplications()
-
-
- _filterByDuplications: ->
- duplications = @source.get 'duplications'
- @settings.set 'duplications', true
- @sourceView.resetShowBlocks()
- duplications.forEach (d) =>
- d.blocks.forEach (b) =>
- if b._ref == '1'
- lineFrom = b.from
- lineTo = b.from + b.size
- @sourceView.addShowBlock lineFrom - LINES_AROUND_DUPLICATION, lineTo + LINES_AROUND_DUPLICATION
- @sourceView.render()
+++ /dev/null
-define [
- 'component-viewer/utils'
-], (
- utils
-) ->
-
- $ = jQuery
- API_COMPONENT = "#{baseUrl}/api/components/app"
- API_ISSUES = "#{baseUrl}/api/issues/search"
- LINES_AROUND_ISSUE = 4
-
-
- class IssuesMixin
-
- requestIssues: (key) ->
- options =
- components: key
- ignorePaging: true
- extra_fields: 'actions,transitions,assigneeName,actionPlanName'
- $.get API_ISSUES, options, (data) =>
- @state.set 'hasIssues', true
- issues = _.sortBy data.issues, (issue) -> "#{issue.rule}_____#{issue.message}"
- @source.set issues: issues
- @resetIssues()
-
-
- resetIssues: ->
- issues = @source.get('issues')
- if _.isArray issues
- @source.set
- activeIssues: issues.filter (issue) -> !issue.resolution
-
-
- showIssues: (store = false, issue) ->
- @settings.set 'issues', true
- @storeSettings() if store
- if issue?
- @currentIssue = issue.key
- @source.set 'issues', [issue]
- @filterByCurrentIssue()
- @headerView.render()
- @trigger 'sized'
- else
- unless @state.get 'hasIssues'
- @requestIssues(@key).done =>
- @sourceView.render()
- @trigger 'sized'
- else
- @sourceView.render()
- @trigger 'sized'
-
-
- hideIssues: (store = false) ->
- @settings.set 'issues', false
- @storeSettings() if store
- @sourceView.render()
-
-
- requestIssuesPeriod: (key, period) ->
- params = key: key
- params.period = period if period?
- $.get API_COMPONENT, params, (data) =>
- rules = data.rules.map (r) -> key: r[0], name: r[1], count: r[2]
- severities = data.severities.map (r) -> key: r[0], name: r[1], count: r[2]
- @state.set
- rules: _.sortBy(rules, 'name')
- severities: utils.sortSeverities(severities)
-
-
- filterLinesByIssues: ->
- issues = @source.get 'issues'
- @sourceView.resetShowBlocks()
- issues.forEach (issue) =>
- line = issue.line || 0
- if issue.status == 'CLOSED'
- @sourceView.addShowBlock 0, 0, true
- else
- @sourceView.addShowBlock line - LINES_AROUND_ISSUE, line + LINES_AROUND_ISSUE, line == 0
- @sourceView.render()
-
-
- filterByIssues: (predicate, requestIssues = true) ->
- period = @state.get('period')
- if period
- p = predicate
- predicate = (issue) =>
- creationDate = new Date moment(issue.creationDate).format()
- (creationDate > period.get('sinceDate')) && p issue
-
- if requestIssues && !@state.get 'hasIssues'
- @requestIssues(@key).done => @_filterByIssues(predicate)
- else
- @_filterByIssues(predicate)
-
-
- _filterByIssues: (predicate) ->
- issues = @source.get 'issues'
- @settings.set 'issues', true
- @sourceView.resetShowBlocks()
- activeIssues = []
- issues.forEach (issue) =>
- if predicate issue
- line = issue.line || 0
- if issue.status == 'CLOSED'
- @sourceView.addShowBlock 0, 0, true
- else
- @sourceView.addShowBlock line - LINES_AROUND_ISSUE, line + LINES_AROUND_ISSUE, line == 0
- activeIssues.push issue
- @source.set 'activeIssues', activeIssues
- @sourceView.render()
-
-
- # Current Issue
- filterByCurrentIssue: -> @filterByIssues ((issue) => issue.key == @currentIssue), false
-
-
- # All Issues
- filterByAllIssues: -> @filterByIssues -> true
-
- # Resolved Issues
- filterByFixedIssues: -> @filterByIssues (issue) -> issue.resolution == 'FIXED'
-
- # Unresolved Issues
- filterByUnresolvedIssues: -> @filterByIssues (issue) -> !issue.resolution
-
- # False Positive
- filterByFalsePositiveIssues: -> @filterByIssues (issue) -> issue.resolution == 'FALSE-POSITIVE'
-
- # Open/Reopened Issues
- filterByOpenIssues: -> @filterByIssues (issue) -> issue.status == 'OPEN' || issue.status == 'REOPENED'
-
- # Rule
- filterByRule: (rule) -> @filterByIssues (issue) -> issue.rule == rule && !issue.resolution
-
- # Severity
- filterByBlockerIssues: -> @filterByIssues (issue) -> issue.severity == 'BLOCKER' && !issue.resolution
- filterByCriticalIssues: -> @filterByIssues (issue) -> issue.severity == 'CRITICAL' && !issue.resolution
- filterByMajorIssues: -> @filterByIssues (issue) -> issue.severity == 'MAJOR' && !issue.resolution
- filterByMinorIssues: -> @filterByIssues (issue) -> issue.severity == 'MINOR' && !issue.resolution
- filterByInfoIssues: -> @filterByIssues (issue) -> issue.severity == 'INFO' && !issue.resolution
+++ /dev/null
-define [], () ->
-
- $ = jQuery
- API_SCM = "#{baseUrl}/api/sources/scm"
-
-
- class SCMMixin
-
- requestSCM: (key) ->
- $.get API_SCM, key: key, (data) =>
- if data?.scm?
- @state.set 'hasSCM', true
- @source.set scm: data.scm
- @augmentWithSCM data.scm
-
-
- augmentWithSCM: (scm) ->
- formattedSource = @source.get 'formattedSource'
- scmLength = scm.length
- if scmLength > 0
- scmIndex = 0
- scmCurrent = scm[scmIndex]
- scmDetails = {}
- formattedSource.forEach (line) ->
- if line.lineNumber == scmCurrent[0]
- scmDetails = author: scmCurrent[1], date: scmCurrent[2]
- if scmIndex < scmLength - 1
- scmIndex++
- scmCurrent = scm[scmIndex]
- line.scm = scmDetails
- @source.set 'formattedSource', formattedSource
-
-
-
- showSCM: (store = false) ->
- @settings.set 'scm', true
- @storeSettings() if store
- unless @state.get 'hasSCM'
- @requestSCM(@key).done => @sourceView.render()
- else
- @sourceView.render()
-
-
- hideSCM: (store = false) ->
- @settings.set 'scm', false
- @storeSettings() if store
- @sourceView.render()
-
-
- filterByModifiedLines: ->
- @filterBySCM()
-
-
- filterBySCM: ->
- requests = [@requestSCM(@key)]
- if @settings.get('issues') && !@state.get('hasIssues')
- requests.push @requestIssues @key
- $.when.apply($, requests).done =>
- @_filterBySCM()
-
-
- _filterBySCM: () ->
- formattedSource = @source.get 'formattedSource'
- period = @state.get 'period'
- @settings.set 'scm', true
- unless period?
- return @showAllLines()
- else
- periodDate = period.get 'sinceDate'
- @sourceView.resetShowBlocks()
- scmBlockLine = 1
- predicate = false
- formattedSource.forEach (line) =>
- scmBlockDate = new Date line.scm.date
- if scmBlockDate >= periodDate
- scmBlockLine = line.lineNumber if predicate == false
- predicate = true
- else if predicate == true
- predicate = false
- @sourceView.addShowBlock scmBlockLine, line.lineNumber - 1
- if predicate
- @sourceView.addShowBlock scmBlockLine, _.size @source.get 'source'
- @sourceView.render()
+++ /dev/null
-define [
- 'backbone'
-], (
- Backbone
-) ->
-
-
- class Component extends Backbone.Model
\ No newline at end of file
+++ /dev/null
-define [
- 'backbone'
-], (
- Backbone
-) ->
-
-
- class Period extends Backbone.Model
-
- defaults:
- key: ''
- sinceDate: null
+++ /dev/null
-define [
- 'backbone'
-], (
- Backbone
-) ->
-
-
- class State extends Backbone.Model
-
- defaults:
- hasMeasures: false
- hasIssues: false
- hasCoverage: false
- hasITCoverage: false
- hasDuplications: false
- hasTests: false
- hasSCM: false
-
- activeHeaderTab: null
\ No newline at end of file
+++ /dev/null
-define [
- 'backbone.marionette'
- 'templates/component-viewer'
- 'source-viewer/popups/scm-popup'
- 'component-viewer/coverage-popup'
- 'component-viewer/duplication-popup'
- 'component-viewer/time-changes-popup'
- 'component-viewer/line-actions-popup'
- 'issue/issue-view'
- 'issue/models/issue'
- 'common/handlebars-extensions'
-], (
- Marionette
- Templates
- SCMPopupView
- CoveragePopupView
- DuplicationPopupView
- TimeChangesPopupView
- LineActionsPopupView
- IssueView
- Issue
-) ->
-
- $ = jQuery
-
- API_COVERAGE_TESTS = "#{baseUrl}/api/tests/test_cases"
- ISSUES_LIMIT = 100
-
-
- class SourceView extends Marionette.ItemView
- template: Templates['cw-source']
- expandTemplate: Templates['cw-code-expand']
-
- LINES_AROUND_ISSUE = 4
- LINES_AROUND_COVERED_LINE = 1
- EXPAND_LINES = 20
- HIGHLIGHTED_ROW_CLASS = 'source-line-highlighted'
-
-
- events:
- 'click .sym': 'highlightUsages'
-
- 'click .js-line-actions': 'highlightLine'
-
- 'click .source-line-scm': 'showSCMPopup'
-
- 'click .source-line-covered': 'showCoveragePopup'
- 'click .source-line-partially-covered': 'showCoveragePopup'
- 'click .source-line-uncovered': 'showCoveragePopup'
-
- 'click .source-line-duplications-extra': 'showDuplicationPopup'
-
- 'click .js-expand': 'expandBlock'
- 'click .js-expand-all': 'expandAll'
-
- 'click .js-time-changes': 'toggleTimeChangePopup'
-
-
- initialize: ->
- super
- @showBlocks = []
-
-
- resetShowBlocks: ->
- @showBlocks = []
- @options.main.trigger 'resetShowBlocks'
-
-
- addShowBlock: (from, to, forceIncludeZero = false) ->
- if from <= 0 && !forceIncludeZero
- from = 1
- @showBlocks.push from: from, to: to
-
-
- onRender: ->
- @delegateEvents()
- @showSettings = false
- @renderExpandButtons()
- @renderIssues() if @options.main.settings.get('issues') && @model.has('activeIssues')
- @highlightCurrentLine()
-
-
- renderExpandButtons: ->
- rows = @$('.source-line[data-line-number]')
- rows.get().forEach (row) =>
- line = $(row).data 'line-number'
- linePrev = $(row).prev('[data-line-number]').data 'line-number'
- if line? && linePrev? && (linePrev + 1) < line
- expand = @expandTemplate
- from: linePrev
- to: line
- settings: @options.main.settings.toJSON()
- baseDuplications: @getBaseDuplications()
- $(expand).insertBefore $(row)
-
- firstShown = rows.first().data('line-number')
- if firstShown > 1
- expand = @expandTemplate
- from: firstShown - EXPAND_LINES
- to: firstShown
- settings: @options.main.settings.toJSON()
- baseDuplications: @getBaseDuplications()
- $(expand).insertBefore rows.first()
-
- lines = _.size @model.get 'source'
- lastShown = rows.last().data('line-number')
- if lastShown < lines
- expand = @expandTemplate
- from: lastShown
- to: lines
- settings: @options.main.settings.toJSON()
- baseDuplications: @getBaseDuplications()
- $(expand).insertAfter rows.last()
-
- @delegateEvents()
-
-
- renderIssues: ->
- issues = @model.get 'activeIssues'
- issues = _.sortBy issues, 'line'
- rendered = 0
- issues.forEach (issue) =>
- line = issue.line || 0
- line = 0 if issue.status == 'CLOSED'
- row = @$("##{@cid}-#{line}")
- unless row.length > 0
- line = 0
- row = @$("##{@cid}-#{line}")
- if row.length > 0
- rendered += 1
- row.removeClass 'hidden'
- container = row.children('.source-line-code')
- container.addClass 'has-issues' if line > 0
- if rendered < ISSUES_LIMIT
- issueModel = new Issue issue
- issueView = new IssueView model: issueModel
- issues = container.find '.issue-list'
- if issues.length == 0
- issues = $('<div class="issue-list"></div>').appendTo container
- issueView.render().$el.appendTo issues
- issueView.$el.prop('id', "issue-#{issue.key}").data('issue-key', issue.key)
- issueView.on 'reset', =>
- @updateIssue issueModel
- @options.main.requestComponent(@options.main.key, false, false).done =>
- @options.main.headerView.silentUpdate = true
- @options.main.headerView.render()
- else
- row.prop 'title', tp('component_viewer.issues_limit_reached_tooltip', issue.message)
-
-
- updateIssue: (issueModel) ->
- issues = @model.get 'issues'
- issues = _.reject issues, (issue) -> issue.key == issueModel.get('key')
- issues.push issueModel.toJSON()
- @model.set 'issues', issues
-
- issues = @model.get 'activeIssues'
- issues = _.reject issues, (issue) -> issue.key == issueModel.get('key')
- issues.push issueModel.toJSON()
- @model.set 'activeIssues', issues
-
-
- showSpinner: ->
- @$el.html '<div style="padding: 10px;"><i class="spinner"></i></div>'
-
-
- showLineActionsPopup: (e) ->
- e.stopPropagation()
- $('body').click()
- popup = new LineActionsPopupView
- triggerEl: $(e.currentTarget)
- main: @options.main
- row: $(e.currentTarget).closest '.source-line'
- popup.render()
-
-
- highlightLine: (e) ->
- row = $(e.currentTarget).closest('.source-line')
- highlighted = row.is ".#{HIGHLIGHTED_ROW_CLASS}"
- @$(".#{HIGHLIGHTED_ROW_CLASS}").removeClass HIGHLIGHTED_ROW_CLASS
- @highlightedLine = null
- unless highlighted
- row.addClass HIGHLIGHTED_ROW_CLASS
- @highlightedLine = row.data 'line-number'
- @showLineActionsPopup(e)
-
-
- highlightCurrentLine: ->
- if @highlightedLine?
- @$("[data-line-number=#{@highlightedLine}]").addClass HIGHLIGHTED_ROW_CLASS
-
-
- highlightUsages: (e) ->
- highlighted = $(e.currentTarget).is '.highlighted'
- key = e.currentTarget.className.split(/\s+/)[0]
- @$('.sym.highlighted').removeClass 'highlighted'
- @$(".sym.#{key}").addClass 'highlighted' unless highlighted
-
-
- toggleSettings: ->
- @$('.settings-toggle button').toggleClass 'open'
- @$('.component-viewer-source-settings').toggleClass 'open'
-
-
- toggleMeasures: (e) ->
- row = $(e.currentTarget).closest '.component-viewer-header'
- row.toggleClass 'component-viewer-header-full'
-
-
- showSCMPopup: (e) ->
- e.stopPropagation()
- $('body').click()
- line = +$(e.currentTarget).closest('[data-line-number]').data 'line-number'
- row = _.findWhere @options.main.source.get('formattedSource'), lineNumber: line
- popup = new SCMPopupView
- triggerEl: $(e.currentTarget)
- model: new Backbone.Model
- scmAuthor: row.scm.author
- scmDate: row.scm.date
- popup.render()
-
-
- showCoveragePopup: (e) ->
- e.stopPropagation()
- $('body').click()
- line = $(e.currentTarget).closest('.source-line').data 'line-number'
- row = _.findWhere @options.main.source.get('formattedSource'), lineNumber: line
- $.get API_COVERAGE_TESTS, key: @options.main.component.get('key'), line: line, (data) =>
- popup = new CoveragePopupView
- model: new Backbone.Model data
- triggerEl: $(e.currentTarget)
- main: @options.main
- row: row
- popup.render()
-
-
- showDuplicationPopup: (e) ->
- 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 blocks
- popup.render()
-
-
- duplicationMouseEnter: (e) ->
- @toggleDuplicationHover e, true
-
-
- duplicationMouseLeave: (e) ->
- @toggleDuplicationHover e, false
-
-
- toggleDuplicationHover: (e, add) ->
- bar = $(e.currentTarget)
- index = bar.parent().children('.duplication').index bar
- @$('.duplications').each ->
- $(".duplication", @).eq(index).filter('.duplication-exists').toggleClass 'duplication-hover', add
-
-
- expandBlock: (e) ->
- linesFrom = $(e.currentTarget).data 'from'
- linesTo = $(e.currentTarget).data 'to'
- if linesTo == _.size @model.get 'source'
- if linesTo - linesFrom > EXPAND_LINES
- linesTo = linesFrom + EXPAND_LINES
- if linesFrom == 0 && linesTo > EXPAND_LINES
- linesFrom = linesTo - EXPAND_LINES
- @showBlocks.push from: linesFrom, to: linesTo
- @render()
-
-
- expandAll: ->
- @options.main.showAllLines()
-
-
- getSCMForLine: (lineNumber) ->
- scm = @model.get('scm') || []
- closest = -1
- closestIndex = -1
- scm.forEach (s, i) ->
- line = s[0]
- if line <= lineNumber && line > closest
- closest = line
- closestIndex = i
- if closestIndex != -1 then scm[closestIndex] else null
-
-
- augmentWithSCM: (source) ->
- scm = @model.get('scm') || []
- scm.forEach (s) ->
- line = _.findWhere source, lineNumber: s[0]
- line.scm = author: s[1], date: s[2]
- @showBlocks.forEach (block) =>
- scmForLine = @getSCMForLine block.from
- if scmForLine?
- line = _.findWhere source, lineNumber: block.from
- line.scm = author: scmForLine[1], date: scmForLine[2]
- source
-
-
- augmentWithShow: (source) ->
- source.forEach (sourceLine) =>
- show = false
- line = sourceLine.lineNumber
- @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)
-
-
- getStatColumnsCount: ->
- count = 1 # line number
- count += 2 if @options.main.settings.get 'coverage'
- count += 1 if @options.main.settings.get 'duplications'
- count += 1 if @options.main.settings.get 'issues'
- count
-
-
- showZeroLine: ->
- r = false
- r = true unless @options.main.state.get 'hasSource'
- @showBlocks.forEach (block) ->
- r = true if block.from <= 0
- r
-
-
- getBaseDuplications: ->
- source = @model.get 'formattedSource'
- baseDuplications = []
- if source? && source.length > 0 && _.first(source).duplications?
- baseDuplications = _.first(source).duplications
- baseDuplications
-
-
- serializeData: ->
- uid: @cid
- source: @prepareSource()
- settings: @options.main.settings.toJSON()
- state: @options.main.state.toJSON()
- showSettings: @showSettings
- component: @options.main.component.toJSON()
- columns: @getStatColumnsCount() + 1
- showZeroLine: @showZeroLine()
- issuesLimit: ISSUES_LIMIT
- issuesLimitReached: @model.get('activeIssues')?.length > ISSUES_LIMIT
- baseDuplications: @getBaseDuplications()
+++ /dev/null
-define [
- 'backbone.marionette'
- 'templates/component-viewer'
- 'common/popup'
-], (
- Marionette
- Templates
- Popup
-) ->
-
- $ = jQuery
-
-
- class TimeChangesPopupView extends Popup
- template: Templates['cw-time-changes-popup']
-
-
- events:
- 'click a[data-period]': 'enablePeriod'
-
-
- enablePeriod: (e) ->
- period = $(e.currentTarget).data 'period'
- @trigger 'change', period
-
-
- serializeData: ->
- component: @options.main.component.toJSON()
- periods: @options.main.periods.toJSON()
- prefix: @options.prefix || 'Δ'
+++ /dev/null
-define ->
-
- splitLongName: (longName) ->
- lastSeparator = longName.lastIndexOf '/'
- if lastSeparator == -1
- lastSeparator = longName.lastIndexOf '.'
- dir: longName.substr 0, lastSeparator
- name: longName.substr lastSeparator + 1
-
-
- sortSeverities: (severities) ->
- order = ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO']
- _.sortBy severities, (s) -> order.indexOf s.key
-
-
- mixOf: (base, mixins...) ->
- class Mixed extends base
- for mixin in mixins by -1 # earlier mixins override later ones
- for name, method of mixin::
- Mixed::[name] = method
- Mixed
\ No newline at end of file
+++ /dev/null
-define [
- 'backbone.marionette'
- 'templates/component-viewer'
-], (
- Marionette
- Templates
-) ->
-
- $ = jQuery
-
-
- class WorkspaceView extends Marionette.ItemView
- template: Templates['cw-workspace']
-
-
- events:
- 'click .js-toggle-workspace': 'toggleWorkspace'
-
- 'click .component-viewer-workspace-item > a[data-key]': 'goToWorkspaceItem'
- 'click .component-viewer-workspace-option > a[data-key]': 'goToWorkspaceOption'
-
-
- onRender: ->
- @delegateEvents()
-
-
- toggleWorkspace: ->
- @options.main.toggleWorkspace true
-
-
- goToWorkspaceItem: (e) ->
- key = $(e.currentTarget).data 'key'
- workspace = @options.main.workspace
- workspaceItem = workspace.findWhere key: key
- workspaceItem.set 'active', true
- workspaceItemOptions = workspaceItem.get 'options'
- workspaceItemOptions.forEach (option) -> option.active = false
- @options.main._open key
-
-
- goToWorkspaceOption: (e) ->
- workspaceKey = $(e.currentTarget).data 'workspace-key'
- key = $(e.currentTarget).data 'key'
- workspace = @options.main.workspace
- workspaceItem = workspace.findWhere key: workspaceKey
- workspaceItem.set 'active', false
- workspaceItemOptions = workspaceItem.get 'options'
- workspaceItemOptions.forEach (option) -> option.active = option.key == key
- @options.main._open key
-
-
- serializeData: ->
- _.extend super,
- workspace: @options.main.workspace.toJSON()
- settings: @options.main.settings.toJSON()
-
+++ /dev/null
-<tr class="source-line source-line-expand">
- <td class="source-meta source-line-number"></td>
- {{#if settings.scm}}
- <td class="source-meta source-line-scm"></td>
- {{/if}}
- {{#if settings.coverage}}
- <td class="source-meta source-line-coverage"></td>
- {{/if}}
- {{#if settings.duplications}}
- {{#each baseDuplications}}
- <td class="source-meta source-line-duplications-extra"></td>
- {{/each}}
- {{/if}}
- <td class="source-line-code">
- <button class="button-clean js-expand" data-from="{{from}}" data-to="{{to}}"><i class="icon-expand"></i></button>
- </td>
-</tr>
+++ /dev/null
-<div class="bubble-popup-container">
- <div class="bubble-popup-title">
- {{#if row.coverage.covered}}
- {{t 'source_viewer.covered'}}
- {{#if row.coverage.branches}}
- ({{default row.coverage.coveredBranches 0}} of {{row.coverage.branches}} {{t 'source_viewer.conditions'}})
- {{/if}}
- {{else}}
- {{t 'source_viewer.not_covered'}}
- {{#if row.coverage.branches}}
- ({{row.coverage.branches}} {{t 'source_viewer.conditions'}})
- {{/if}}
- {{/if}}
- </div>
-
- {{#each testFiles}}
- <div class="bubble-popup-section">
- <a class="component-viewer-popup-test-file link-action" data-key="{{file.key}}" title="{{file.longName}}">
- {{file.longName}}
- </a>
- <ul class="bubble-popup-list">
- {{#each tests}}
- <li class="component-viewer-popup-test" title="{{name}}">
- <i class="component-viewer-popup-test-status {{testStatusIconClass status}}"></i>
- <span class="component-viewer-popup-test-name">
- <a class="component-viewer-popup-test-file link-action" title="{{name}}"
- data-key="{{../file.key}}" data-method="{{name}}">
- {{name}}
- </a>
- </span>
- <span class="component-viewer-popup-test-duration">{{durationInMs}}ms</span>
- </li>
- {{/each}}
- </ul>
- </div>
- {{/each}}
-</div>
-
-<div class="bubble-popup-arrow"></div>
+++ /dev/null
-<div class="bubble-popup-container">
- <div class="bubble-popup-title">{{t 'component_viewer.transition.duplication'}}</div>
- {{#each duplications}}
- <div class="bubble-popup-section">
- {{#notEqComponents file ../component}}
- <div class="component-viewer-popup-label" title="{{projectFullName file}}">
- <i class="icon-qualifier-trk"></i> {{projectFullName file}}
- </div>
- {{/notEqComponents}}
-
- {{#notEq file.key ../component.key}}
- <a class="link-action" data-key="{{file.key}}" title="{{file.name}}">
- {{file.name}}
- </a>
- {{/notEq}}
-
- <div class="component-viewer-popup-duplications">
- Lines:
- {{#joinEach blocks ','}}
- <a class="link-action" data-key="{{../file.key}}" data-line="{{from}}">
- {{from}} – {{sum from size}}
- </a>
- {{/joinEach}}
- </div>
- </div>
- {{else}}
- {{t 'duplications.block_was_duplicated_by_a_deleted_resource'}}
- {{/each}}
-</div>
-
-<div class="bubble-popup-arrow"></div>
+++ /dev/null
-<div class="component-viewer-header-bar">
- <div class="component-viewer-header-component">
- {{#unless state.removed}}
- {{#if component.projectName}}
- <div class="component-viewer-header-component-project">
- {{qualifierIcon 'TRK'}}
- <a class="link-action" href="{{dashboardUrl component.project}}">{{component.projectName}}</a>
- {{#if component.subProjectName}}
- / <a class="link-action" href="{{dashboardUrl component.subProject}}">{{component.subProjectName}}</a>
- {{/if}}
- </div>
- {{/if}}
-
- <div class="component-viewer-header-component-name">
- {{qualifierIcon component.q}} {{default component.path component.longName}}
-
- {{#if state.canMarkAsFavourite}}
- <a class="js-favorite component-viewer-header-favorite"
- title="{{#if component.fav}}{{t 'click_to_remove_from_favorites'}}{{else}}{{t 'click_to_add_to_favorites'}}{{/if}}">
- <i class="{{#if component.fav}}icon-favorite{{else}}icon-not-favorite{{/if}}"></i>
- </a>
- {{/if}}
- </div>
- {{else}}
- <div class="component-viewer-header-component-project removed">{{state.removedMessage}}</div>
- {{/unless}}
- </div>
-
- {{#unless state.removed}}
- <a class="js-actions component-viewer-header-actions" title="{{t 'component_viewer.more_actions'}}">
- <i class="icon-list"></i>
- </a>
-
- <div class="component-viewer-header-measures">
- {{#if component.isUnitTest}}
- <div class="component-viewer-header-measures-scope">
- <a data-scope="tests" class="component-viewer-header-measures-expand js-header-tab-tests">
- <div class="component-viewer-header-measure">
- <span class="component-viewer-header-measure-value">{{component.measures.fTests}}</span>
- <span class="component-viewer-header-measure-label">{{t 'metric.tests.name'}}</span>
- </div>
- <i class="icon-dropdown"></i>
- </a>
- </div>
- {{/if}}
-
- {{#unless component.isUnitTest}}
- <div class="component-viewer-header-measures-scope">
- <span data-scope="basic" class="js-toggle-coverage component-viewer-header-measures-toggle-scope inactive"></span>
- <a data-scope="basic" class="component-viewer-header-measures-expand js-header-tab-basic">
- <div class="component-viewer-header-measure">
- <span class="component-viewer-header-measure-value">{{default component.measures.fNcloc '–'}}</span>
- <span class="component-viewer-header-measure-label">{{t 'metric.ncloc.name'}}</span>
- </div>
- <i class="icon-dropdown"></i>
- </a>
- </div>
- {{/unless}}
-
- <div class="component-viewer-header-measures-scope">
- <a data-scope="issues" class="component-viewer-header-measures-expand js-header-tab-issues">
- {{#if component.measures.fSqaleRating}}
- <div class="component-viewer-header-measure">
- <span class="rating rating-{{component.measures.fSqaleRating}}"
- {{#if component.measures.fSqaleDebtRatio}}title="{{t 'metric.sqale_debt_ratio.name'}}: {{component.measures.fSqaleDebtRatio}}"{{/if}}>
- {{component.measures.fSqaleRating}}
- </span>
- </div>
- {{/if}}
- <div class="component-viewer-header-measure">
- <span class="component-viewer-header-measure-value">{{default component.measures.fDebt '0'}}</span>
- <span class="component-viewer-header-measure-label">{{t 'component_viewer.header.debt'}}</span>
- </div>
- {{#if component.measures.fIssues}}
- <div class="component-viewer-header-measure">
- <span class="component-viewer-header-measure-value">{{component.measures.fIssues}}</span>
- <span class="component-viewer-header-measure-label">{{t 'metric.violations.name'}}</span>
- </div>
- {{/if}}
- {{#if component.measures.fIssues}}
- <div class="component-viewer-header-measure">
- <div class="component-viewer-header-measure-issues">
- <div class="component-viewer-header-measure-issue s-blocker"
- style="width: {{percent component.measures.fBlockerIssues component.measures.maxIssues}};"></div>
- <div class="component-viewer-header-measure-issue s-critical"
- style="width: {{percent component.measures.fCriticalIssues component.measures.maxIssues}};"></div>
- <div class="component-viewer-header-measure-issue s-major"
- style="width: {{percent component.measures.fMajorIssues component.measures.maxIssues}};"></div>
- <div class="component-viewer-header-measure-issue s-minor"
- style="width: {{percent component.measures.fMinorIssues component.measures.maxIssues}};"></div>
- <div class="component-viewer-header-measure-issue s-info"
- style="width: {{percent component.measures.fInfoIssues component.measures.maxIssues}};"></div>
- </div>
- </div>
- {{/if}}
- <i class="icon-dropdown"></i>
- </a>
- <a data-scope="issues" title="{{t 'component_viewer.header.toggle_issues'}}"
- class="js-toggle-issues component-viewer-header-measures-toggle-scope {{#if settings.issues}}active{{/if}}"></a>
- </div>
-
- {{#inArray state.tabs 'coverage'}}
- <div class="component-viewer-header-measures-scope">
- <a data-scope="coverage" class="component-viewer-header-measures-expand js-header-tab-coverage">
- <div class="component-viewer-header-measure">
- <span class="component-viewer-header-measure-value">{{default component.measures.fCoverage '–'}}</span>
- <span class="component-viewer-header-measure-label">{{t 'metric.coverage.name'}}</span>
- </div>
- <i class="icon-dropdown"></i>
- </a>
- <a data-scope="coverage" title="{{t 'component_viewer.header.toggle_coverage'}}"
- class="js-toggle-coverage component-viewer-header-measures-toggle-scope {{#if settings.coverage}}active{{/if}}"></a>
- </div>
- {{/inArray}}
-
- {{#inArray state.tabs 'duplications'}}
- <div class="component-viewer-header-measures-scope">
- <a data-scope="duplications" class="component-viewer-header-measures-expand js-header-tab-duplications">
- <div class="component-viewer-header-measure">
- <span class="component-viewer-header-measure-value">{{default component.measures.fDuplicationDensity '–'}}</span>
- <span class="component-viewer-header-measure-label">{{t 'metric.duplicated_lines_density.name'}}</span>
- </div>
- <i class="icon-dropdown"></i>
- </a>
- <a data-scope="duplications" title="{{t 'component_viewer.header.toggle_duplications'}}"
- class="js-toggle-duplications component-viewer-header-measures-toggle-scope {{#if settings.duplications}}active{{/if}}"></a>
- </div>
- {{/inArray}}
-
- {{#inArray state.tabs 'scm'}}
- <div class="component-viewer-header-measures-scope">
- <a data-scope="scm" class="component-viewer-header-measures-expand js-header-tab-scm">
- <div class="component-viewer-header-measure">
- <span class="component-viewer-header-measure-value"><i class="icon-calendar"></i></span>
- <span class="component-viewer-header-measure-label">SCM</span>
- </div>
- <i class="icon-dropdown"></i>
- </a>
- <a data-scope="scm" title="{{t 'component_viewer.header.toggle_scm'}}"
- class="js-toggle-scm component-viewer-header-measures-toggle-scope {{#if settings.scm}}active{{/if}}"></a>
- </div>
- {{/inArray}}
- </div>
- {{/unless}}
-</div>
-
-<div class="component-viewer-header-expanded-bar"></div>
+++ /dev/null
-<div class="component-viewer-header"></div>
-<div class="component-viewer-workspace"></div>
-<div class="component-viewer-source code-source"></div>
+++ /dev/null
-<div class="bubble-popup-container">
- <div class="bubble-popup-title">{{t 'component_viewer.line_actions'}}</div>
-
- <div class="bubble-popup-section">
- <a href="#" class="js-get-permalink link-action">{{t 'component_viewer.get_permalink'}}</a>
- </div>
-
- {{#if state.canCreateManualIssue}}
- <div class="bubble-popup-section">
- <a href="#" class="js-add-manual-issue link-action">{{t 'component_viewer.add_manual_issue'}}</a>
- </div>
- {{/if}}
-</div>
-
-<div class="bubble-popup-arrow"></div>
+++ /dev/null
-<a class="js-new-window">{{t 'component_viewer.new_window'}}</a>
-<br>
-<a class="js-full-source">{{t 'component_viewer.show_full_source'}}</a>
-<br>
-<a class="js-raw-source">{{t 'component_viewer.show_raw_source'}}</a>
-
-{{#each state.extensions}}
- <br>
- <a class="js-extension" data-key="{{this.[0]}}">{{this.[1]}}</a>
-{{/each}}
+++ /dev/null
-{{#if state.sourceSecurity}}
-
- <p>{{t 'code_viewer.no_source_code_displayed_due_to_security'}}</p>
-
-{{else}}
-
- {{#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}}
-
- <div class="source source-duplications-expanded">
- <table class="source-table">
- {{#if showZeroLine}}
- <tr class="source-line hidden" data-line-number="0" id="{{uid}}-0">
- <td class="source-meta source-line-number" title="{{t 'component_viewer.line_actions'}}"></td>
-
- {{#if settings.scm}}
- <td class="source-meta source-line-scm"></td>
- {{/if}}
-
- {{#if settings.coverage}}
- <td class="source-meta source-line-coverage">
- <div class="source-line-bar"></div>
- </td>
- {{/if}}
-
- {{#if settings.duplications}}
- {{#each baseDuplications}}
- <td class="source-meta source-line-duplications-extra">
- <div class="source-line-bar"></div>
- </td>
- {{/each}}
- {{/if}}
-
- <td class="source-line-code"></td>
- </tr>
- {{/if}}
-
- {{#each source}}
- {{#if show}}
- <tr class="source-line" data-line-number="{{lineNumber}}" id="{{../../uid}}-{{lineNumber}}">
- <td class="source-meta source-line-number js-line-actions" title="{{t 'component_viewer.line_actions'}}"
- {{#if lineNumber}}data-line-number="{{lineNumber}}"{{/if}}></td>
-
- {{#if ../../settings.scm}}
- <td class="source-meta {{#if scm}}source-line-scm{{/if}}">
- {{#if scm}}
- {{#ifSCMChanged ../../../../source ../../../lineNumber}}
- <div class="source-line-scm-inner" data-author="{{scm.author}}"></div>
- {{/ifSCMChanged}}
- {{/if}}
- </td>
- {{/if}}
-
- {{#if ../../settings.coverage}}
- <td class="source-meta source-line-coverage {{#if coverage}}source-line-{{coverageStatus}}{{/if}}">
- <div class="source-line-bar"></div>
- </td>
- {{/if}}
-
- {{#if ../../settings.duplications}}
- {{#each duplications}}
- <td class="source-meta source-line-duplications-extra {{#if this}}source-line-duplicated{{/if}}"
- data-index="{{this}}" data-line-number="{{line}}">
- <div class="source-line-bar"></div>
- </td>
- {{/each}}
- {{/if}}
-
- <td class="source-line-code code"><pre>{{{code}}}</pre></td>
- </tr>
- {{/if}}
- {{/each}}
- </table>
- </div>
-
-{{/if}}
+++ /dev/null
-<div class="bubble-popup-title">Time Changes</div>
-
-<ul class="bubble-popup-list">
- {{#each periods}}
- <li><a class="link-action" data-period="{{key}}">{{#if key}}{{../../prefix}}{{/if}} {{label}}</a></li>
- {{/each}}
-</ul>
-
-<div class="bubble-popup-arrow"></div>
+++ /dev/null
-<div class="component-viewer-workspace-header">
- <div class="component-viewer-workspace-title"
- title="{{t 'component_viewer.workspace.tooltip'}}">{{t 'component_viewer.workspace'}}</div>
- <button class="button-clean component-viewer-workspace-toggle js-toggle-workspace"
- title="{{#if settings.workspace}}{{t 'component_viewer.workspace.hide_workspace'}}{{else}}{{t 'component_viewer.workspace.show_workspace'}}{{/if}}">
- {{#if settings.workspace}}
- <i class="icon-double-chevron-left"></i>
- {{else}}
- <i class="icon-double-chevron-right"></i>
- {{/if}}
- </button>
-</div>
-
-<ul class="component-viewer-workspace-list">
- {{#eachReverse workspace}}
- <li class="component-viewer-workspace-item {{#if active}}active{{/if}}">
- <div class="text-ellipsis subtitle" title="{{component.projectName}}{{#if component.subProjectName}} / {{component.subProjectName}}{{/if}}">
- {{component.projectName}}{{#if component.subProjectName}} / {{component.subProjectName}}{{/if}}
- </div>
- {{#if component.dir}}<div class="text-ellipsis subtitle">{{component.dir}}</div>{{/if}}
- {{qualifierIcon component.q}} <a class="link-action" data-key="{{component.key}}">{{component.name}}</a>
-
- {{#if options}}
- <div class="component-viewer-workspace-transition">{{t 'component_viewer.transition' ../transition}}</div>
- <ul class="component-viewer-workspace-options">
- {{#each options}}
- <li class="component-viewer-workspace-option text-ellipsis {{#if active}}active{{/if}}" title="{{name}}">
- {{#if component}}
- <div class="text-ellipsis subtitle" title="{{component.projectName}}{{#if component.subProjectName}} / {{component.subProjectName}}{{/if}}">
- {{component.projectName}}{{#if component.subProjectName}} / {{component.subProjectName}}{{/if}}
- </div>
- {{/if}}
- {{#if subname}}<div class="text-ellipsis subtitle" title="{{subname}}">{{subname}}</div>{{/if}}
- <a class="link-action" data-workspace-key="{{../component.key}}" data-key="{{key}}">{{name}}</a>
- </li>
- {{/each}}
- </ul>
- {{/if}}
- </li>
- {{/eachReverse}}
-</ul>
+++ /dev/null
-<li><span class="item" data-metric="{{label}}">
- <span class="label">{{t 'metric' label 'name'}}</span>
- <span class="number">{{value}}</span>
-</span></li>
\ No newline at end of file
+++ /dev/null
-<li><a class="item {{cl}}" data-metric="{{label}}">
- <span class="label">{{t 'metric' label 'name'}}</span>
- <span class="number">{{value}}</span>
- <i class="icon-component-viewer-filter"></i>
-</a></li>
+++ /dev/null
-{{#with component.measures}}
- <div class="component-viewer-header-expanded-bar-section">
- <div class="component-viewer-header-expanded-bar-section-title">
- {{t 'component_viewer.measure_section.size'}}
- </div>
- <ul class="component-viewer-header-expanded-bar-section-list">
- {{{componentViewerHeaderLink lines 'lines' 'js-filter-lines'}}}
- {{#if ncloc_data}}
- {{{componentViewerHeaderLink ncloc 'ncloc' 'js-filter-ncloc'}}}
- {{else}}
- {{{componentViewerHeaderItem ncloc 'ncloc'}}}
- {{/if}}
- {{{componentViewerHeaderItem generated_lines 'generated_lines'}}}
- {{{componentViewerHeaderItem generated_ncloc 'generated_ncloc'}}}
- </ul>
- </div>
-
- <div class="component-viewer-header-expanded-bar-section">
- <div class="component-viewer-header-expanded-bar-section-title">
- {{t 'component_viewer.measure_section.complexity'}}
- </div>
- <ul class="component-viewer-header-expanded-bar-section-list">
- {{{componentViewerHeaderItem complexity 'complexity'}}}
- {{{componentViewerHeaderItem function_complexity 'function_complexity'}}}
- </ul>
- </div>
-
- <div class="component-viewer-header-expanded-bar-section">
- <div class="component-viewer-header-expanded-bar-section-title">
- {{t 'component_viewer.measure_section.structure'}}
- </div>
- <ul class="component-viewer-header-expanded-bar-section-list">
- {{{componentViewerHeaderItem classes 'classes'}}}
- {{{componentViewerHeaderItem functions 'functions'}}}
- {{{componentViewerHeaderItem accessors 'accessors'}}}
- {{{componentViewerHeaderItem statements 'statements'}}}
- </ul>
- </div>
-
- <div class="component-viewer-header-expanded-bar-section">
- <div class="component-viewer-header-expanded-bar-section-title">
- {{t 'component_viewer.measure_section.documentation'}}
- </div>
- <ul class="component-viewer-header-expanded-bar-section-list">
- {{{componentViewerHeaderItem comment_lines 'comment_lines'}}}
- {{{componentViewerHeaderItem comment_lines_density 'comment_lines_density'}}}
- {{{componentViewerHeaderItem public_api 'public_api'}}}
- {{{componentViewerHeaderItem public_undocumented_api 'public_undocumented_api'}}}
- {{{componentViewerHeaderItem public_documented_api_density 'public_documented_api_density'}}}
- </ul>
- </div>
-{{/with}}
+++ /dev/null
-{{#if state.hasSource}}
- <div class="component-viewer-header-time-changes">
- <a class="js-coverage-time-changes">
- {{#if period}}Δ {{period.label}}{{else}}<i class="icon-period"></i> {{t 'component_viewer.time_changes'}}{{/if}}
- </a>
- </div>
-{{/if}}
-
-{{#with component.measures}}
- {{#any coverage line_coverage lines_to_cover covered_lines uncovered_lines branch_coverage conditions_to_cover
- covered_conditions uncovered_conditions it_coverage it_line_coverage it_lines_to_cover it_covered_lines
- it_uncovered_lines it_branch_coverage it_conditions_to_cover it_covered_conditions it_uncovered_conditions
- overall_coverage overall_line_coverage overall_lines_to_cover overall_covered_lines overall_uncovered_lines
- overall_branch_coverage overall_conditions_to_cover overall_covered_conditions overall_uncovered_conditions}}
- {{else}}
- <div class="component-viewer-header-expanded-bar-section">
- <div class="component-viewer-header-expanded-bar-section-title">
- {{t 'component_viewer.no_coverage'}}
- </div>
- </div>
- {{/any}}
-
- <span class="nowrap">
- {{#any overall_coverage overall_line_coverage overall_lines_to_cover overall_covered_lines overall_uncovered_lines}}
- <div class="component-viewer-header-expanded-bar-section">
- <div class="component-viewer-header-expanded-bar-section-title">
- {{t 'component_viewer.measure_section.overall'}}
- </div>
- <ul class="component-viewer-header-expanded-bar-section-list">
- {{{componentViewerHeaderItem overall_coverage 'overall_coverage'}}}
- {{{componentViewerHeaderItem overall_line_coverage 'overall_line_coverage'}}}
- {{#if ../../state.hasSource}}
- {{{componentViewerHeaderLink overall_lines_to_cover 'overall_lines_to_cover' 'js-filter-lines-to-cover-overall'}}}
- {{{componentViewerHeaderLink overall_uncovered_lines 'overall_uncovered_lines' 'js-filter-uncovered-lines-overall'}}}
- {{else}}
- {{{componentViewerHeaderItem overall_lines_to_cover 'overall_lines_to_cover'}}}
- {{{componentViewerHeaderItem overall_uncovered_lines 'overall_uncovered_lines'}}}
- {{/if}}
- </ul>
- </div>
- {{/any}}
-
- {{#any overall_branch_coverage overall_conditions_to_cover overall_covered_conditions overall_uncovered_conditions}}
- <div class="component-viewer-header-expanded-bar-section">
- <div class="component-viewer-header-expanded-bar-section-title">
- {{#any overall_coverage overall_line_coverage overall_lines_to_cover overall_covered_lines overall_uncovered_lines}}
-
- {{else}}
- {{t 'component_viewer.measure_section.overall'}}
- {{/any}}
- </div>
- <ul class="component-viewer-header-expanded-bar-section-list">
- {{#any overall_coverage overall_line_coverage overall_lines_to_cover overall_covered_lines overall_uncovered_lines}}
- <li><span class="item"> </span></li>
- {{/any}}
- {{{componentViewerHeaderItem overall_branch_coverage 'overall_branch_coverage'}}}
- {{#if ../../state.hasSource}}
- {{{componentViewerHeaderLink overall_conditions_to_cover 'overall_conditions_to_cover' 'js-filter-branches-to-cover-overall'}}}
- {{{componentViewerHeaderLink overall_uncovered_conditions 'overall_uncovered_conditions' 'js-filter-uncovered-branches-overall'}}}
- {{else}}
- {{{componentViewerHeaderItem overall_conditions_to_cover 'overall_conditions_to_cover'}}}
- {{{componentViewerHeaderItem overall_uncovered_conditions 'overall_uncovered_conditions'}}}
- {{/if}}
- </ul>
- </div>
- {{/any}}
- </span>
-
- <span class="nowrap">
- {{#any coverage line_coverage lines_to_cover covered_lines uncovered_lines}}
- <div class="component-viewer-header-expanded-bar-section">
- <div class="component-viewer-header-expanded-bar-section-title">
- {{t 'component_viewer.measure_section.unit_tests'}}
- </div>
- <ul class="component-viewer-header-expanded-bar-section-list">
- {{{componentViewerHeaderItem coverage 'coverage'}}}
- {{{componentViewerHeaderItem line_coverage 'line_coverage'}}}
- {{#if ../../state.hasSource}}
- {{{componentViewerHeaderLink lines_to_cover 'lines_to_cover' 'js-filter-lines-to-cover'}}}
- {{{componentViewerHeaderLink uncovered_lines 'uncovered_lines' 'js-filter-uncovered-lines'}}}
- {{else}}
- {{{componentViewerHeaderItem lines_to_cover 'lines_to_cover'}}}
- {{{componentViewerHeaderItem uncovered_lines 'uncovered_lines'}}}
- {{/if}}
- </ul>
- </div>
- {{/any}}
-
- {{#any branch_coverage conditions_to_cover covered_conditions uncovered_conditions}}
- <div class="component-viewer-header-expanded-bar-section">
- <div class="component-viewer-header-expanded-bar-section-title">
- {{#any coverage line_coverage lines_to_cover covered_lines uncovered_lines}}
-
- {{else}}
- {{t 'component_viewer.measure_section.unit_tests'}}
- {{/any}}
- </div>
- <ul class="component-viewer-header-expanded-bar-section-list">
- {{#any coverage line_coverage lines_to_cover covered_lines uncovered_lines}}
- <li><span class="item"> </span></li>
- {{/any}}
- {{{componentViewerHeaderItem branch_coverage 'branch_coverage'}}}
- {{#if ../../state.hasSource}}
- {{{componentViewerHeaderLink conditions_to_cover 'conditions_to_cover' 'js-filter-branches-to-cover'}}}
- {{{componentViewerHeaderLink uncovered_conditions 'uncovered_conditions' 'js-filter-uncovered-branches'}}}
- {{else}}
- {{{componentViewerHeaderItem conditions_to_cover 'conditions_to_cover'}}}
- {{{componentViewerHeaderItem uncovered_conditions 'uncovered_conditions'}}}
- {{/if}}
- </ul>
- </div>
- {{/any}}
- </span>
-
- <span class="nowrap">
- {{#any it_coverage it_line_coverage it_lines_to_cover it_covered_lines it_uncovered_lines}}
- <div class="component-viewer-header-expanded-bar-section">
- <div class="component-viewer-header-expanded-bar-section-title">
- {{t 'component_viewer.measure_section.integration_tests'}}
- </div>
- <ul class="component-viewer-header-expanded-bar-section-list">
- {{{componentViewerHeaderItem it_coverage 'it_coverage'}}}
- {{{componentViewerHeaderItem it_line_coverage 'it_line_coverage'}}}
- {{#if ../../state.hasSource}}
- {{{componentViewerHeaderLink it_lines_to_cover 'it_lines_to_cover' 'js-filter-lines-to-cover-it'}}}
- {{{componentViewerHeaderLink it_uncovered_lines 'it_uncovered_lines' 'js-filter-uncovered-lines-it'}}}
- {{else}}
- {{{componentViewerHeaderItem it_lines_to_cover 'it_lines_to_cover'}}}
- {{{componentViewerHeaderItem it_uncovered_lines 'it_uncovered_lines'}}}
- {{/if}}
- </ul>
- </div>
- {{/any}}
-
- {{#any it_branch_coverage it_conditions_to_cover it_covered_conditions it_uncovered_conditions}}
- <div class="component-viewer-header-expanded-bar-section">
- <div class="component-viewer-header-expanded-bar-section-title">
- {{#any it_coverage it_line_coverage it_lines_to_cover it_covered_lines it_uncovered_lines}}
-
- {{else}}
- {{t 'component_viewer.measure_section.integration_tests'}}
- {{/any}}
- </div>
- <ul class="component-viewer-header-expanded-bar-section-list">
- {{#any it_coverage it_line_coverage it_lines_to_cover it_covered_lines it_uncovered_lines}}
- <li><span class="item"> </span></li>
- {{/any}}
- {{{componentViewerHeaderItem it_branch_coverage 'it_branch_coverage'}}}
- {{#if ../../state.hasSource}}
- {{{componentViewerHeaderLink it_conditions_to_cover 'it_conditions_to_cover' 'js-filter-branches-to-cover-it'}}}
- {{{componentViewerHeaderLink it_uncovered_conditions 'it_uncovered_conditions' 'js-filter-uncovered-branches-it'}}}
- {{else}}
- {{{componentViewerHeaderItem it_conditions_to_cover 'it_conditions_to_cover'}}}
- {{{componentViewerHeaderItem it_uncovered_conditions 'it_uncovered_conditions'}}}
- {{/if}}
- </ul>
- </div>
- {{/any}}
- </span>
-{{/with}}
+++ /dev/null
-<div class="bubble-popup-container">
- {{#notEq test.status 'ERROR'}}
- {{#notEq test.status 'FAILURE'}}
- <div class="bubble-popup-title">{{t 'component_viewer.transition.covers'}}</div>
- {{#each items}}
- <div class="bubble-popup-section">
- <a class="component-viewer-popup-test-file link-action" data-key="{{key}}" title="{{name}}">{{name}}</a>
- <span class="subtitle">{{tp 'component_viewer.x_lines_are_covered' coveredLines}}</span>
- <br><span class="subtitle" title="{{dir}}">{{dir}}</span>
- </div>
- {{else}}
- {{t 'none'}}
- {{/each}}
- {{/notEq}}
- {{/notEq}}
-
- {{#notEq test.status 'OK'}}
- <div class="bubble-popup-title">{{t 'component_viewer.details'}}</div>
- {{#if test.message}}
- <pre>{{test.message}}</pre>
- {{/if}}
- <pre>{{test.stackTrace}}</pre>
- {{/notEq}}
-
-</div>
-
-<div class="bubble-popup-arrow"></div>
+++ /dev/null
-{{#with component.measures}}
- <div class="component-viewer-header-expanded-bar-section">
- <div class="component-viewer-header-expanded-bar-section-title">{{t 'duplications'}}</div>
- <ul class="component-viewer-header-expanded-bar-section-list">
- {{#if ../state.hasSource}}
- {{{componentViewerHeaderLink duplicated_blocks 'duplicated_blocks' 'js-filter-duplications'}}}
- {{else}}
- {{{componentViewerHeaderItem duplicated_blocks 'duplicated_blocks'}}}
- {{/if}}
- {{{componentViewerHeaderItem duplicated_lines 'duplicated_lines'}}}
- </ul>
- </div>
-{{/with}}
\ No newline at end of file
+++ /dev/null
-{{#if state.hasSource}}
- <div class="component-viewer-header-time-changes">
- <a class="link-action js-issues-time-changes">
- {{#if period}}{{t 'component_viewer.added'}} {{period.label}}{{else}}<i class="icon-period"></i> {{t 'component_viewer.time_changes'}}{{/if}}
- </a>
- </div>
-{{/if}}
-
-<div class="component-viewer-header-expanded-bar-section">
- <div class="component-viewer-header-expanded-bar-section-title">
- {{#if hasIssues}}{{t 'component_viewer.measure_section.filters'}}{{else}}{{t 'component_viewer.no_issues'}}{{/if}}
- </div>
- <ul class="component-viewer-header-expanded-bar-section-list">
- {{#if currentIssue}}
- <li><a class="item js-filter-current-issue">
- <span>{{t 'component_viewer.issues.current_issue'}}</span>
- <i class="icon-component-viewer-filter"></i>
- </a></li>
- {{/if}}
- {{#unless state.removed}}
- <li><a class="item js-filter-unresolved-issues">
- <span>{{t 'component_viewer.issues.unresolved_issues'}}</span>
- <i class="icon-component-viewer-filter"></i>
- </a></li>
- {{/unless}}
- {{#unless state.removed}}
- <li><a class="item js-filter-open-issues">
- <span>{{t 'component_viewer.issues.open_issues'}}</span>
- <i class="icon-component-viewer-filter"></i>
- </a></li>
- {{/unless}}
- {{#unless state.removed}}
- <li><a class="item js-filter-fixed-issues">
- <span>{{t 'component_viewer.issues.fixed_issues'}}</span>
- <i class="icon-component-viewer-filter"></i>
- </a></li>
- {{/unless}}
- {{#unless state.removed}}
- <li><a class="item js-filter-false-positive-issues">
- <span>{{t 'component_viewer.issues.false_positive_issues'}}</span>
- <i class="icon-component-viewer-filter"></i>
- </a></li>
- {{/unless}}
- </ul>
-</div>
-
-{{#ifNotEmpty state.severities}}
- <div class="component-viewer-header-expanded-bar-section">
- <div class="component-viewer-header-expanded-bar-section-title">
- {{t 'component_viewer.measure_section.severities'}}
- </div>
- <ul class="component-viewer-header-expanded-bar-section-list">
- {{#each state.severities}}
- {{#unless ../../state.removed}}
- <li><a class="item js-filter-{{key}}-issues">
- <span>{{severityIcon key}} {{name}}</span>
- <span class="number">{{count}}</span>
- <i class="icon-component-viewer-filter"></i>
- </a></li>
- {{else}}
- <li><span class="item">
- <span>{{severityIcon key}} {{name}}</span>
- <span class="number">{{count}}</span>
- </span></li>
- {{/unless}}
- {{/each}}
- </ul>
- </div>
-{{/ifNotEmpty}}
-
-{{#ifNotEmpty state.rules}}
- <div class="component-viewer-header-expanded-bar-section">
- <div class="component-viewer-header-expanded-bar-section-title">
- {{t 'component_viewer.measure_section.rules'}}
- </div>
- <ul class="component-viewer-header-expanded-bar-section-list">
- {{#each state.rules}}
- {{#unless ../../state.removed}}
- <li><a class="item js-filter-rule" data-rule="{{key}}" title="{{name}}">
- <span>{{name}}</span>
- <span class="number">{{count}}</span>
- <i class="icon-component-viewer-filter"></i>
- </a></li>
- {{else}}
- <li><span class="item">
- <span>{{name}}</span>
- <span class="number">{{count}}</span>
- </span></li>
- {{/unless}}
- {{/each}}
- </ul>
- </div>
-{{/ifNotEmpty}}
-
-{{#if hasIssues}}
- <div class="component-viewer-header-expanded-bar-section component-viewer-header-expanded-bar-section-actions">
- <div class="component-viewer-header-expanded-bar-section-title"> </div>
- <ul class="component-viewer-header-expanded-bar-section-list">
- {{#if state.canBulkChange}}
- <li><a class="link-action js-issues-bulk-change" title="200 max">
- <span><i class="icon-bulk-change"></i> {{t 'bulk_change'}}</span>
- </a></li>
- {{/if}}
- </ul>
- </div>
-{{/if}}
+++ /dev/null
-<div class="component-viewer-header-time-changes">
- <a class="js-scm-time-changes">
- {{#if period}}Δ {{period.label}}{{else}}<i class="icon-period"></i> {{t 'component_viewer.time_changes'}}{{/if}}
- </a>
-</div>
-
-<div class="component-viewer-header-expanded-bar-section">
- <ul class="component-viewer-header-expanded-bar-section-list">
- <li><a class="item js-filter-modified-lines">
- <span>{{t 'component_viewer.scm.modified_lines'}}</span>
- <i class="icon-component-viewer-filter"></i>
- </a></li>
- </ul>
-</div>
+++ /dev/null
-{{#with component.measures}}
- <span class="nowrap">
- {{#any test_success_density test_failures test_errors test_execution_time}}
- <div class="component-viewer-header-expanded-bar-section">
- <div class="component-viewer-header-expanded-bar-section-title">
- {{t 'component_viewer.measure_section.tests'}}
- </div>
- <ul class="component-viewer-header-expanded-bar-section-list">
- {{#if test_success_density}}
- <li><span class="item" data-metric="test_success_density">
- <span class="label">{{t 'metric.test_success_density.short_name'}}</span>
- <span class="number">{{test_success_density}}</span>
- </span></li>
- {{/if}}
- {{#if skipped_tests}}
- <li><span class="item" data-metric="skipped_tests">
- <span class="label">{{t 'metric.skipped_tests.short_name'}}</span>
- <span class="number">{{skipped_tests}}</span>
- </span></li>
- {{/if}}
- {{#if test_failures}}
- <li><span class="item" data-metric="test_failures">
- <span class="label">{{t 'metric.test_failures.short_name'}}</span>
- <span class="number">{{test_failures}}</span>
- </span></li>
- {{/if}}
- {{#if test_errors}}
- <li><span class="item" data-metric="test_errors">
- <span class="label">{{t 'metric.test_errors.short_name'}}</span>
- <span class="number">{{test_errors}}</span>
- </span></li>
- {{/if}}
- {{#if test_execution_time}}
- <li><span class="item" data-metric="test_execution_time">
- <span class="label">{{t 'metric.test_execution_time.short_name'}}</span>
- <span class="number">{{test_execution_time}}</span>
- </span></li>
- {{/if}}
- </ul>
- </div>
- {{/any}}
- </span>
-{{/with}}
-
-<div class="component-viewer-header-expanded-bar-section large">
- <div class="component-viewer-header-expanded-bar-section-title justify">
- <span class="ib">
- {{t 'component_viewer.measure_section.test_cases'}}
- {{t 'component_viewer.tests.ordered_by'}}
- <a class="js-sort-tests-name">{{t 'component_viewer.tests.test_name'}}</a>
- /
- <a class="js-sort-tests-duration">{{t 'component_viewer.tests.duration'}}</a>
- </span>
- {{#if hasCoveragePerTestData}}
- <span class="ib">{{t 'component_viewer.covered_lines'}}</span>
- {{/if}}
- </div>
- <ul class="component-viewer-header-expanded-bar-section-list">
- {{#each tests}}
- {{#eq status 'SKIPPED'}}
- <li><span class="item" title="{{name}}" data-status="{{status}}">
- <span class="label">{{testStatusIcon status}}
- <span class="duration subtitle"></span>
- {{name}}</span>
- </span></li>
- {{else}}
- {{#ifTestData this}}
- <li><a class="item js-unit-test" data-name="{{name}}" data-status="{{status}}" title="{{name}}">
- <span class="label">{{testStatusIcon status}}
- <span class="duration subtitle">{{durationInMs}}ms</span>
- {{name}}</span>
- {{#if coveredLines}}
- <span class="number">{{coveredLines}}</span>
- {{/if}}
- <i class="icon-component-viewer-filter"></i>
- </a></li>
- {{else}}
- <li><span class="item" data-name="{{name}}" data-status="{{status}}" title="{{name}}">
- <span class="label">{{testStatusIcon status}}
- <span class="duration subtitle">{{durationInMs}}ms</span> {{name}}</span>
- </span></li>
- {{/ifTestData}}
- {{/eq}}
- {{/each}}
- </ul>
-</div>
return message;
});
- Handlebars.registerHelper('componentViewerHeaderLink', function(value, label, cl, hash) {
- var name = '_cw-header-link';
- if (value != null) {
- var ps = Handlebars.partials;
- if (typeof ps[name] !== 'function') {
- ps[name] = Handlebars.compile(ps[name]);
- }
- return ps[name]({ value: value, label: label, cl: cl}, hash);
- }
- });
-
- Handlebars.registerHelper('componentViewerHeaderItem', function(value, label, hash) {
- var name = '_cw-header-item';
- if (value != null) {
- var ps = Handlebars.partials;
- if (typeof ps[name] !== 'function') {
- ps[name] = Handlebars.compile(ps[name]);
- }
- return ps[name]({ value: value, label: label}, hash);
- }
- });
-
Handlebars.registerHelper('ifMeasureShouldBeShown', function(measure, period, options) {
if (measure != null || period != null) {
return options.fn(this);
define([
'backbone.marionette',
- 'templates/component-viewer',
+ 'templates/source-viewer',
'common/popup'
], function (Marionette, Templates, Popup) {