</tr>
<tr>
<td>assertText</td>
- <td>id=component-measures-component-measure-project-measures-page-test-project:src/main/xoo/sample/Sample.xoo</td>
+ <td>id=component-measures-component-measure-project-measures-page-test-project:src/main/xoo/sample/Sample.xoo-ncloc</td>
<td>*13*</td>
</tr>
<tr>
</tr>
<tr>
<td>assertText</td>
- <td>id=component-measures-component-measure-project-measures-page-test-project:src/main/xoo/sample</td>
+ <td>id=component-measures-component-measure-project-measures-page-test-project:src/main/xoo/sample-ncloc</td>
<td>*13*</td>
</tr>
<tr>
</tr>
<tr>
<td>assertText</td>
- <td>id=component-measures-component-measure-project-measures-page-test-project:src/main/xoo/sample/Sample.xoo</td>
+ <td>id=component-measures-component-measure-project-measures-page-test-project:src/main/xoo/sample/Sample.xoo-ncloc</td>
<td>*13*</td>
</tr>
<tr>
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+export default {
+ 'overall_coverage': ['overall_uncovered_lines', 'overall_uncovered_conditions'],
+ 'overall_line_coverage': ['overall_uncovered_lines'],
+ 'overall_branch_coverage': ['overall_uncovered_conditions'],
+ 'overall_uncovered_lines': ['overall_line_coverage'],
+ 'overall_uncovered_conditions': ['overall_branch_coverage'],
+
+ 'new_overall_coverage': ['new_overall_uncovered_lines', 'new_overall_uncovered_conditions'],
+ 'new_overall_line_coverage': ['new_overall_uncovered_lines'],
+ 'new_overall_branch_coverage': ['new_overall_uncovered_conditions'],
+ 'new_overall_uncovered_lines': ['new_overall_line_coverage'],
+ 'new_overall_uncovered_conditions': ['new_overall_branch_coverage'],
+
+ 'coverage': ['uncovered_lines', 'uncovered_conditions'],
+ 'line_coverage': ['uncovered_lines'],
+ 'branch_coverage': ['uncovered_conditions'],
+ 'uncovered_lines': ['line_coverage'],
+ 'uncovered_conditions': ['branch_coverage'],
+
+ 'new_coverage': ['new_uncovered_lines', 'new_uncovered_conditions'],
+ 'new_line_coverage': ['new_uncovered_lines'],
+ 'new_branch_coverage': ['new_uncovered_conditions'],
+ 'new_uncovered_lines': ['new_line_coverage'],
+ 'new_uncovered_conditions': ['new_branch_coverage'],
+
+ 'it_coverage': ['it_uncovered_lines', 'it_uncovered_conditions'],
+ 'it_line_coverage': ['it_uncovered_lines'],
+ 'it_branch_coverage': ['it_uncovered_conditions'],
+ 'it_uncovered_lines': ['it_line_coverage'],
+ 'it_uncovered_conditions': ['it_branch_coverage'],
+
+ 'new_it_coverage': ['new_it_uncovered_lines', 'new_it_uncovered_conditions'],
+ 'new_it_line_coverage': ['new_it_uncovered_lines'],
+ 'new_it_branch_coverage': ['new_it_uncovered_conditions'],
+ 'new_it_uncovered_lines': ['new_it_line_coverage'],
+ 'new_it_uncovered_conditions': ['new_it_branch_coverage']
+};
import ComponentsListRow from './ComponentsListRow';
import EmptyComponentsList from './EmptyComponentsList';
+import complementary from '../../config/complementary';
-const ComponentsList = ({ components, selected, metric, onClick }) => {
+const ComponentsList = ({ components, metrics, selected, metric, onClick }) => {
if (!components.length) {
return <EmptyComponentsList/>;
}
+ const otherMetrics = (complementary[metric.key] || []).map(metric => {
+ return metrics.find(m => m.key === metric);
+ });
+
return (
<table className="data zebra zebra-hover">
+ {otherMetrics.length > 0 && (
+ <thead>
+ <tr>
+ <th> </th>
+ <th className="text-right">
+ <span className="small">{metric.name}</span>
+ </th>
+ {otherMetrics.map(metric => (
+ <th key={metric.key} className="text-right">
+ <span className="small">{metric.name}</span>
+ </th>
+ ))}
+ </tr>
+ </thead>
+ )}
+
<tbody>
- {components.map(component => (
- <ComponentsListRow
- key={component.id}
- component={component}
- isSelected={component === selected}
- metric={metric}
- onClick={onClick}/>
- ))}
+ {components.map(component => (
+ <ComponentsListRow
+ key={component.id}
+ component={component}
+ otherMetrics={otherMetrics}
+ isSelected={component === selected}
+ metric={metric}
+ onClick={onClick}/>
+ ))}
</tbody>
</table>
);
import ComponentCell from './ComponentCell';
import MeasureCell from './MeasureCell';
-const ComponentsListRow = ({ component, isSelected, metric, onClick }) => {
+const replaceMeasure = (component, measure) => {
+ return {
+ ...component,
+ value: measure.value,
+ leak: measure.leak
+ };
+};
+
+const ComponentsListRow = ({ component, otherMetrics, isSelected, metric, onClick }) => {
const handleClick = () => {
onClick(component);
};
+ const otherMeasures = otherMetrics.map(metric => {
+ const measure = component.measures.find(measure => measure.metric === metric.key);
+ return { ...measure, metric };
+ });
+
return (
<tr>
<ComponentCell
<MeasureCell
component={component}
metric={metric}/>
+
+ {otherMeasures.map(measure => (
+ <MeasureCell
+ key={measure.metric.key}
+ component={replaceMeasure(component, measure)}
+ metric={measure.metric}/>
+ ))}
</tr>
);
};
}
render () {
- const { component, components, metric, leakPeriod, selected, fetching, total } = this.props;
+ const { component, components, metrics, metric, leakPeriod, selected, fetching, total } = this.props;
const { onSelectNext, onSelectPrevious } = this.props;
const breadcrumbs = [component];
{(!fetching || components.length !== 0) ? (
<ComponentsList
components={components}
+ metrics={metrics}
selected={selected}
metric={metric}
onClick={this.handleClick.bind(this)}/>
return {
...drilldown,
component: state.app.component,
+ metrics: state.app.metrics,
metric: state.details.metric,
fetching: state.status.fetching
};
const MeasureCell = ({ component, metric }) => {
return (
<td className="thin nowrap text-right">
- <span id={'component-measures-component-measure-' + component.key}>
+ <span id={'component-measures-component-measure-' + component.key + '-' + metric.key}>
<Measure measure={{ value: component.value, leak: component.leak }} metric={metric}/>
</span>
</td>
}
render () {
- const { components, breadcrumbs, metric, leakPeriod, selected, fetching, total } = this.props;
+ const { components, metrics, breadcrumbs, metric, leakPeriod, selected, fetching, total } = this.props;
const { onSelectNext, onSelectPrevious, onFetchMore } = this.props;
const selectedIndex = components.indexOf(selected);
{(!fetching || components.length !== 0) ? (
<ComponentsList
components={components}
+ metrics={metrics}
selected={selected}
metric={metric}
onClick={this.handleClick.bind(this)}/>
return {
...drilldown,
component: state.app.component,
+ metrics: state.app.metrics,
metric: state.details.metric,
fetching: state.status.fetching
};
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { getComponentTree } from '../../../api/components';
-import { enhanceWithSingleMeasure } from '../utils';
+import { enhanceWithMeasure } from '../utils';
import { startFetching, stopFetching } from './statusActions';
+import complementary from '../config/complementary';
export const UPDATE_STORE = 'drilldown/list/UPDATE_STORE';
return { type: UPDATE_STORE, state };
}
+function getComplementary (metric) {
+ const comp = complementary[metric] || [];
+ return [metric, ...comp];
+}
+
function makeRequest (baseComponent, metric, options, periodIndex = 1) {
const asc = metric.direction === 1;
const ps = 100;
}
Object.assign(finalOptions, options);
- return getComponentTree('leaves', baseComponent.key, [metric.key], finalOptions);
+ return getComponentTree('leaves', baseComponent.key, getComplementary(metric.key), finalOptions);
}
function fetchLeaves (baseComponent, metric, pageIndex = 1, periodIndex = 1) {
const options = { p: pageIndex };
return makeRequest(baseComponent, metric, options, periodIndex).then(r => {
- const nextComponents = enhanceWithSingleMeasure(r.components, periodIndex);
+ const nextComponents = enhanceWithMeasure(r.components, metric.key, periodIndex);
return {
components: nextComponents,
import initial from 'lodash/initial';
import { getComponentTree } from '../../../api/components';
-import { enhanceWithSingleMeasure } from '../utils';
+import { enhanceWithMeasure } from '../utils';
import { startFetching, stopFetching } from './statusActions';
+import complementary from '../config/complementary';
/*
* Actions
* Workflow
*/
+function getComplementary (metric) {
+ const comp = complementary[metric] || [];
+ return [metric, ...comp];
+}
+
function makeRequest (baseComponent, metric, options, periodIndex = 1) {
const asc = metric.direction === 1;
const ps = 100;
}
Object.assign(finalOptions, options);
- return getComponentTree('children', baseComponent.key, [metric.key], finalOptions);
+ return getComponentTree('children', baseComponent.key, getComplementary(metric.key), finalOptions);
}
function fetchComponents (baseComponent, metric, pageIndex = 1, periodIndex = 1) {
const options = { p: pageIndex };
return makeRequest(baseComponent, metric, options, periodIndex).then(r => {
- const nextComponents = enhanceWithSingleMeasure(r.components, periodIndex);
+ const nextComponents = enhanceWithMeasure(r.components, metric.key, periodIndex);
return {
baseComponent,
});
}
+export function enhanceWithMeasure (components, metric, periodIndex = 1) {
+ return components
+ .map(component => {
+ const measuresWithLeak = enhanceWithLeak(component.measures, periodIndex);
+ const measure = measuresWithLeak.find(measure => measure.metric === metric);
+ const value = measure ? measure.value : null;
+ const leak = measure ? measure.leak : null;
+ return { ...component, value, leak, measures: measuresWithLeak };
+ });
+}
+
export function hasHistory (metricKey) {
return metricKey.indexOf('new_') !== 0;
}