diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2016-03-11 15:43:10 +0100 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2016-03-11 15:43:10 +0100 |
commit | bffb09e48ee33d2019dd60b4e41746a02e6806d1 (patch) | |
tree | bd30e60cebbe4509594ba89feb3f107774849f81 /server/sonar-web | |
parent | e49268378aba0cd00d59a9356eb9d59c60aa08f7 (diff) | |
download | sonarqube-bffb09e48ee33d2019dd60b4e41746a02e6806d1.tar.gz sonarqube-bffb09e48ee33d2019dd60b4e41746a02e6806d1.zip |
improve code quality
Diffstat (limited to 'server/sonar-web')
15 files changed, 35 insertions, 39 deletions
diff --git a/server/sonar-web/src/main/js/api/ce.js b/server/sonar-web/src/main/js/api/ce.js index b272cb9c0fb..3209ac3d0d7 100644 --- a/server/sonar-web/src/main/js/api/ce.js +++ b/server/sonar-web/src/main/js/api/ce.js @@ -51,7 +51,7 @@ export function cancelAllTasks () { export function getTasksForComponent (componentId) { const url = '/api/ce/component'; const data = { componentId }; - return new Promise((resolve) => $.get(url, data).done(resolve)); + return new Promise(resolve => $.get(url, data).done(resolve)); } export function getTypes () { diff --git a/server/sonar-web/src/main/js/apps/account/containers/NotificationsContainer.js b/server/sonar-web/src/main/js/apps/account/containers/NotificationsContainer.js index 84328295905..0764dae9c46 100644 --- a/server/sonar-web/src/main/js/apps/account/containers/NotificationsContainer.js +++ b/server/sonar-web/src/main/js/apps/account/containers/NotificationsContainer.js @@ -31,8 +31,8 @@ function mapStateToProps (state) { function mapDispatchToProps (dispatch) { return { - onAddProject: (project) => dispatch(addProjectNotifications(project)), - onRemoveProject: (project) => dispatch(removeProjectNotifications(project)) + onAddProject: project => dispatch(addProjectNotifications(project)), + onRemoveProject: project => dispatch(removeProjectNotifications(project)) }; } diff --git a/server/sonar-web/src/main/js/apps/background-tasks/containers/BackgroundTasksAppContainer.js b/server/sonar-web/src/main/js/apps/background-tasks/containers/BackgroundTasksAppContainer.js index 88859c23ab3..553f123ceaa 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/containers/BackgroundTasksAppContainer.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/containers/BackgroundTasksAppContainer.js @@ -28,7 +28,7 @@ function mapStateToProps () { function mapDispatchToProps (dispatch) { return { - initApp: (component) => dispatch(initApp(component)) + initApp: component => dispatch(initApp(component)) }; } diff --git a/server/sonar-web/src/main/js/apps/background-tasks/containers/SearchContainer.js b/server/sonar-web/src/main/js/apps/background-tasks/containers/SearchContainer.js index 5518f3f17ec..6314eab7cee 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/containers/SearchContainer.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/containers/SearchContainer.js @@ -48,11 +48,11 @@ function mapDispatchToProps (dispatch) { return { onRefresh: () => dispatch(filterTasks()), onReset: () => dispatch(filterTasks(DEFAULT_FILTERS)), - onStatusChange: (status) => dispatch(filterTasks(updateStatusQuery(status))), - onTypeChange: (taskType) => dispatch(filterTasks({ taskType })), - onCurrentsChange: (currents) => dispatch(filterTasks({ currents, status: STATUSES.ALL_EXCEPT_PENDING })), - onDateChange: (date) => dispatch(filterTasks({ date })), - onSearch: (query) => dispatch(search(query)) + onStatusChange: status => dispatch(filterTasks(updateStatusQuery(status))), + onTypeChange: taskType => dispatch(filterTasks({ taskType })), + onCurrentsChange: currents => dispatch(filterTasks({ currents, status: STATUSES.ALL_EXCEPT_PENDING })), + onDateChange: date => dispatch(filterTasks({ date })), + onSearch: query => dispatch(search(query)) }; } diff --git a/server/sonar-web/src/main/js/apps/background-tasks/containers/TasksContainer.js b/server/sonar-web/src/main/js/apps/background-tasks/containers/TasksContainer.js index 994a04ec57e..890782913a0 100644 --- a/server/sonar-web/src/main/js/apps/background-tasks/containers/TasksContainer.js +++ b/server/sonar-web/src/main/js/apps/background-tasks/containers/TasksContainer.js @@ -33,8 +33,8 @@ function mapStateToProps (state) { function mapDispatchToProps (dispatch) { return { - onCancelTask: (task) => dispatch(cancelTask(task)), - onFilterTask: (task) => dispatch(filterTasks(Object.assign({}, DEFAULT_FILTERS, { query: task.componentKey }))) + onCancelTask: task => dispatch(cancelTask(task)), + onFilterTask: task => dispatch(filterTasks(Object.assign({}, DEFAULT_FILTERS, { query: task.componentKey }))) }; } diff --git a/server/sonar-web/src/main/js/apps/quality-gates/containers/DetailsContainer.js b/server/sonar-web/src/main/js/apps/quality-gates/containers/DetailsContainer.js index 28a8dd342b9..3f2c835edf5 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/containers/DetailsContainer.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/containers/DetailsContainer.js @@ -38,15 +38,15 @@ function mapStateToProps (state) { function mapDispatchToProps (dispatch) { return { - onShow: (qualityGate) => dispatch(showQualityGate(qualityGate)), - onDelete: (qualityGate) => dispatch(deleteQualityGate(qualityGate)), + onShow: qualityGate => dispatch(showQualityGate(qualityGate)), + onDelete: qualityGate => dispatch(deleteQualityGate(qualityGate)), onRename: (qualityGate, newName) => dispatch(renameQualityGate(qualityGate, newName)), - onCopy: (qualityGate) => dispatch(copyQualityGate(qualityGate)), - onSetAsDefault: (qualityGate) => dispatch(setQualityGateAsDefault(qualityGate)), - onUnsetAsDefault: (qualityGate) => dispatch(unsetQualityGateAsDefault(qualityGate)), - onAddCondition: (metric) => dispatch(addCondition(metric)), + onCopy: qualityGate => dispatch(copyQualityGate(qualityGate)), + onSetAsDefault: qualityGate => dispatch(setQualityGateAsDefault(qualityGate)), + onUnsetAsDefault: qualityGate => dispatch(unsetQualityGateAsDefault(qualityGate)), + onAddCondition: metric => dispatch(addCondition(metric)), onSaveCondition: (oldCondition, newCondition) => dispatch(saveCondition(oldCondition, newCondition)), - onDeleteCondition: (condition) => dispatch(deleteCondition(condition)) + onDeleteCondition: condition => dispatch(deleteCondition(condition)) }; } diff --git a/server/sonar-web/src/main/js/apps/quality-gates/containers/QualityGatesAppContainer.js b/server/sonar-web/src/main/js/apps/quality-gates/containers/QualityGatesAppContainer.js index d916ce1dd0a..2145fd817ea 100644 --- a/server/sonar-web/src/main/js/apps/quality-gates/containers/QualityGatesAppContainer.js +++ b/server/sonar-web/src/main/js/apps/quality-gates/containers/QualityGatesAppContainer.js @@ -28,9 +28,9 @@ function mapStateToProps (state) { function mapDispatchToProps (dispatch) { return { - updateStore: (nextState) => dispatch(setState(nextState)), - addQualityGate: (qualityGate) => dispatch(addQualityGate(qualityGate)), - deleteQualityGate: (qualityGate) => dispatch(deleteQualityGate(qualityGate)) + updateStore: nextState => dispatch(setState(nextState)), + addQualityGate: qualityGate => dispatch(addQualityGate(qualityGate)), + deleteQualityGate: qualityGate => dispatch(deleteQualityGate(qualityGate)) }; } diff --git a/server/sonar-web/src/main/js/components/navigator/filters/metric-filters.js b/server/sonar-web/src/main/js/components/navigator/filters/metric-filters.js index 5a3be4e8f12..1753c1cd138 100644 --- a/server/sonar-web/src/main/js/components/navigator/filters/metric-filters.js +++ b/server/sonar-web/src/main/js/components/navigator/filters/metric-filters.js @@ -87,7 +87,7 @@ const DetailsMetricFilterView = BaseFilters.DetailsFilterView.extend({ onRender () { const periodZeroLabel = this.$('[name=period]').children('[value="0"]').html(); - this.periodZeroOption = '<option value="0">' + periodZeroLabel + '</option>'; + this.periodZeroOption = `<option value="0">${periodZeroLabel}</option>`; const value = this.model.get('value') || {}; this.$('[name=metric]').val(value.metric).select2({ diff --git a/server/sonar-web/src/main/js/components/source-viewer/helpers/code-with-issue-locations-helper.js b/server/sonar-web/src/main/js/components/source-viewer/helpers/code-with-issue-locations-helper.js index 69e077cb622..0b5d1aa57ba 100644 --- a/server/sonar-web/src/main/js/components/source-viewer/helpers/code-with-issue-locations-helper.js +++ b/server/sonar-web/src/main/js/components/source-viewer/helpers/code-with-issue-locations-helper.js @@ -111,7 +111,7 @@ function highlightIssueLocations (tokens, issueLocations, className) { */ function generateHTML (tokens) { return tokens.map(function (token) { - return '<span class="' + token.className + '">' + _.escape(token.text) + '</span>'; + return `<span class="${token.className}">${_.escape(token.text)}</span>`; }).join(''); } diff --git a/server/sonar-web/src/main/js/components/source-viewer/main.js b/server/sonar-web/src/main/js/components/source-viewer/main.js index 9516aa17e46..c6cb2892ffd 100644 --- a/server/sonar-web/src/main/js/components/source-viewer/main.js +++ b/server/sonar-web/src/main/js/components/source-viewer/main.js @@ -357,8 +357,8 @@ export default Marionette.LayoutView.extend({ addIssue (issue) { const line = issue.get('line') || 0; - const code = this.$('.source-line-code[data-line-number=' + line + ']'); - const issueBox = '<div class="issue" id="issue-' + issue.get('key') + '" data-key="' + issue.get('key') + '">'; + const code = this.$(`.source-line-code[data-line-number=${line}]`); + const issueBox = `<div class="issue" id="issue-${issue.get('key')}" data-key="${issue.get('key')}">`; code.addClass('has-issues'); let issueList = code.find('.issue-list'); if (issueList.length === 0) { @@ -372,7 +372,7 @@ export default Marionette.LayoutView.extend({ }, showIssuesForLine (line) { - this.$('.source-line-code[data-line-number="' + line + '"]').find('.issue-list').removeClass('hidden'); + this.$(`.source-line-code[data-line-number="${line}"]`).find('.issue-list').removeClass('hidden'); const issues = this.issues.filter(function (issue) { return (issue.get('line') === line) || (!issue.get('line') && !line); }); @@ -386,7 +386,7 @@ export default Marionette.LayoutView.extend({ const line = +$(this).data('line-number'); const row = _.findWhere(that.model.get('source'), { line }); const issue = _.first(row.issues); - $(this).html('<i class="icon-severity-' + issue.severity.toLowerCase() + '"></i>'); + $(this).html(`<i class="icon-severity-${issue.severity.toLowerCase()}"></i>`); }); }, @@ -444,7 +444,7 @@ export default Marionette.LayoutView.extend({ // immediately show dropdown popup if there is only one duplicated block if (that.model.get('duplications').length === 1) { - const dupsBlock = that.$('.source-line[data-line-number=' + lineNumber + ']') + const dupsBlock = that.$(`.source-line[data-line-number=${lineNumber}]`) .find('.source-line-duplications-extra'); dupsBlock.click(); } diff --git a/server/sonar-web/src/main/js/helpers/handlebars/changelog.js b/server/sonar-web/src/main/js/helpers/handlebars/changelog.js index b6bc94694da..d604b74cc22 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/changelog.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/changelog.js @@ -20,7 +20,7 @@ import { translate, translateWithParameters } from '../../helpers/l10n'; module.exports = function (diff) { - let message = ''; + let message; if (diff.newValue != null) { message = translateWithParameters('issue.changelog.changed_to', translate('issue.changelog.field', diff.key), diff.newValue); diff --git a/server/sonar-web/src/main/js/helpers/l10n.js b/server/sonar-web/src/main/js/helpers/l10n.js index 2ce515e7085..3045a66c855 100644 --- a/server/sonar-web/src/main/js/helpers/l10n.js +++ b/server/sonar-web/src/main/js/helpers/l10n.js @@ -30,9 +30,7 @@ export function translate (...keys) { export function translateWithParameters (messageKey, ...parameters) { const message = messages[messageKey]; if (message) { - return parameters.reduce((acc, parameter, index) => { - return acc.replace(`{${index}}`, parameter); - }, message); + return parameters.reduce((acc, parameter, index) => acc.replace(`{${index}}`, parameter), message); } else { return `${messageKey}.${parameters.join('.')}`; } diff --git a/server/sonar-web/src/main/js/helpers/request.js b/server/sonar-web/src/main/js/helpers/request.js index c5c1bb2fdbc..e1fd843f605 100644 --- a/server/sonar-web/src/main/js/helpers/request.js +++ b/server/sonar-web/src/main/js/helpers/request.js @@ -45,9 +45,7 @@ const HEADERS = { */ function queryString (parameters) { return Object.keys(parameters) - .map(key => { - return `${encodeURIComponent(key)}=${encodeURIComponent(parameters[key])}`; - }) + .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(parameters[key])}`) .join('&'); } diff --git a/server/sonar-web/src/main/js/helpers/urls.js b/server/sonar-web/src/main/js/helpers/urls.js index 7826f91227f..be2f332895b 100644 --- a/server/sonar-web/src/main/js/helpers/urls.js +++ b/server/sonar-web/src/main/js/helpers/urls.js @@ -34,9 +34,9 @@ export function getComponentUrl (componentKey) { * @returns {string} */ export function getComponentIssuesUrl (componentKey, query) { - const serializedQuery = Object.keys(query).map(criterion => { - return `${encodeURIComponent(criterion)}=${encodeURIComponent(query[criterion])}`; - }).join('|'); + const serializedQuery = Object.keys(query).map(criterion => ( + `${encodeURIComponent(criterion)}=${encodeURIComponent(query[criterion])}` + )).join('|'); return '/component_issues?id=' + encodeURIComponent(componentKey) + '#' + serializedQuery; } diff --git a/server/sonar-web/src/main/js/main/app.js b/server/sonar-web/src/main/js/main/app.js index 24592caac8f..90f27396cfa 100644 --- a/server/sonar-web/src/main/js/main/app.js +++ b/server/sonar-web/src/main/js/main/app.js @@ -80,7 +80,7 @@ window.sonarqube.appStarted = Promise.resolve() // expose libraries -window.require = (module) => { +window.require = module => { switch (module) { case 'backbone': return Backbone; |