From 82d6d4a735a54336ecba7c022337a79a625a28ff Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Fri, 25 Mar 2016 17:46:57 +0100 Subject: [PATCH] improve code quality --- .../components/LanguageDistribution.js | 7 ++++--- .../details/MeasureDetailsContainer.js | 1 + .../details/history/MeasureHistory.js | 4 ++-- .../main/js/apps/component-measures/home/reducer.js | 11 ++++++----- .../src/main/resources/org/sonar/l10n/core.properties | 1 + 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/component-measures/components/LanguageDistribution.js b/server/sonar-web/src/main/js/apps/component-measures/components/LanguageDistribution.js index ea0e9db68ba..bd9fc9a54c0 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/components/LanguageDistribution.js +++ b/server/sonar-web/src/main/js/apps/component-measures/components/LanguageDistribution.js @@ -17,7 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import _ from 'underscore'; +import find from 'lodash/find'; +import sortBy from 'lodash/sortBy'; import React from 'react'; import { Histogram } from '../../../components/charts/histogram'; @@ -37,7 +38,7 @@ export default class LanguageDistribution extends React.Component { getLanguageName (langKey) { if (this.state && this.state.languages) { - const lang = _.findWhere(this.state.languages, { key: langKey }); + const lang = find(this.state.languages, { key: langKey }); return lang ? lang.name : translate('unknown'); } else { return langKey; @@ -54,7 +55,7 @@ export default class LanguageDistribution extends React.Component { return { x: parseInt(tokens[1], 10), y: index, value: tokens[0] }; }); - data = _.sortBy(data, d => -d.x); + data = sortBy(data, d => -d.x); const yTicks = data.map(point => this.getLanguageName(point.value)).map(this.cutLanguageName); const yValues = data.map(point => formatMeasure(point.x, 'SHORT_INT')); diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetailsContainer.js b/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetailsContainer.js index af344e20413..c6f91fd298d 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetailsContainer.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/MeasureDetailsContainer.js @@ -29,6 +29,7 @@ const mapStateToProps = state => { metrics: state.app.metrics, metric: state.details.metric, measure: state.details.measure, + secondaryMeasure: state.details.secondaryMeasure, periods: state.details.periods }; }; diff --git a/server/sonar-web/src/main/js/apps/component-measures/details/history/MeasureHistory.js b/server/sonar-web/src/main/js/apps/component-measures/details/history/MeasureHistory.js index 4958e72d75f..22c72923f43 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/details/history/MeasureHistory.js +++ b/server/sonar-web/src/main/js/apps/component-measures/details/history/MeasureHistory.js @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import _ from 'underscore'; +import sortBy from 'lodash/sortBy'; import moment from 'moment'; import React from 'react'; @@ -95,7 +95,7 @@ export default class MeasureHistory extends React.Component { return { version: event.n, date: moment(event.dt).toDate() }; }); - return _.sortBy(events, 'date'); + return sortBy(events, 'date'); }); } diff --git a/server/sonar-web/src/main/js/apps/component-measures/home/reducer.js b/server/sonar-web/src/main/js/apps/component-measures/home/reducer.js index 9ba2b5f86ec..d15d4a11411 100644 --- a/server/sonar-web/src/main/js/apps/component-measures/home/reducer.js +++ b/server/sonar-web/src/main/js/apps/component-measures/home/reducer.js @@ -17,9 +17,10 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import _ from 'underscore'; -import sortBy from '../../../../../../node_modules/lodash/sortBy'; -import partition from '../../../../../../node_modules/lodash/partition'; +import groupBy from 'lodash/groupBy'; +import partition from 'lodash/partition'; +import sortBy from 'lodash/sortBy'; +import toPairs from 'lodash/toPairs'; import { RECEIVE_MEASURES } from './actions'; @@ -32,9 +33,9 @@ const initialState = { function groupByDomains (measures) { const KNOWN_DOMAINS = ['Reliability', 'Security', 'Maintainability', 'Tests', 'Duplication', 'Size', 'Complexity']; - const domains = _.sortBy(_.pairs(_.groupBy(measures, measure => measure.metric.domain)).map(r => { + const domains = sortBy(toPairs(groupBy(measures, measure => measure.metric.domain)).map(r => { const [name, measures] = r; - const sortedMeasures = _.sortBy(measures, measure => measure.metric.name); + const sortedMeasures = sortBy(measures, measure => measure.metric.name); return { name, measures: sortedMeasures }; }), 'name'); diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 26c97d51421..6df4863e37d 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -1856,6 +1856,7 @@ coding_rules.custom_rule=Custom Rule coding_rules.custom_rule.title=This rule has been created through customization of a rule template coding_rules.custom_rule.activation_notice=Note: parameters of a custom rule are not customizable on rule activation, only during creation/edit. coding_rules.custom_rules=Custom Rules +coding_rules.delete_rule=Delete Rule coding_rules.delete.custom.confirm=Are you sure you want to delete custom rule "{0}"? coding_rules.delete.manual.confirm=Are you sure you want to delete manual rule "{0}"? coding_rules.extend_description=Extend Description -- 2.39.5