};
getFacetValueForOption = (facet, option) => {
- const map = ['*-30.0', '30.0-50.0', '50.0-70.0', '70.0-80.0', '80.0-*'];
+ const map = ['80.0-*', '70.0-80.0', '50.0-70.0', '30.0-50.0', '*-30.0'];
return facet[map[option - 1]];
};
return (
<FilterContainer
property="coverage"
- options={[5, 4, 3, 2, 1]}
+ options={[1, 2, 3, 4, 5]}
renderName={() => 'Coverage'}
renderOption={this.renderOption}
getFacetValueForOption={this.getFacetValueForOption}
return (
<span>
<Rating value={option} small={true}/>
+ {option > 1 && option < 5 && (
+ <span className="note spacer-left">and worse</span>
+ )}
</span>
);
};
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import flatMap from 'lodash/flatMap';
+import sumBy from 'lodash/sumBy';
import { createMap } from '../../../../components/store/generalReducers';
import { RECEIVE_PROJECTS } from '../projects/actions';
import { mapMetricToProperty } from '../utils';
+const CUMULATIVE_FACETS = [
+ 'reliability',
+ 'security',
+ 'maintainability',
+ 'coverage',
+ 'duplications',
+ 'size'
+];
+
+const REVERSED_FACETS = [
+ 'coverage'
+];
+
const mapFacetValues = values => {
const map = {};
values.forEach(value => {
return map;
};
+const cumulativeMapFacetValues = values => {
+ const map = {};
+ let sum = sumBy(values, value => value.count);
+ values.forEach((value, index) => {
+ map[value.val] = index > 0 && index < values.length - 1 ? sum : value.count;
+ sum -= value.count;
+ });
+ return map;
+};
+
const getFacetsMap = facets => {
const map = {};
facets.forEach(facet => {
const property = mapMetricToProperty(facet.property);
- map[property] = mapFacetValues(facet.values);
+ const { values } = facet;
+ if (REVERSED_FACETS.includes(property)) {
+ values.reverse();
+ }
+ map[property] = CUMULATIVE_FACETS.includes(property) ?
+ cumulativeMapFacetValues(values) :
+ mapFacetValues(values);
});
return map;
};
'size': getAsNumericRating(urlQuery['size']),
});
+const convertIssuesRating = (metric, rating) => {
+ if (rating > 1 && rating < 5) {
+ return `${metric} >= ${rating}`;
+ } else {
+ return `${metric} = ${rating}`;
+ }
+};
+
const convertCoverage = coverage => {
switch (coverage) {
case 1:
- return 'coverage < 30';
+ return 'coverage >= 80';
case 2:
- return 'coverage >= 30 and coverage < 50';
+ return 'coverage < 80';
case 3:
- return 'coverage >= 50 and coverage < 70';
+ return 'coverage < 70';
case 4:
- return 'coverage >= 70 and coverage < 80';
+ return 'coverage < 50';
case 5:
- return 'coverage >= 80';
+ return 'coverage < 30';
default:
return '';
}
case 1:
return 'duplicated_lines_density < 3';
case 2:
- return 'duplicated_lines_density >= 3 and duplicated_lines_density < 5';
+ return 'duplicated_lines_density >= 3';
case 3:
- return 'duplicated_lines_density >= 5 and duplicated_lines_density < 10';
+ return 'duplicated_lines_density >= 5';
case 4:
- return 'duplicated_lines_density >= 10 duplicated_lines_density < 20';
+ return 'duplicated_lines_density >= 10';
case 5:
return 'duplicated_lines_density >= 20';
default:
case 1:
return 'ncloc < 1000';
case 2:
- return 'ncloc >= 1000 and ncloc < 10000';
+ return 'ncloc >= 1000';
case 3:
- return 'ncloc >= 10000 and ncloc < 100000';
+ return 'ncloc >= 10000';
case 4:
- return 'ncloc >= 100000 ncloc < 500000';
+ return 'ncloc >= 100000';
case 5:
return 'ncloc >= 500000';
default:
}
if (query['reliability'] != null) {
- conditions.push('reliability_rating = ' + query['reliability']);
+ conditions.push(convertIssuesRating('reliability_rating', query['reliability']));
}
if (query['security'] != null) {
- conditions.push('security_rating = ' + query['security']);
+ conditions.push(convertIssuesRating('security_rating', query['security']));
}
if (query['maintainability'] != null) {
- conditions.push('sqale_rating = ' + query['maintainability']);
+ conditions.push(convertIssuesRating('sqale_rating', query['maintainability']));
}
return conditions.join(' and ');
export const getCoverageRatingLabel = rating => {
checkNumberRating(rating);
- const mapping = ['< 30%', '30–50%', '50–70%', '70–80%', '> 80%'];
+ const mapping = ['> 80%', '< 80%', '< 70%', '< 50%', '< 30%'];
return mapping[rating - 1];
};
export const getCoverageRatingAverageValue = rating => {
checkNumberRating(rating);
- const mapping = [15, 40, 60, 75, 90];
+ const mapping = [90, 75, 60, 40, 15];
return mapping[rating - 1];
};
export const getDuplicationsRatingLabel = rating => {
checkNumberRating(rating);
- const mapping = ['< 3%', '3–5%', '5–10%', '10–20%', '> 20%'];
+ const mapping = ['< 3%', '> 3%', '> 5%', '> 10%', '> 20%'];
return mapping[rating - 1];
};
export const getSizeRatingLabel = rating => {
checkNumberRating(rating);
- const mapping = ['< 1k', '1k–10k', '10k–100k', '100k–500k', '> 500k'];
+ const mapping = ['< 1k', '> 1k', '> 10k', '> 100k', '> 500k'];
return mapping[rating - 1];
};