diff options
Diffstat (limited to 'server/sonar-web/src/main/js/helpers')
107 files changed, 551 insertions, 546 deletions
diff --git a/server/sonar-web/src/main/js/helpers/__tests__/l10n-test.js b/server/sonar-web/src/main/js/helpers/__tests__/l10n-test.js index 8234f9b25f0..3763be42db6 100644 --- a/server/sonar-web/src/main/js/helpers/__tests__/l10n-test.js +++ b/server/sonar-web/src/main/js/helpers/__tests__/l10n-test.js @@ -25,7 +25,7 @@ afterEach(() => { describe('#translate', () => { it('should translate simple message', () => { - resetBundle({ 'my_key': 'my message' }); + resetBundle({ my_key: 'my message' }); expect(translate('my_key')).toBe('my message'); }); @@ -46,23 +46,25 @@ describe('#translate', () => { describe('#translateWithParameters', () => { it('should translate message with one parameter in the beginning', () => { - resetBundle({ 'x_apples': '{0} apples' }); + resetBundle({ x_apples: '{0} apples' }); expect(translateWithParameters('x_apples', 5)).toBe('5 apples'); }); it('should translate message with one parameter in the middle', () => { - resetBundle({ 'x_apples': 'I have {0} apples' }); + resetBundle({ x_apples: 'I have {0} apples' }); expect(translateWithParameters('x_apples', 5)).toBe('I have 5 apples'); }); it('should translate message with one parameter in the end', () => { - resetBundle({ 'x_apples': 'Apples: {0}' }); + resetBundle({ x_apples: 'Apples: {0}' }); expect(translateWithParameters('x_apples', 5)).toBe('Apples: 5'); }); it('should translate message with several parameters', () => { - resetBundle({ 'x_apples': '{0}: I have {2} apples in my {1} baskets - {3}' }); - expect(translateWithParameters('x_apples', 1, 2, 3, 4)).toBe('1: I have 3 apples in my 2 baskets - 4'); + resetBundle({ x_apples: '{0}: I have {2} apples in my {1} baskets - {3}' }); + expect(translateWithParameters('x_apples', 1, 2, 3, 4)).toBe( + '1: I have 3 apples in my 2 baskets - 4' + ); }); it('should not translate message but return its key', () => { diff --git a/server/sonar-web/src/main/js/helpers/__tests__/measures-test.js b/server/sonar-web/src/main/js/helpers/__tests__/measures-test.js index 5bf2f905e6c..bc621a44fec 100644 --- a/server/sonar-web/src/main/js/helpers/__tests__/measures-test.js +++ b/server/sonar-web/src/main/js/helpers/__tests__/measures-test.js @@ -228,8 +228,12 @@ describe('#formatMeasureVariation()', () => { expect(formatMeasureVariation(ONE_HOUR + 55 * ONE_MINUTE, 'SHORT_WORK_DUR')).toBe('+2h'); expect(formatMeasureVariation(3 * ONE_DAY + 6 * ONE_HOUR, 'SHORT_WORK_DUR')).toBe('+4d'); expect(formatMeasureVariation(7 * ONE_HOUR + 59 * ONE_MINUTE, 'SHORT_WORK_DUR')).toBe('+1d'); - expect(formatMeasureVariation(5 * ONE_DAY + 2 * ONE_HOUR + ONE_MINUTE, 'SHORT_WORK_DUR')).toBe('+5d'); - expect(formatMeasureVariation(15 * ONE_DAY + 2 * ONE_HOUR + ONE_MINUTE, 'SHORT_WORK_DUR')).toBe('+15d'); + expect(formatMeasureVariation(5 * ONE_DAY + 2 * ONE_HOUR + ONE_MINUTE, 'SHORT_WORK_DUR')).toBe( + '+5d' + ); + expect(formatMeasureVariation(15 * ONE_DAY + 2 * ONE_HOUR + ONE_MINUTE, 'SHORT_WORK_DUR')).toBe( + '+15d' + ); expect(formatMeasureVariation(7 * ONE_MINUTE, 'SHORT_WORK_DUR')).toBe('+7min'); expect(formatMeasureVariation(-5 * ONE_DAY, 'SHORT_WORK_DUR')).toBe('-5d'); expect(formatMeasureVariation(-2 * ONE_HOUR, 'SHORT_WORK_DUR')).toBe('-2h'); diff --git a/server/sonar-web/src/main/js/helpers/__tests__/path-test.js b/server/sonar-web/src/main/js/helpers/__tests__/path-test.js index 6520af31676..3941b76b9b7 100644 --- a/server/sonar-web/src/main/js/helpers/__tests__/path-test.js +++ b/server/sonar-web/src/main/js/helpers/__tests__/path-test.js @@ -33,13 +33,15 @@ describe('#collapsedDirFromPath()', () => { }); it('should cut long path', () => { - expect(collapsedDirFromPath('src/main/js/components/navigator/app/models/state.js')) - .toBe('src/.../js/components/navigator/app/models/'); + expect(collapsedDirFromPath('src/main/js/components/navigator/app/models/state.js')).toBe( + 'src/.../js/components/navigator/app/models/' + ); }); it('should cut very long path', () => { - expect(collapsedDirFromPath('src/main/another/js/components/navigator/app/models/state.js')) - .toBe('src/.../js/components/navigator/app/models/'); + expect( + collapsedDirFromPath('src/main/another/js/components/navigator/app/models/state.js') + ).toBe('src/.../js/components/navigator/app/models/'); }); }); diff --git a/server/sonar-web/src/main/js/helpers/__tests__/urls-test.js b/server/sonar-web/src/main/js/helpers/__tests__/urls-test.js index 730cea9ef83..c6e54c559d5 100644 --- a/server/sonar-web/src/main/js/helpers/__tests__/urls-test.js +++ b/server/sonar-web/src/main/js/helpers/__tests__/urls-test.js @@ -40,34 +40,47 @@ describe('#getComponentUrl', () => { }); it('should encode component key', () => { - expect(getComponentUrl(COMPLEX_COMPONENT_KEY)).toBe('/dashboard?id=' + COMPLEX_COMPONENT_KEY_ENCODED); + expect(getComponentUrl(COMPLEX_COMPONENT_KEY)).toBe( + '/dashboard?id=' + COMPLEX_COMPONENT_KEY_ENCODED + ); }); it('should take baseUrl into account', () => { window.baseUrl = '/context'; - expect(getComponentUrl(COMPLEX_COMPONENT_KEY)).toBe('/context/dashboard?id=' + COMPLEX_COMPONENT_KEY_ENCODED); + expect(getComponentUrl(COMPLEX_COMPONENT_KEY)).toBe( + '/context/dashboard?id=' + COMPLEX_COMPONENT_KEY_ENCODED + ); }); }); describe('#getComponentIssuesUrl', () => { it('should work without parameters', () => { expect(getComponentIssuesUrl(SIMPLE_COMPONENT_KEY, {})).toBe( - '/component_issues?id=' + SIMPLE_COMPONENT_KEY + '#'); + '/component_issues?id=' + SIMPLE_COMPONENT_KEY + '#' + ); }); it('should encode component key', () => { expect(getComponentIssuesUrl(COMPLEX_COMPONENT_KEY, {})).toBe( - '/component_issues?id=' + COMPLEX_COMPONENT_KEY_ENCODED + '#'); + '/component_issues?id=' + COMPLEX_COMPONENT_KEY_ENCODED + '#' + ); }); it('should work with parameters', () => { expect(getComponentIssuesUrl(SIMPLE_COMPONENT_KEY, { resolved: 'false' })).toBe( - '/component_issues?id=' + SIMPLE_COMPONENT_KEY + '#resolved=false'); + '/component_issues?id=' + SIMPLE_COMPONENT_KEY + '#resolved=false' + ); }); it('should encode parameters', () => { - expect(getComponentIssuesUrl(SIMPLE_COMPONENT_KEY, { componentUuids: COMPLEX_COMPONENT_KEY })).toBe( - '/component_issues?id=' + SIMPLE_COMPONENT_KEY + '#componentUuids=' + COMPLEX_COMPONENT_KEY_ENCODED); + expect( + getComponentIssuesUrl(SIMPLE_COMPONENT_KEY, { componentUuids: COMPLEX_COMPONENT_KEY }) + ).toBe( + '/component_issues?id=' + + SIMPLE_COMPONENT_KEY + + '#componentUuids=' + + COMPLEX_COMPONENT_KEY_ENCODED + ); }); }); diff --git a/server/sonar-web/src/main/js/helpers/constants.js b/server/sonar-web/src/main/js/helpers/constants.js index 4fcd519529a..96422aad693 100644 --- a/server/sonar-web/src/main/js/helpers/constants.js +++ b/server/sonar-web/src/main/js/helpers/constants.js @@ -21,4 +21,10 @@ export const SEVERITIES = ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO']; export const STATUSES = ['OPEN', 'REOPENED', 'CONFIRMED', 'RESOLVED', 'CLOSED']; export const CHART_COLORS_RANGE_PERCENT = ['#00aa00', '#b0d513', '#eabe06', '#ed7d20', '#d4333f']; -export const CHART_REVERSED_COLORS_RANGE_PERCENT = ['#d4333f', '#ed7d20', '#eabe06', '#b0d513', '#00aa00']; +export const CHART_REVERSED_COLORS_RANGE_PERCENT = [ + '#d4333f', + '#ed7d20', + '#eabe06', + '#b0d513', + '#00aa00' +]; diff --git a/server/sonar-web/src/main/js/helpers/cookies.js b/server/sonar-web/src/main/js/helpers/cookies.js index 0a8ee581989..ad2cef2a945 100644 --- a/server/sonar-web/src/main/js/helpers/cookies.js +++ b/server/sonar-web/src/main/js/helpers/cookies.js @@ -20,7 +20,7 @@ // @flow let cookies; -export function getCookie (name: string) { +export function getCookie(name: string) { if (cookies) { return cookies[name]; } diff --git a/server/sonar-web/src/main/js/helpers/csv.js b/server/sonar-web/src/main/js/helpers/csv.js index 05fa990d2ac..c07e0c868d2 100644 --- a/server/sonar-web/src/main/js/helpers/csv.js +++ b/server/sonar-web/src/main/js/helpers/csv.js @@ -18,7 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // @flow -export function csvEscape (value: string): string { +export function csvEscape(value: string): string { const escaped = value.replace(/"/g, '\\"'); return `"${escaped}"`; } diff --git a/server/sonar-web/src/main/js/helpers/handlebars/alertIconClass.js b/server/sonar-web/src/main/js/helpers/handlebars/alertIconClass.js index f7ffa5f14d6..5e62278dc0e 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/alertIconClass.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/alertIconClass.js @@ -19,8 +19,6 @@ */ import Handlebars from 'handlebars/runtime'; -module.exports = function (alert) { - return new Handlebars.default.SafeString( - 'icon-alert-' + alert.toLowerCase() - ); +module.exports = function(alert) { + return new Handlebars.default.SafeString('icon-alert-' + alert.toLowerCase()); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/all.js b/server/sonar-web/src/main/js/helpers/handlebars/all.js index e6700493451..b68d8d6b3df 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/all.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/all.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. */ -module.exports = function (...args) { +module.exports = function(...args) { const options = args[args.length - 1]; const list = args.slice(0, -1); const all = list.reduce((prev, current) => prev && current, true); diff --git a/server/sonar-web/src/main/js/helpers/handlebars/any.js b/server/sonar-web/src/main/js/helpers/handlebars/any.js index c54631ca2a0..d9dd373ddd4 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/any.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/any.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. */ -module.exports = function (...args) { +module.exports = function(...args) { const options = args[args.length - 1]; const list = args.slice(0, -1); const any = list.reduce((prev, current) => prev || current, false); diff --git a/server/sonar-web/src/main/js/helpers/handlebars/avatarHelper.js b/server/sonar-web/src/main/js/helpers/handlebars/avatarHelper.js index b363867eb4b..67220a97d5a 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/avatarHelper.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/avatarHelper.js @@ -20,7 +20,7 @@ import md5 from 'blueimp-md5'; import Handlebars from 'handlebars/runtime'; -function gravatarServer () { +function gravatarServer() { const getStore = require('../../app/utils/getStore').default; const { getSettingValue } = require('../../store/rootReducer'); @@ -28,13 +28,11 @@ function gravatarServer () { return (getSettingValue(store.getState(), 'sonar.lf.gravatarServerUrl') || {}).value; } -module.exports = function (email, size) { +module.exports = function(email, size) { // double the size for high pixel density screens const emailHash = md5.md5((email || '').trim()); - const url = gravatarServer() - .replace('{EMAIL_MD5}', emailHash) - .replace('{SIZE}', size * 2); + const url = gravatarServer().replace('{EMAIL_MD5}', emailHash).replace('{SIZE}', size * 2); return new Handlebars.default.SafeString( - `<img class="rounded" src="${url}" width="${size}" height="${size}" alt="${email}">` + `<img class="rounded" src="${url}" width="${size}" height="${size}" alt="${email}">` ); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/capitalize.js b/server/sonar-web/src/main/js/helpers/handlebars/capitalize.js index 63e2b200913..ee2d3fa8799 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/capitalize.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/capitalize.js @@ -17,6 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -module.exports = function (string) { +module.exports = function(string) { return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase(); }; 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 3ccf6a9be07..ec409ce9add 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'; import { formatMeasure } from '../../helpers/measures'; -module.exports = function (diff) { +module.exports = function(diff) { let message; if (diff.key === 'file') { @@ -28,20 +28,25 @@ module.exports = function (diff) { } if (diff.newValue != null) { - const newValue = diff.key === 'effort' ? - formatMeasure(diff.newValue, 'WORK_DUR') : - diff.newValue; - message = translateWithParameters('issue.changelog.changed_to', - translate('issue.changelog.field', diff.key), newValue); + const newValue = diff.key === 'effort' + ? formatMeasure(diff.newValue, 'WORK_DUR') + : diff.newValue; + message = translateWithParameters( + 'issue.changelog.changed_to', + translate('issue.changelog.field', diff.key), + newValue + ); } else { - message = translateWithParameters('issue.changelog.removed', - translate('issue.changelog.field', diff.key)); + message = translateWithParameters( + 'issue.changelog.removed', + translate('issue.changelog.field', diff.key) + ); } if (diff.oldValue != null) { - const oldValue = diff.key === 'effort' ? - formatMeasure(diff.oldValue, 'WORK_DUR') : - diff.oldValue; + const oldValue = diff.key === 'effort' + ? formatMeasure(diff.oldValue, 'WORK_DUR') + : diff.oldValue; message += ' ('; message += translateWithParameters('issue.changelog.was', oldValue); diff --git a/server/sonar-web/src/main/js/helpers/handlebars/collapsePath.js b/server/sonar-web/src/main/js/helpers/handlebars/collapsePath.js index 9bb0b7584e8..56a8ba3021f 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/collapsePath.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/collapsePath.js @@ -19,6 +19,6 @@ */ import { collapsePath } from '../path'; -module.exports = function (path) { +module.exports = function(path) { return collapsePath(path); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/collapsedDirFromPath.js b/server/sonar-web/src/main/js/helpers/handlebars/collapsedDirFromPath.js index 8eddd1a9364..33dcbdb2294 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/collapsedDirFromPath.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/collapsedDirFromPath.js @@ -19,6 +19,6 @@ */ import { collapsedDirFromPath } from '../path'; -module.exports = function (path) { +module.exports = function(path) { return collapsedDirFromPath(path); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/componentBrowsePermalink.js b/server/sonar-web/src/main/js/helpers/handlebars/componentBrowsePermalink.js index ec104070b26..1786109374c 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/componentBrowsePermalink.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/componentBrowsePermalink.js @@ -17,6 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -module.exports = function (componentKey) { +module.exports = function(componentKey) { return window.baseUrl + '/components/index?id=' + encodeURIComponent(componentKey); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/componentDashboardPermalink.js b/server/sonar-web/src/main/js/helpers/handlebars/componentDashboardPermalink.js index 7c8f7e40422..6f388fb49a8 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/componentDashboardPermalink.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/componentDashboardPermalink.js @@ -17,11 +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. */ -module.exports = function (componentKey, dashboardKey) { - const params = [ - { key: 'id', value: componentKey }, - { key: 'did', value: dashboardKey } - ]; +module.exports = function(componentKey, dashboardKey) { + const params = [{ key: 'id', value: componentKey }, { key: 'did', value: dashboardKey }]; const matchPeriod = window.location.search.match(/period=(\d+)/); if (matchPeriod) { diff --git a/server/sonar-web/src/main/js/helpers/handlebars/componentIssuesPermalink.js b/server/sonar-web/src/main/js/helpers/handlebars/componentIssuesPermalink.js index e849eb51826..cd9aaf55d66 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/componentIssuesPermalink.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/componentIssuesPermalink.js @@ -17,6 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -module.exports = function (componentKey) { +module.exports = function(componentKey) { return window.baseUrl + '/component_issues/index?id=' + encodeURIComponent(componentKey); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/componentPermalink.js b/server/sonar-web/src/main/js/helpers/handlebars/componentPermalink.js index a5ea3eddbb7..4a45d395468 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/componentPermalink.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/componentPermalink.js @@ -17,6 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -module.exports = function (componentKey) { +module.exports = function(componentKey) { return window.baseUrl + '/dashboard/index?id=' + encodeURIComponent(componentKey); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/d.js b/server/sonar-web/src/main/js/helpers/handlebars/d.js index 72d868abb0c..47e0709a26c 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/d.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/d.js @@ -19,6 +19,6 @@ */ import moment from 'moment'; -module.exports = function (date) { +module.exports = function(date) { return moment(date).format('LL'); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/dashboardL10n.js b/server/sonar-web/src/main/js/helpers/handlebars/dashboardL10n.js index 9d7dc2c04c5..2d7819bfabb 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/dashboardL10n.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/dashboardL10n.js @@ -19,7 +19,7 @@ */ import { translate } from '../../helpers/l10n'; -module.exports = function (dashboardName) { +module.exports = function(dashboardName) { const l10nKey = `dashboard.${dashboardName}.name`; const l10nLabel = translate(l10nKey); if (l10nLabel !== l10nKey) { diff --git a/server/sonar-web/src/main/js/helpers/handlebars/dashboardUrl.js b/server/sonar-web/src/main/js/helpers/handlebars/dashboardUrl.js index 5f022fd8d18..fbb5b5ab10b 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/dashboardUrl.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/dashboardUrl.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. */ -module.exports = function (componentKey, componentQualifier) { +module.exports = function(componentKey, componentQualifier) { let url = window.baseUrl + '/dashboard/index?id=' + encodeURIComponent(componentKey); if (componentQualifier === 'FIL' || componentQualifier === 'CLA') { url += '&metric=sqale_index'; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/default.js b/server/sonar-web/src/main/js/helpers/handlebars/default.js index 39650a052ad..4dd7a7d2f5a 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/default.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/default.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. */ -module.exports = function (...args) { +module.exports = function(...args) { const list = args.slice(0, -1); return list.reduce((prev, current) => prev != null ? prev : current, null); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/dirFromPath.js b/server/sonar-web/src/main/js/helpers/handlebars/dirFromPath.js index 8493c686dc8..ef39646e1e4 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/dirFromPath.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/dirFromPath.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. */ -module.exports = function (path) { +module.exports = function(path) { if (typeof path === 'string') { const tokens = path.split('/'); return tokens.length > 1 ? tokens.slice(0, -1).join('/') + '/' : ''; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/ds.js b/server/sonar-web/src/main/js/helpers/handlebars/ds.js index 82d499370b2..52430aef8dc 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/ds.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/ds.js @@ -19,6 +19,6 @@ */ import moment from 'moment'; -module.exports = function (date) { +module.exports = function(date) { return moment(date).format('YYYY-MM-DD'); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/dt.js b/server/sonar-web/src/main/js/helpers/handlebars/dt.js index 07be677136d..c343c4bf17e 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/dt.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/dt.js @@ -19,6 +19,6 @@ */ import moment from 'moment'; -module.exports = function (date) { +module.exports = function(date) { return moment(date).format('LLL'); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/durationFromNow.js b/server/sonar-web/src/main/js/helpers/handlebars/durationFromNow.js index ae052bafccc..fec9cb09b05 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/durationFromNow.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/durationFromNow.js @@ -19,6 +19,6 @@ */ import moment from 'moment'; -module.exports = function (date, units) { +module.exports = function(date, units) { return moment(new Date()).diff(date, units); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/eachChanged.js b/server/sonar-web/src/main/js/helpers/handlebars/eachChanged.js index c47748382a7..15c202363d7 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/eachChanged.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/eachChanged.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. */ -module.exports = function (context, property, options) { +module.exports = function(context, property, options) { let ret = ''; context.forEach((d, i) => { const changed = i > 0 ? d[property] !== context[i - 1][property] : true; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/eachEven.js b/server/sonar-web/src/main/js/helpers/handlebars/eachEven.js index 08da2f5d2e2..418147dd589 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/eachEven.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/eachEven.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. */ -module.exports = function (context, options) { +module.exports = function(context, options) { let ret = ''; context.forEach((d, i) => { if (i % 2 === 0) { diff --git a/server/sonar-web/src/main/js/helpers/handlebars/eachIndex.js b/server/sonar-web/src/main/js/helpers/handlebars/eachIndex.js index 380d667fb2b..51289bf6c1c 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/eachIndex.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/eachIndex.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. */ -module.exports = function (context, options) { +module.exports = function(context, options) { let ret = ''; context.forEach((d, index) => { const c = { index, ...d }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/eachOdd.js b/server/sonar-web/src/main/js/helpers/handlebars/eachOdd.js index 8ec991eb479..c25ff315438 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/eachOdd.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/eachOdd.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. */ -module.exports = function (context, options) { +module.exports = function(context, options) { let ret = ''; context.forEach((d, i) => { if (i % 2 === 1) { diff --git a/server/sonar-web/src/main/js/helpers/handlebars/eachReverse.js b/server/sonar-web/src/main/js/helpers/handlebars/eachReverse.js index fd110a74931..aebecc4a762 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/eachReverse.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/eachReverse.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. */ -module.exports = function (array, options) { +module.exports = function(array, options) { let ret = ''; if (array && array.length > 0) { diff --git a/server/sonar-web/src/main/js/helpers/handlebars/eachWithPrevious.js b/server/sonar-web/src/main/js/helpers/handlebars/eachWithPrevious.js index 140c4f8c01b..c65330c0e2a 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/eachWithPrevious.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/eachWithPrevious.js @@ -17,13 +17,13 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -module.exports = function (context, options) { +module.exports = function(context, options) { let ret = ''; if (Array.isArray(context)) { context.forEach((element, index, list) => { const previous = index > 0 ? list[index - 1] : null; - const c = { '_previous': previous, ...element }; + const c = { _previous: previous, ...element }; ret += options.fn(c); }); } diff --git a/server/sonar-web/src/main/js/helpers/handlebars/empty.js b/server/sonar-web/src/main/js/helpers/handlebars/empty.js index b9641e09b32..b6292bc3dfa 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/empty.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/empty.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. */ -module.exports = function (array, options) { +module.exports = function(array, options) { const cond = Array.isArray(array) && array.length > 0; return cond ? options.inverse(this) : options.fn(this); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/eq.js b/server/sonar-web/src/main/js/helpers/handlebars/eq.js index 030c04aa20c..0036c5909b0 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/eq.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/eq.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. */ -module.exports = function (v1, v2, options) { +module.exports = function(v1, v2, options) { /* eslint eqeqeq: 0 */ return v1 == v2 ? options.fn(this) : options.inverse(this); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/eqComponents.js b/server/sonar-web/src/main/js/helpers/handlebars/eqComponents.js index 6fa5faeff0d..1094adc8048 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/eqComponents.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/eqComponents.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. */ -module.exports = function (a, b, options) { - const notEq = a && b && ((a.project !== b.project) || (a.subProject !== b.subProject)); +module.exports = function(a, b, options) { + const notEq = a && b && (a.project !== b.project || a.subProject !== b.subProject); return notEq ? options.inverse(this) : options.fn(this); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/exporterUrl.js b/server/sonar-web/src/main/js/helpers/handlebars/exporterUrl.js index 40ceb13406b..e7cee0663e8 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/exporterUrl.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/exporterUrl.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. */ -module.exports = function (profile, exporterKey) { +module.exports = function(profile, exporterKey) { let url = window.baseUrl + '/api/qualityprofiles/export'; url += '?language=' + encodeURIComponent(profile.language); url += '&name=' + encodeURIComponent(profile.name); diff --git a/server/sonar-web/src/main/js/helpers/handlebars/fileFromPath.js b/server/sonar-web/src/main/js/helpers/handlebars/fileFromPath.js index 0380a1ab091..cbd67c58103 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/fileFromPath.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/fileFromPath.js @@ -19,6 +19,6 @@ */ import { fileFromPath } from '../path'; -module.exports = function (path) { +module.exports = function(path) { return fileFromPath(path); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/formatFacetValue.js b/server/sonar-web/src/main/js/helpers/handlebars/formatFacetValue.js index 4358c116440..13ab82b9342 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/formatFacetValue.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/formatFacetValue.js @@ -19,8 +19,7 @@ */ import { formatMeasure } from '../measures'; -module.exports = function (value, facetMode) { +module.exports = function(value, facetMode) { const formatter = facetMode === 'effort' ? 'SHORT_WORK_DUR' : 'SHORT_INT'; return formatMeasure(value, formatter); }; - diff --git a/server/sonar-web/src/main/js/helpers/handlebars/formatMeasure.js b/server/sonar-web/src/main/js/helpers/handlebars/formatMeasure.js index 7c793c4818f..2d0c4f75a3a 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/formatMeasure.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/formatMeasure.js @@ -19,6 +19,6 @@ */ import { formatMeasure } from '../measures'; -module.exports = function (measure, type) { +module.exports = function(measure, type) { return formatMeasure(measure, type); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/formatMeasureVariation.js b/server/sonar-web/src/main/js/helpers/handlebars/formatMeasureVariation.js index 4691729bc14..0f7268b8d45 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/formatMeasureVariation.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/formatMeasureVariation.js @@ -19,6 +19,6 @@ */ import { formatMeasureVariation } from '../measures'; -module.exports = function (measure, type) { +module.exports = function(measure, type) { return formatMeasureVariation(measure, type); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/fromNow.js b/server/sonar-web/src/main/js/helpers/handlebars/fromNow.js index dc2f302ad0a..5d4fc596ef5 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/fromNow.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/fromNow.js @@ -19,6 +19,6 @@ */ import moment from 'moment'; -module.exports = function (date) { +module.exports = function(date) { return moment(date).fromNow(); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/gt.js b/server/sonar-web/src/main/js/helpers/handlebars/gt.js index 7b8ab5ce735..b080892436d 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/gt.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/gt.js @@ -17,6 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -module.exports = function (v1, v2, options) { +module.exports = function(v1, v2, options) { return v1 > v2 ? options.fn(this) : options.inverse(this); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/ifLength.js b/server/sonar-web/src/main/js/helpers/handlebars/ifLength.js index 747ecd2a23a..df7578ac096 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/ifLength.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/ifLength.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. */ -module.exports = function (array, len, options) { +module.exports = function(array, len, options) { const cond = Array.isArray(array) && array.length === +len; return cond ? options.fn(this) : options.inverse(this); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/ifLengthGT.js b/server/sonar-web/src/main/js/helpers/handlebars/ifLengthGT.js index 840e34d71d4..79ee2daf7fc 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/ifLengthGT.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/ifLengthGT.js @@ -17,8 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -module.exports = function (array, len, options) { - return Array.isArray(array) && array.length > len ? - options.fn(this) : - options.inverse(this); +module.exports = function(array, len, options) { + return Array.isArray(array) && array.length > len ? options.fn(this) : options.inverse(this); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/ifMeasureShouldBeShown.js b/server/sonar-web/src/main/js/helpers/handlebars/ifMeasureShouldBeShown.js index 76daf8434c8..ba482982a56 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/ifMeasureShouldBeShown.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/ifMeasureShouldBeShown.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. */ -module.exports = function (measure, period, options) { +module.exports = function(measure, period, options) { if (measure != null || period != null) { return options.fn(this); } else { diff --git a/server/sonar-web/src/main/js/helpers/handlebars/ifNotEmpty.js b/server/sonar-web/src/main/js/helpers/handlebars/ifNotEmpty.js index 868c2442f40..7cf02fd690e 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/ifNotEmpty.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/ifNotEmpty.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. */ -module.exports = function (...args) { +module.exports = function(...args) { const options = args[args.length - 1]; const list = args.slice(0, -1); const notEmpty = list.reduce((prev, current) => prev || (current && current.length > 0), false); diff --git a/server/sonar-web/src/main/js/helpers/handlebars/ifSCMChanged.js b/server/sonar-web/src/main/js/helpers/handlebars/ifSCMChanged.js index ac1b427f8e4..567966a17b1 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/ifSCMChanged.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/ifSCMChanged.js @@ -17,13 +17,14 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -module.exports = function (source, line, options) { +module.exports = function(source, line, options) { const currentLine = source.find(row => row.lineNumber === line); const prevLine = source.find(row => row.lineNumber === line - 1); let changed = true; if (currentLine && prevLine && currentLine.scm && prevLine.scm) { - changed = (currentLine.scm.author !== prevLine.scm.author) || - (currentLine.scm.date !== prevLine.scm.date) || (!prevLine.show); + changed = currentLine.scm.author !== prevLine.scm.author || + currentLine.scm.date !== prevLine.scm.date || + !prevLine.show; } return changed ? options.fn(this) : options.inverse(this); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/ifSCMChanged2.js b/server/sonar-web/src/main/js/helpers/handlebars/ifSCMChanged2.js index 1d8c0337576..7b43f90609a 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/ifSCMChanged2.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/ifSCMChanged2.js @@ -17,10 +17,11 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -module.exports = function (currentLine, prevLine, options) { +module.exports = function(currentLine, prevLine, options) { let changed = true; if (currentLine && prevLine && currentLine.scmAuthor && prevLine.scmAuthor) { - changed = (currentLine.scmAuthor !== prevLine.scmAuthor) || (currentLine.scmDate !== prevLine.scmDate); + changed = currentLine.scmAuthor !== prevLine.scmAuthor || + currentLine.scmDate !== prevLine.scmDate; } return changed ? options.fn(this) : options.inverse(this); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/ifShowAvatars.js b/server/sonar-web/src/main/js/helpers/handlebars/ifShowAvatars.js index 9198d30b927..03afa92c69c 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/ifShowAvatars.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/ifShowAvatars.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. */ -function enableGravatar () { +function enableGravatar() { const getStore = require('../../app/utils/getStore').default; const { getSettingValue } = require('../../store/rootReducer'); @@ -25,6 +25,6 @@ function enableGravatar () { return (getSettingValue(store.getState(), 'sonar.lf.enableGravatar') || {}).value === 'true'; } -module.exports = function (options) { +module.exports = function(options) { return enableGravatar() ? options.fn(this) : options.inverse(this); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/ifTestData.js b/server/sonar-web/src/main/js/helpers/handlebars/ifTestData.js index 037472c7453..3890484400a 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/ifTestData.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/ifTestData.js @@ -17,8 +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. */ -module.exports = function (test, options) { - if ((test.status !== 'OK') || ((test.status === 'OK') && test.coveredLines)) { +module.exports = function(test, options) { + if (test.status !== 'OK' || (test.status === 'OK' && test.coveredLines)) { return options.fn(this); } else { return options.inverse(this); diff --git a/server/sonar-web/src/main/js/helpers/handlebars/inArray.js b/server/sonar-web/src/main/js/helpers/handlebars/inArray.js index c6128384140..d27ee3bf395 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/inArray.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/inArray.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. */ -module.exports = function (array, element, options) { +module.exports = function(array, element, options) { if (Array.isArray(array) && array.indexOf(element) !== -1) { return options.fn(this); } else { diff --git a/server/sonar-web/src/main/js/helpers/handlebars/isActiveLink.js b/server/sonar-web/src/main/js/helpers/handlebars/isActiveLink.js index 842178f8495..ece6ad7cbc7 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/isActiveLink.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/isActiveLink.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. */ -module.exports = function (...args) { +module.exports = function(...args) { const options = args[args.length - 1]; const list = args.slice(0, -1); const prefix = list.join(''); diff --git a/server/sonar-web/src/main/js/helpers/handlebars/isNull.js b/server/sonar-web/src/main/js/helpers/handlebars/isNull.js index 83c2b86faa5..7f5de187317 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/isNull.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/isNull.js @@ -17,6 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -module.exports = function (value, options) { +module.exports = function(value, options) { return value == null ? options.fn(this) : options.inverse(this); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/issueFilterHomeLink.js b/server/sonar-web/src/main/js/helpers/handlebars/issueFilterHomeLink.js index f36ab04e62a..c65b1c7a8d0 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/issueFilterHomeLink.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/issueFilterHomeLink.js @@ -17,6 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -module.exports = function (id) { +module.exports = function(id) { return window.baseUrl + '/issues/search#id=' + id; }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/issueFilterValue.js b/server/sonar-web/src/main/js/helpers/handlebars/issueFilterValue.js index ee96ae190e5..4752108a788 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/issueFilterValue.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/issueFilterValue.js @@ -19,7 +19,7 @@ */ import { formatMeasure } from '../measures'; -module.exports = function (value, mode) { +module.exports = function(value, mode) { const formatter = mode === 'effort' ? 'SHORT_WORK_DUR' : 'SHORT_INT'; return formatMeasure(value, formatter); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/issueType.js b/server/sonar-web/src/main/js/helpers/handlebars/issueType.js index 9e7cf60f558..e1e5f96fc2a 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/issueType.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/issueType.js @@ -19,6 +19,6 @@ */ import { translate } from '../../helpers/l10n'; -module.exports = function (issueType) { +module.exports = function(issueType) { return translate('issue.type', issueType); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/issueTypeIcon.js b/server/sonar-web/src/main/js/helpers/handlebars/issueTypeIcon.js index 90df8808442..d7c4d6a7fc6 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/issueTypeIcon.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/issueTypeIcon.js @@ -21,22 +21,22 @@ import Handlebars from 'handlebars/runtime'; /* eslint-disable max-len */ const bug = new Handlebars.default.SafeString( - `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"> + `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"> <path style="fill:currentColor" d="M11 9h1.3l.5.8.8-.5-.8-1.3H11v-.3l2-2.3V3h-1v2l-1 1.2V5c-.1-.8-.7-1.5-1.4-1.9L11 1.8l-.7-.7-1.8 1.6-1.8-1.6-.7.7 1.5 1.3C6.7 3.5 6.1 4.2 6 5v1.1L5 5V3H4v2.3l2 2.3V8H4.2l-.7 1.2.8.5.4-.7H6v.3l-2 1.9V14h1v-2.4l1-1C6 12 7.1 13 8.4 13h.8c.7 0 1.4-.3 1.8-.9.3-.4.3-.9.2-1.4l.9.9V14h1v-2.8l-2-1.9V9zm-2 2H8V6h1v5z"/> </svg>` ); const vulnerability = new Handlebars.default.SafeString( - `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"> + `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"> <path style="fill:currentColor" d="M10.8 5H6V3.9a2.28 2.28 0 0 1 2-2.5 2.22 2.22 0 0 1 1.8 1.2.48.48 0 0 0 .7.2.48.48 0 0 0 .2-.7A3 3 0 0 0 8 .4a3.34 3.34 0 0 0-3 3.5v1.2a2.16 2.16 0 0 0-2 2.1v4.4a2.22 2.22 0 0 0 2.2 2.2h5.6a2.22 2.22 0 0 0 2.2-2.2V7.2A2.22 2.22 0 0 0 10.8 5zm-2.2 5.5v1.2H7.4v-1.2a1.66 1.66 0 0 1-1.1-1.6A1.75 1.75 0 0 1 8 7.2a1.71 1.71 0 0 1 .6 3.3z"/> </svg>` ); const codeSmell = new Handlebars.default.SafeString( - `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"> + `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"> <path style="fill:currentColor" d="M8 2C4.7 2 2 4.7 2 8s2.7 6 6 6 6-2.7 6-6-2.7-6-6-6zm-.5 5.5h.9v.9h-.9v-.9zm-3.8.2c-.1 0-.2-.1-.2-.2 0-.4.1-1.2.6-2S5.3 4.2 5.6 4c.2 0 .3 0 .3.1l1.3 2.3c0 .1 0 .2-.1.2-.1.2-.2.3-.3.5-.1.2-.2.4-.2.5 0 .1-.1.2-.2.2l-2.7-.1zM9.9 12c-.3.2-1.1.5-2 .5-.9 0-1.7-.3-2-.5-.1 0-.1-.2-.1-.3l1.3-2.3c0-.1.1-.1.2-.1.2.1.3.1.5.1s.4 0 .5-.1c.1 0 .2 0 .2.1l1.3 2.3c.2.2.2.3.1.3zm2.5-4.1L9.7 8c-.1 0-.2-.1-.2-.2 0-.2-.1-.4-.2-.5 0-.1-.2-.3-.3-.4-.1 0-.1-.1-.1-.2l1.3-2.3c.1-.1.2-.1.3-.1.3.2 1 .7 1.5 1.5s.6 1.6.6 2c0 0-.1.1-.2.1z"/> </svg>` ); -module.exports = function (type) { +module.exports = function(type) { switch (type) { case 'BUG': return bug; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/join.js b/server/sonar-web/src/main/js/helpers/handlebars/join.js index 6f9d4b8124d..b28e2eeb3c1 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/join.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/join.js @@ -17,6 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -module.exports = function (array, separator) { +module.exports = function(array, separator) { return array.join(separator); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/joinEach.js b/server/sonar-web/src/main/js/helpers/handlebars/joinEach.js index 9d6c2437779..5503875561d 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/joinEach.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/joinEach.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. */ -module.exports = function (array, separator, options) { +module.exports = function(array, separator, options) { let ret = ''; if (array && array.length > 0) { diff --git a/server/sonar-web/src/main/js/helpers/handlebars/length.js b/server/sonar-web/src/main/js/helpers/handlebars/length.js index 45292c99899..e35510f5a5d 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/length.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/length.js @@ -17,6 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -module.exports = function (array) { +module.exports = function(array) { return Array.isArray(array) ? array.length : null; }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/limitString.js b/server/sonar-web/src/main/js/helpers/handlebars/limitString.js index 13d1bffc584..ec131d1c76b 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/limitString.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/limitString.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. */ -module.exports = function (str) { +module.exports = function(str) { if (typeof str === 'string') { const LIMIT = 30; return str.length > LIMIT ? str.substr(0, LIMIT) + '...' : str; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/link.js b/server/sonar-web/src/main/js/helpers/handlebars/link.js index db88bdaed9d..e1b6306245b 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/link.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/link.js @@ -17,6 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -module.exports = function (...args) { +module.exports = function(...args) { return window.baseUrl + args.slice(0, -1).join(''); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/log.js b/server/sonar-web/src/main/js/helpers/handlebars/log.js index b552a6ba5c5..aaaa9f39c39 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/log.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/log.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. */ -module.exports = function (...args) { +module.exports = function(...args) { /* eslint no-console: 0 */ console.log(...args.slice(0, -1)); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/lt.js b/server/sonar-web/src/main/js/helpers/handlebars/lt.js index 02166a34062..2aa609a9ee5 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/lt.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/lt.js @@ -17,6 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -module.exports = function (v1, v2, options) { +module.exports = function(v1, v2, options) { return v1 < v2 ? options.fn(this) : options.inverse(this); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/notEmpty.js b/server/sonar-web/src/main/js/helpers/handlebars/notEmpty.js index 45417e52e04..e7140005ceb 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/notEmpty.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/notEmpty.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. */ -module.exports = function (array, options) { +module.exports = function(array, options) { const cond = Array.isArray(array) && array.length > 0; return cond ? options.fn(this) : options.inverse(this); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/notEq.js b/server/sonar-web/src/main/js/helpers/handlebars/notEq.js index e4d4e1ea6d2..18e0be28841 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/notEq.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/notEq.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. */ -module.exports = function (v1, v2, options) { +module.exports = function(v1, v2, options) { /* eslint eqeqeq: 0 */ return v1 != v2 ? options.fn(this) : options.inverse(this); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/notEqComponents.js b/server/sonar-web/src/main/js/helpers/handlebars/notEqComponents.js index 849135fa4c8..34759858286 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/notEqComponents.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/notEqComponents.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. */ -module.exports = function (a, b, options) { - const notEq = a && b && ((a.project !== b.project) || (a.subProject !== b.subProject)); +module.exports = function(a, b, options) { + const notEq = a && b && (a.project !== b.project || a.subProject !== b.subProject); return notEq ? options.fn(this) : options.inverse(this); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/notNull.js b/server/sonar-web/src/main/js/helpers/handlebars/notNull.js index 7731cd09136..9aa3f2b343c 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/notNull.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/notNull.js @@ -17,6 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -module.exports = function (value, options) { +module.exports = function(value, options) { return value != null ? options.fn(this) : options.inverse(this); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/numberShort.js b/server/sonar-web/src/main/js/helpers/handlebars/numberShort.js index 20d1233eb01..c2a86b8a93c 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/numberShort.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/numberShort.js @@ -19,7 +19,7 @@ */ import numeral from 'numeral'; -module.exports = function (number) { +module.exports = function(number) { let format = '0,0'; if (number >= 10000) { format = '0.[0]a'; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/operators.js b/server/sonar-web/src/main/js/helpers/handlebars/operators.js index d18ffbdfcc1..67b12e35717 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/operators.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/operators.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. */ -module.exports = function (options) { +module.exports = function(options) { const ops = ['LT', 'GT', 'EQ', 'NE']; return ops.reduce((prev, current) => prev + options.fn(current), ''); diff --git a/server/sonar-web/src/main/js/helpers/handlebars/parameterChangelog.js b/server/sonar-web/src/main/js/helpers/handlebars/parameterChangelog.js index 75902a3a5b5..0f945dfd629 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/parameterChangelog.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/parameterChangelog.js @@ -20,14 +20,17 @@ import Handlebars from 'handlebars/runtime'; import { translateWithParameters } from '../l10n'; -module.exports = function (value, parameter) { +module.exports = function(value, parameter) { if (parameter) { return new Handlebars.default.SafeString( - translateWithParameters('quality_profiles.parameter_set_to_x', value, parameter) + translateWithParameters('quality_profiles.parameter_set_to_x', value, parameter) ); } else { return new Handlebars.default.SafeString( - translateWithParameters('quality_profiles.changelog.parameter_reset_to_default_value_x', parameter) + translateWithParameters( + 'quality_profiles.changelog.parameter_reset_to_default_value_x', + parameter + ) ); } }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/percent.js b/server/sonar-web/src/main/js/helpers/handlebars/percent.js index f71a9d51d05..5e3e06fb38d 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/percent.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/percent.js @@ -17,9 +17,9 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -module.exports = function (value, total) { +module.exports = function(value, total) { if (total > 0) { - return '' + ((value || 0) / total * 100) + '%'; + return '' + (value || 0) / total * 100 + '%'; } else { return '0%'; } diff --git a/server/sonar-web/src/main/js/helpers/handlebars/profileUrl.js b/server/sonar-web/src/main/js/helpers/handlebars/profileUrl.js index b5531416162..dab5f850fc2 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/profileUrl.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/profileUrl.js @@ -17,6 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -module.exports = function (key) { +module.exports = function(key) { return window.baseUrl + '/profiles/show?key=' + encodeURIComponent(key); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/projectFullName.js b/server/sonar-web/src/main/js/helpers/handlebars/projectFullName.js index 6e5d356f633..e92aa71d550 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/projectFullName.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/projectFullName.js @@ -17,6 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -module.exports = function (component) { - return component.projectName + (component.subProjectName ? (' / ' + component.subProjectName) : ''); +module.exports = function(component) { + return component.projectName + (component.subProjectName ? ' / ' + component.subProjectName : ''); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/qualifierIcon.js b/server/sonar-web/src/main/js/helpers/handlebars/qualifierIcon.js index 44117345c22..4a4f3420a95 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/qualifierIcon.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/qualifierIcon.js @@ -19,8 +19,8 @@ */ import Handlebars from 'handlebars/runtime'; -module.exports = function (qualifier) { +module.exports = function(qualifier) { return new Handlebars.default.SafeString( - qualifier ? `<i class="icon-qualifier-${qualifier.toLowerCase()}"></i>` : '' + qualifier ? `<i class="icon-qualifier-${qualifier.toLowerCase()}"></i>` : '' ); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/recursive.js b/server/sonar-web/src/main/js/helpers/handlebars/recursive.js index 1064215671c..415e9cebcd0 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/recursive.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/recursive.js @@ -19,7 +19,7 @@ */ let audaciousFn; -module.exports = function (children, options) { +module.exports = function(children, options) { let out = ''; if (options.fn !== undefined) { diff --git a/server/sonar-web/src/main/js/helpers/handlebars/repeat.js b/server/sonar-web/src/main/js/helpers/handlebars/repeat.js index 18cb23cac20..a42b736b326 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/repeat.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/repeat.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. */ -module.exports = function (number, options) { +module.exports = function(number, options) { let ret = ''; for (let i = 0; i < number; i++) { ret += options.fn(this); diff --git a/server/sonar-web/src/main/js/helpers/handlebars/rulePermalink.js b/server/sonar-web/src/main/js/helpers/handlebars/rulePermalink.js index af903f2bdb0..e338339a804 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/rulePermalink.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/rulePermalink.js @@ -17,6 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -module.exports = function (ruleKey) { +module.exports = function(ruleKey) { return window.baseUrl + '/coding_rules#rule_key=' + encodeURIComponent(ruleKey); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/severityChangelog.js b/server/sonar-web/src/main/js/helpers/handlebars/severityChangelog.js index e5747acc20f..e57fccf19be 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/severityChangelog.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/severityChangelog.js @@ -20,7 +20,7 @@ import Handlebars from 'handlebars/runtime'; import { translate, translateWithParameters } from '../../helpers/l10n'; -module.exports = function (severity) { +module.exports = function(severity) { const label = `<i class="icon-severity-${severity.toLowerCase()}"></i> ${translate('severity', severity)}`; const message = translateWithParameters('quality_profiles.severity_set_to_x', label); return new Handlebars.default.SafeString(message); diff --git a/server/sonar-web/src/main/js/helpers/handlebars/severityHelper.js b/server/sonar-web/src/main/js/helpers/handlebars/severityHelper.js index 29ed26a53f7..823d68becfa 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/severityHelper.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/severityHelper.js @@ -20,8 +20,8 @@ import Handlebars from 'handlebars/runtime'; import { translate } from '../../helpers/l10n'; -module.exports = function (severity) { +module.exports = function(severity) { return new Handlebars.default.SafeString( - `<i class="icon-severity-${severity.toLowerCase()}"></i> ${translate('severity', severity)}` + `<i class="icon-severity-${severity.toLowerCase()}"></i> ${translate('severity', severity)}` ); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/severityIcon.js b/server/sonar-web/src/main/js/helpers/handlebars/severityIcon.js index 07c765b6fd3..3304bbbc995 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/severityIcon.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/severityIcon.js @@ -19,8 +19,8 @@ */ import Handlebars from 'handlebars/runtime'; -module.exports = function (severity) { +module.exports = function(severity) { return new Handlebars.default.SafeString( - `<i class="icon-severity-${severity.toLowerCase()}"></i>` + `<i class="icon-severity-${severity.toLowerCase()}"></i>` ); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/show.js b/server/sonar-web/src/main/js/helpers/handlebars/show.js index 98295ceecab..886eb58bab1 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/show.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/show.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. */ -module.exports = function (...args) { +module.exports = function(...args) { let ret = null; args.forEach(arg => { if (typeof arg === 'string' && ret == null) { diff --git a/server/sonar-web/src/main/js/helpers/handlebars/statusHelper.js b/server/sonar-web/src/main/js/helpers/handlebars/statusHelper.js index 3a083162b08..69abb0af95b 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/statusHelper.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/statusHelper.js @@ -20,7 +20,7 @@ import Handlebars from 'handlebars/runtime'; import { translate } from '../../helpers/l10n'; -module.exports = function (status, resolution) { +module.exports = function(status, resolution) { let s = `<i class="icon-status-${status.toLowerCase()}"></i> ${translate('issue.status', status)}`; if (resolution != null) { s = s + ' (' + translate('issue.resolution', resolution) + ')'; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/statusIcon.js b/server/sonar-web/src/main/js/helpers/handlebars/statusIcon.js index ef2f35b0672..4d90492d251 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/statusIcon.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/statusIcon.js @@ -19,8 +19,6 @@ */ import Handlebars from 'handlebars/runtime'; -module.exports = function (status) { - return new Handlebars.default.SafeString( - `<i class="icon-status-${status.toLowerCase()}"></i>` - ); +module.exports = function(status) { + return new Handlebars.default.SafeString(`<i class="icon-status-${status.toLowerCase()}"></i>`); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/sum.js b/server/sonar-web/src/main/js/helpers/handlebars/sum.js index b64a222cc70..5136e03dd13 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/sum.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/sum.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. */ -module.exports = function (...args) { +module.exports = function(...args) { const list = args.slice(0, -1); return list.reduce((p, c) => p + +c, 0); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/t.js b/server/sonar-web/src/main/js/helpers/handlebars/t.js index 2392dafc046..d55d8176234 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/t.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/t.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. */ -module.exports = function () { +module.exports = function() { const args = Array.prototype.slice.call(arguments, 0, -1); return window.t.apply(this, args); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/testStatusIcon.js b/server/sonar-web/src/main/js/helpers/handlebars/testStatusIcon.js index 6fb6b6ab9ea..58e82193a42 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/testStatusIcon.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/testStatusIcon.js @@ -19,8 +19,8 @@ */ import Handlebars from 'handlebars/runtime'; -module.exports = function (status) { +module.exports = function(status) { return new Handlebars.default.SafeString( - `<i class="icon-test-status-${status.toLowerCase()}"></i>` + `<i class="icon-test-status-${status.toLowerCase()}"></i>` ); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/testStatusIconClass.js b/server/sonar-web/src/main/js/helpers/handlebars/testStatusIconClass.js index 88f2f2b0a86..e5718e2c22a 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/testStatusIconClass.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/testStatusIconClass.js @@ -19,7 +19,6 @@ */ import Handlebars from 'handlebars/runtime'; -module.exports = function (status) { - return new Handlebars.default.SafeString(`icon-test-status-${status.toLowerCase()}` - ); +module.exports = function(status) { + return new Handlebars.default.SafeString(`icon-test-status-${status.toLowerCase()}`); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/tp.js b/server/sonar-web/src/main/js/helpers/handlebars/tp.js index f54ed3752ad..f3018e23830 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/tp.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/tp.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. */ -module.exports = function () { +module.exports = function() { const args = Array.prototype.slice.call(arguments, 0, -1); return window.tp.apply(this, args); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/unlessLength.js b/server/sonar-web/src/main/js/helpers/handlebars/unlessLength.js index fc0106e2e8c..95c78a4579b 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/unlessLength.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/unlessLength.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. */ -module.exports = function (array, len, options) { +module.exports = function(array, len, options) { const cond = Array.isArray(array) && array.length === +len; return cond ? options.inverse(this) : options.fn(this); }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/withFirst.js b/server/sonar-web/src/main/js/helpers/handlebars/withFirst.js index 53e64522098..eb3f52d7e9d 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/withFirst.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/withFirst.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. */ -module.exports = function (list, options) { +module.exports = function(list, options) { if (list && list.length > 0) { return options.fn(list[0]); } else { diff --git a/server/sonar-web/src/main/js/helpers/handlebars/withLast.js b/server/sonar-web/src/main/js/helpers/handlebars/withLast.js index df9be847002..bf92fbb7a00 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/withLast.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/withLast.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. */ -module.exports = function (list, options) { +module.exports = function(list, options) { if (list && list.length > 0) { return options.fn(list[list.length - 1]); } else { diff --git a/server/sonar-web/src/main/js/helpers/handlebars/withSign.js b/server/sonar-web/src/main/js/helpers/handlebars/withSign.js index cbf9cf8cabb..14511125837 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/withSign.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/withSign.js @@ -17,6 +17,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -module.exports = function (number) { +module.exports = function(number) { return number >= 0 ? '+' + number : '' + number; }; diff --git a/server/sonar-web/src/main/js/helpers/handlebars/withoutFirst.js b/server/sonar-web/src/main/js/helpers/handlebars/withoutFirst.js index e7d63350446..24e0af2c5cb 100644 --- a/server/sonar-web/src/main/js/helpers/handlebars/withoutFirst.js +++ b/server/sonar-web/src/main/js/helpers/handlebars/withoutFirst.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. */ -module.exports = function (list, options) { +module.exports = function(list, options) { if (list && list.length > 1) { return list.slice(1).reduce((prev, current) => prev + options.fn(current), ''); } else { diff --git a/server/sonar-web/src/main/js/helpers/issues.js b/server/sonar-web/src/main/js/helpers/issues.js index 6410fe3e25c..906ee766099 100644 --- a/server/sonar-web/src/main/js/helpers/issues.js +++ b/server/sonar-web/src/main/js/helpers/issues.js @@ -56,9 +56,8 @@ type RawIssue = { textRange?: TextRange }; -export const sortBySeverity = (issues: Array<*>) => ( - sortBy(issues, issue => SEVERITIES.indexOf(issue.severity)) -); +export const sortBySeverity = (issues: Array<*>) => + sortBy(issues, issue => SEVERITIES.indexOf(issue.severity)); const injectRelational = ( issue: RawIssue | Comment, @@ -98,14 +97,16 @@ const prepareClosed = (issue: RawIssue) => { }; const ensureTextRange = (issue: RawIssue) => { - return issue.line && !issue.textRange ? { - textRange: { - startLine: issue.line, - endLine: issue.line, - startOffset: 0, - endOffset: 999999 - } - } : {}; + return issue.line && !issue.textRange + ? { + textRange: { + startLine: issue.line, + endLine: issue.line, + startOffset: 0, + endOffset: 999999 + } + } + : {}; }; export const parseIssueFromResponse = ( diff --git a/server/sonar-web/src/main/js/helpers/l10n.js b/server/sonar-web/src/main/js/helpers/l10n.js index a9360ae5e50..08832e67dd7 100644 --- a/server/sonar-web/src/main/js/helpers/l10n.js +++ b/server/sonar-web/src/main/js/helpers/l10n.js @@ -23,56 +23,56 @@ import { request } from './request'; let messages = {}; -export function translate (...keys: string[]) { +export function translate(...keys: string[]) { const messageKey = keys.join('.'); return messages[messageKey] || messageKey; } -export function translateWithParameters (messageKey: string, ...parameters: Array<string | number>) { +export function translateWithParameters(messageKey: string, ...parameters: Array<string | number>) { const message = messages[messageKey]; if (message) { return parameters - .map(parameter => String(parameter)) - .reduce((acc, parameter, index) => acc.replace(`{${index}}`, parameter), message); + .map(parameter => String(parameter)) + .reduce((acc, parameter, index) => acc.replace(`{${index}}`, parameter), message); } else { return `${messageKey}.${parameters.join('.')}`; } } -export function hasMessage (...keys: string[]) { +export function hasMessage(...keys: string[]) { const messageKey = keys.join('.'); return messages[messageKey] != null; } -function getCurrentLocale () { +function getCurrentLocale() { return window.navigator.languages ? window.navigator.languages[0] : window.navigator.language; } -function makeRequest (params) { +function makeRequest(params) { const url = '/api/l10n/index'; - return request(url) - .setData(params) - .submit() - .then(response => { - switch (response.status) { - case 200: - return response.json(); - case 304: - return JSON.parse(localStorage.getItem('l10n.bundle') || '{}'); - case 401: - window.location = window.baseUrl + '/sessions/new?return_to=' + - encodeURIComponent(window.location.pathname + window.location.search + window.location.hash); - // return unresolved promise to stop the promise chain - // anyway the page will be reloaded - return new Promise(() => {}); - default: - throw new Error('Unexpected status code: ' + response.status); - } - }); + return request(url).setData(params).submit().then(response => { + switch (response.status) { + case 200: + return response.json(); + case 304: + return JSON.parse(localStorage.getItem('l10n.bundle') || '{}'); + case 401: + window.location = window.baseUrl + + '/sessions/new?return_to=' + + encodeURIComponent( + window.location.pathname + window.location.search + window.location.hash + ); + // return unresolved promise to stop the promise chain + // anyway the page will be reloaded + return new Promise(() => {}); + default: + throw new Error('Unexpected status code: ' + response.status); + } + }); } -function checkCachedBundle () { +function checkCachedBundle() { const cached = localStorage.getItem('l10n.bundle'); if (!cached) { @@ -87,7 +87,7 @@ function checkCachedBundle () { } } -export function requestMessages () { +export function requestMessages() { const currentLocale = getCurrentLocale(); const cachedLocale = localStorage.getItem('l10n.locale'); @@ -118,29 +118,29 @@ export function requestMessages () { }); } -export function resetBundle (bundle: Object) { +export function resetBundle(bundle: Object) { messages = bundle; } -export function installGlobal () { +export function installGlobal() { window.t = translate; window.tp = translateWithParameters; window.requestMessages = requestMessages; } -export function getLocalizedDashboardName (baseName: string) { +export function getLocalizedDashboardName(baseName: string) { const l10nKey = `dashboard.${baseName}.name`; const l10nLabel = translate(l10nKey); return l10nLabel !== l10nKey ? l10nLabel : baseName; } -export function getLocalizedMetricName (metric: { key: string, name: string }) { +export function getLocalizedMetricName(metric: { key: string, name: string }) { const bundleKey = `metric.${metric.key}.name`; const fromBundle = translate(bundleKey); return fromBundle !== bundleKey ? fromBundle : metric.name; } -export function getLocalizedMetricDomain (domainName: string) { +export function getLocalizedMetricDomain(domainName: string) { const bundleKey = `metric_domain.${domainName}`; const fromBundle = translate(bundleKey); return fromBundle !== bundleKey ? fromBundle : domainName; diff --git a/server/sonar-web/src/main/js/helpers/latinize.js b/server/sonar-web/src/main/js/helpers/latinize.js index a727244ffa7..05c2d242541 100644 --- a/server/sonar-web/src/main/js/helpers/latinize.js +++ b/server/sonar-web/src/main/js/helpers/latinize.js @@ -25,348 +25,348 @@ /* jscs:disable maximumLineLength */ const defaultDiacriticsRemovalap = [ { - 'base': 'A', - 'letters': '\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F' + base: 'A', + letters: '\u0041\u24B6\uFF21\u00C0\u00C1\u00C2\u1EA6\u1EA4\u1EAA\u1EA8\u00C3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\u00C4\u01DE\u1EA2\u00C5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F' }, { - 'base': 'AA', - 'letters': '\uA732' + base: 'AA', + letters: '\uA732' }, { - 'base': 'AE', - 'letters': '\u00C6\u01FC\u01E2' + base: 'AE', + letters: '\u00C6\u01FC\u01E2' }, { - 'base': 'AO', - 'letters': '\uA734' + base: 'AO', + letters: '\uA734' }, { - 'base': 'AU', - 'letters': '\uA736' + base: 'AU', + letters: '\uA736' }, { - 'base': 'AV', - 'letters': '\uA738\uA73A' + base: 'AV', + letters: '\uA738\uA73A' }, { - 'base': 'AY', - 'letters': '\uA73C' + base: 'AY', + letters: '\uA73C' }, { - 'base': 'B', - 'letters': '\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181' + base: 'B', + letters: '\u0042\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0182\u0181' }, { - 'base': 'C', - 'letters': '\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E' + base: 'C', + letters: '\u0043\u24B8\uFF23\u0106\u0108\u010A\u010C\u00C7\u1E08\u0187\u023B\uA73E' }, { - 'base': 'D', - 'letters': '\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779' + base: 'D', + letters: '\u0044\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018B\u018A\u0189\uA779' }, { - 'base': 'DZ', - 'letters': '\u01F1\u01C4' + base: 'DZ', + letters: '\u01F1\u01C4' }, { - 'base': 'Dz', - 'letters': '\u01F2\u01C5' + base: 'Dz', + letters: '\u01F2\u01C5' }, { - 'base': 'E', - 'letters': '\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E' + base: 'E', + letters: '\u0045\u24BA\uFF25\u00C8\u00C9\u00CA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\u00CB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E' }, { - 'base': 'F', - 'letters': '\u0046\u24BB\uFF26\u1E1E\u0191\uA77B' + base: 'F', + letters: '\u0046\u24BB\uFF26\u1E1E\u0191\uA77B' }, { - 'base': 'G', - 'letters': '\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E' + base: 'G', + letters: '\u0047\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E' }, { - 'base': 'H', - 'letters': '\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D' + base: 'H', + letters: '\u0048\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D' }, { - 'base': 'I', - 'letters': '\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197' + base: 'I', + letters: '\u0049\u24BE\uFF29\u00CC\u00CD\u00CE\u0128\u012A\u012C\u0130\u00CF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197' }, { - 'base': 'J', - 'letters': '\u004A\u24BF\uFF2A\u0134\u0248' + base: 'J', + letters: '\u004A\u24BF\uFF2A\u0134\u0248' }, { - 'base': 'K', - 'letters': '\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2' + base: 'K', + letters: '\u004B\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2' }, { - 'base': 'L', - 'letters': '\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780' + base: 'L', + letters: '\u004C\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780' }, { - 'base': 'LJ', - 'letters': '\u01C7' + base: 'LJ', + letters: '\u01C7' }, { - 'base': 'Lj', - 'letters': '\u01C8' + base: 'Lj', + letters: '\u01C8' }, { - 'base': 'M', - 'letters': '\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C' + base: 'M', + letters: '\u004D\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C' }, { - 'base': 'N', - 'letters': '\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4' + base: 'N', + letters: '\u004E\u24C3\uFF2E\u01F8\u0143\u00D1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u0220\u019D\uA790\uA7A4' }, { - 'base': 'NJ', - 'letters': '\u01CA' + base: 'NJ', + letters: '\u01CA' }, { - 'base': 'Nj', - 'letters': '\u01CB' + base: 'Nj', + letters: '\u01CB' }, { - 'base': 'O', - 'letters': '\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C' + base: 'O', + letters: '\u004F\u24C4\uFF2F\u00D2\u00D3\u00D4\u1ED2\u1ED0\u1ED6\u1ED4\u00D5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\u00D6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\u00D8\u01FE\u0186\u019F\uA74A\uA74C' }, { - 'base': 'OI', - 'letters': '\u01A2' + base: 'OI', + letters: '\u01A2' }, { - 'base': 'OO', - 'letters': '\uA74E' + base: 'OO', + letters: '\uA74E' }, { - 'base': 'OU', - 'letters': '\u0222' + base: 'OU', + letters: '\u0222' }, { - 'base': 'OE', - 'letters': '\u008C\u0152' + base: 'OE', + letters: '\u008C\u0152' }, { - 'base': 'oe', - 'letters': '\u009C\u0153' + base: 'oe', + letters: '\u009C\u0153' }, { - 'base': 'P', - 'letters': '\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754' + base: 'P', + letters: '\u0050\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754' }, { - 'base': 'Q', - 'letters': '\u0051\u24C6\uFF31\uA756\uA758\u024A' + base: 'Q', + letters: '\u0051\u24C6\uFF31\uA756\uA758\u024A' }, { - 'base': 'R', - 'letters': '\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782' + base: 'R', + letters: '\u0052\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782' }, { - 'base': 'S', - 'letters': '\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784' + base: 'S', + letters: '\u0053\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784' }, { - 'base': 'T', - 'letters': '\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786' + base: 'T', + letters: '\u0054\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786' }, { - 'base': 'TZ', - 'letters': '\uA728' + base: 'TZ', + letters: '\uA728' }, { - 'base': 'U', - 'letters': '\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244' + base: 'U', + letters: '\u0055\u24CA\uFF35\u00D9\u00DA\u00DB\u0168\u1E78\u016A\u1E7A\u016C\u00DC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244' }, { - 'base': 'V', - 'letters': '\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245' + base: 'V', + letters: '\u0056\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245' }, { - 'base': 'VY', - 'letters': '\uA760' + base: 'VY', + letters: '\uA760' }, { - 'base': 'W', - 'letters': '\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72' + base: 'W', + letters: '\u0057\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72' }, { - 'base': 'X', - 'letters': '\u0058\u24CD\uFF38\u1E8A\u1E8C' + base: 'X', + letters: '\u0058\u24CD\uFF38\u1E8A\u1E8C' }, { - 'base': 'Y', - 'letters': '\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE' + base: 'Y', + letters: '\u0059\u24CE\uFF39\u1EF2\u00DD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE' }, { - 'base': 'Z', - 'letters': '\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762' + base: 'Z', + letters: '\u005A\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762' }, { - 'base': 'a', - 'letters': '\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250' + base: 'a', + letters: '\u0061\u24D0\uFF41\u1E9A\u00E0\u00E1\u00E2\u1EA7\u1EA5\u1EAB\u1EA9\u00E3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\u00E4\u01DF\u1EA3\u00E5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250' }, { - 'base': 'aa', - 'letters': '\uA733' + base: 'aa', + letters: '\uA733' }, { - 'base': 'ae', - 'letters': '\u00E6\u01FD\u01E3' + base: 'ae', + letters: '\u00E6\u01FD\u01E3' }, { - 'base': 'ao', - 'letters': '\uA735' + base: 'ao', + letters: '\uA735' }, { - 'base': 'au', - 'letters': '\uA737' + base: 'au', + letters: '\uA737' }, { - 'base': 'av', - 'letters': '\uA739\uA73B' + base: 'av', + letters: '\uA739\uA73B' }, { - 'base': 'ay', - 'letters': '\uA73D' + base: 'ay', + letters: '\uA73D' }, { - 'base': 'b', - 'letters': '\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253' + base: 'b', + letters: '\u0062\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253' }, { - 'base': 'c', - 'letters': '\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184' + base: 'c', + letters: '\u0063\u24D2\uFF43\u0107\u0109\u010B\u010D\u00E7\u1E09\u0188\u023C\uA73F\u2184' }, { - 'base': 'd', - 'letters': '\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A' + base: 'd', + letters: '\u0064\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\uA77A' }, { - 'base': 'dz', - 'letters': '\u01F3\u01C6' + base: 'dz', + letters: '\u01F3\u01C6' }, { - 'base': 'e', - 'letters': '\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD' + base: 'e', + letters: '\u0065\u24D4\uFF45\u00E8\u00E9\u00EA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\u00EB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u025B\u01DD' }, { - 'base': 'f', - 'letters': '\u0066\u24D5\uFF46\u1E1F\u0192\uA77C' + base: 'f', + letters: '\u0066\u24D5\uFF46\u1E1F\u0192\uA77C' }, { - 'base': 'g', - 'letters': '\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F' + base: 'g', + letters: '\u0067\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\u1D79\uA77F' }, { - 'base': 'h', - 'letters': '\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265' + base: 'h', + letters: '\u0068\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265' }, { - 'base': 'hv', - 'letters': '\u0195' + base: 'hv', + letters: '\u0195' }, { - 'base': 'i', - 'letters': '\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131' + base: 'i', + letters: '\u0069\u24D8\uFF49\u00EC\u00ED\u00EE\u0129\u012B\u012D\u00EF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131' }, { - 'base': 'j', - 'letters': '\u006A\u24D9\uFF4A\u0135\u01F0\u0249' + base: 'j', + letters: '\u006A\u24D9\uFF4A\u0135\u01F0\u0249' }, { - 'base': 'k', - 'letters': '\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3' + base: 'k', + letters: '\u006B\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3' }, { - 'base': 'l', - 'letters': '\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747' + base: 'l', + letters: '\u006C\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747' }, { - 'base': 'lj', - 'letters': '\u01C9' + base: 'lj', + letters: '\u01C9' }, { - 'base': 'm', - 'letters': '\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F' + base: 'm', + letters: '\u006D\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F' }, { - 'base': 'n', - 'letters': '\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5' + base: 'n', + letters: '\u006E\u24DD\uFF4E\u01F9\u0144\u00F1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5' }, { - 'base': 'nj', - 'letters': '\u01CC' + base: 'nj', + letters: '\u01CC' }, { - 'base': 'o', - 'letters': '\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275' + base: 'o', + letters: '\u006F\u24DE\uFF4F\u00F2\u00F3\u00F4\u1ED3\u1ED1\u1ED7\u1ED5\u00F5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\u00F6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\u00F8\u01FF\u0254\uA74B\uA74D\u0275' }, { - 'base': 'oi', - 'letters': '\u01A3' + base: 'oi', + letters: '\u01A3' }, { - 'base': 'ou', - 'letters': '\u0223' + base: 'ou', + letters: '\u0223' }, { - 'base': 'oo', - 'letters': '\uA74F' + base: 'oo', + letters: '\uA74F' }, { - 'base': 'p', - 'letters': '\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755' + base: 'p', + letters: '\u0070\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755' }, { - 'base': 'q', - 'letters': '\u0071\u24E0\uFF51\u024B\uA757\uA759' + base: 'q', + letters: '\u0071\u24E0\uFF51\u024B\uA757\uA759' }, { - 'base': 'r', - 'letters': '\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783' + base: 'r', + letters: '\u0072\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783' }, { - 'base': 's', - 'letters': '\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B' + base: 's', + letters: '\u0073\u24E2\uFF53\u00DF\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B' }, { - 'base': 't', - 'letters': '\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787' + base: 't', + letters: '\u0074\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787' }, { - 'base': 'tz', - 'letters': '\uA729' + base: 'tz', + letters: '\uA729' }, { - 'base': 'u', - 'letters': '\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289' + base: 'u', + letters: '\u0075\u24E4\uFF55\u00F9\u00FA\u00FB\u0169\u1E79\u016B\u1E7B\u016D\u00FC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289' }, { - 'base': 'v', - 'letters': '\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C' + base: 'v', + letters: '\u0076\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C' }, { - 'base': 'vy', - 'letters': '\uA761' + base: 'vy', + letters: '\uA761' }, { - 'base': 'w', - 'letters': '\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73' + base: 'w', + letters: '\u0077\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73' }, { - 'base': 'x', - 'letters': '\u0078\u24E7\uFF58\u1E8B\u1E8D' + base: 'x', + letters: '\u0078\u24E7\uFF58\u1E8B\u1E8D' }, { - 'base': 'y', - 'letters': '\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF' + base: 'y', + letters: '\u0079\u24E8\uFF59\u1EF3\u00FD\u0177\u1EF9\u0233\u1E8F\u00FF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF' }, { - 'base': 'z', - 'letters': '\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763' + base: 'z', + letters: '\u007A\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763' } ]; @@ -379,7 +379,7 @@ for (let i = 0; i < defaultDiacriticsRemovalap.length; i++) { } // "what?" version ... http://jsperf.com/diacritics/12 -function removeDiacritics (str) { +function removeDiacritics(str) { return str.replace(/[^\u0000-\u007E]/g, a => diacriticsMap[a] || a); } diff --git a/server/sonar-web/src/main/js/helpers/measures.js b/server/sonar-web/src/main/js/helpers/measures.js index 69593cecf53..e665b5a809b 100644 --- a/server/sonar-web/src/main/js/helpers/measures.js +++ b/server/sonar-web/src/main/js/helpers/measures.js @@ -20,7 +20,6 @@ import numeral from 'numeral'; import { translate, translateWithParameters } from './l10n'; - const HOURS_IN_DAY = 8; /** @@ -28,7 +27,7 @@ const HOURS_IN_DAY = 8; * @param {string|number} value * @param {string} type */ -export function formatMeasure (value, type) { +export function formatMeasure(value, type) { const formatter = getFormatter(type); return useFormatter(value, formatter); } @@ -38,7 +37,7 @@ export function formatMeasure (value, type) { * @param {string|number} value * @param {string} type */ -export function formatMeasureVariation (value, type) { +export function formatMeasureVariation(value, type) { const formatter = getVariationFormatter(type); return useFormatter(value, formatter); } @@ -48,7 +47,7 @@ export function formatMeasureVariation (value, type) { * @param {string} metricKey * @returns {string} */ -export function localizeMetric (metricKey) { +export function localizeMetric(metricKey) { return translate('metric', metricKey, 'name'); } @@ -57,7 +56,7 @@ export function localizeMetric (metricKey) { * @param {string} type * @returns {string} */ -export function getShortType (type) { +export function getShortType(type) { if (type === 'INT') { return 'SHORT_INT'; } else if (type === 'WORK_DUR') { @@ -72,7 +71,7 @@ export function getShortType (type) { * @param {Array} metrics * @returns {Array} */ -export function enhanceMeasuresWithMetrics (measures, metrics) { +export function enhanceMeasuresWithMetrics(measures, metrics) { return measures.map(measure => { const metric = metrics.find(metric => metric.key === measure.metric); return { ...measure, metric }; @@ -84,7 +83,7 @@ export function enhanceMeasuresWithMetrics (measures, metrics) { * @param measure * @param periodIndex */ -export function getPeriodValue (measure, periodIndex) { +export function getPeriodValue(measure, periodIndex) { const { periods } = measure; const period = periods.find(period => period.index === periodIndex); return period ? period.value : null; @@ -95,7 +94,7 @@ export function getPeriodValue (measure, periodIndex) { * @param {string} metricKey * @returns {boolean} */ -export function isDiffMetric (metricKey) { +export function isDiffMetric(metricKey) { return metricKey.indexOf('new_') === 0; } @@ -103,37 +102,36 @@ export function isDiffMetric (metricKey) { * Helpers */ -function useFormatter (value, formatter) { - return value != null && value !== '' && formatter != null ? - formatter(value) : null; +function useFormatter(value, formatter) { + return value != null && value !== '' && formatter != null ? formatter(value) : null; } -function getFormatter (type) { +function getFormatter(type) { const FORMATTERS = { - 'INT': intFormatter, - 'SHORT_INT': shortIntFormatter, - 'FLOAT': floatFormatter, - 'PERCENT': percentFormatter, - 'WORK_DUR': durationFormatter, - 'SHORT_WORK_DUR': shortDurationFormatter, - 'RATING': ratingFormatter, - 'LEVEL': levelFormatter, - 'MILLISEC': millisecondsFormatter + INT: intFormatter, + SHORT_INT: shortIntFormatter, + FLOAT: floatFormatter, + PERCENT: percentFormatter, + WORK_DUR: durationFormatter, + SHORT_WORK_DUR: shortDurationFormatter, + RATING: ratingFormatter, + LEVEL: levelFormatter, + MILLISEC: millisecondsFormatter }; return FORMATTERS[type] || noFormatter; } -function getVariationFormatter (type) { +function getVariationFormatter(type) { const FORMATTERS = { - 'INT': intVariationFormatter, - 'SHORT_INT': shortIntVariationFormatter, - 'FLOAT': floatVariationFormatter, - 'PERCENT': percentVariationFormatter, - 'WORK_DUR': durationVariationFormatter, - 'SHORT_WORK_DUR': shortDurationVariationFormatter, - 'RATING': emptyFormatter, - 'LEVEL': emptyFormatter, - 'MILLISEC': millisecondsVariationFormatter + INT: intVariationFormatter, + SHORT_INT: shortIntVariationFormatter, + FLOAT: floatVariationFormatter, + PERCENT: percentVariationFormatter, + WORK_DUR: durationVariationFormatter, + SHORT_WORK_DUR: shortDurationVariationFormatter, + RATING: emptyFormatter, + LEVEL: emptyFormatter, + MILLISEC: millisecondsVariationFormatter }; return FORMATTERS[type] || noFormatter; } @@ -142,23 +140,23 @@ function getVariationFormatter (type) { * Formatters */ -function noFormatter (value) { +function noFormatter(value) { return value; } -function emptyFormatter () { +function emptyFormatter() { return null; } -function intFormatter (value) { +function intFormatter(value) { return numeral(value).format('0,0'); } -function intVariationFormatter (value) { +function intVariationFormatter(value) { return numeral(value).format('+0,0'); } -function shortIntFormatter (value) { +function shortIntFormatter(value) { let format = '0,0'; if (value >= 1000) { format = '0.[0]a'; @@ -169,35 +167,35 @@ function shortIntFormatter (value) { return numeral(value).format(format); } -function shortIntVariationFormatter (value) { +function shortIntVariationFormatter(value) { const formatted = shortIntFormatter(Math.abs(value)); return value < 0 ? `-${formatted}` : `+${formatted}`; } -function floatFormatter (value) { +function floatFormatter(value) { return numeral(value).format('0,0.0[0000]'); } -function floatVariationFormatter (value) { +function floatVariationFormatter(value) { return value === 0 ? '+0.0' : numeral(value).format('+0,0.0[0000]'); } -function percentFormatter (value) { +function percentFormatter(value) { value = parseFloat(value); return value === 100 ? '100%' : numeral(value / 100).format('0,0.0%'); } -function percentVariationFormatter (value) { +function percentVariationFormatter(value) { value = parseFloat(value); return value === 0 ? '+0.0%' : numeral(value / 100).format('+0,0.0%'); } -function ratingFormatter (value) { +function ratingFormatter(value) { value = parseInt(value, 10); return String.fromCharCode(97 + value - 1).toUpperCase(); } -function levelFormatter (value) { +function levelFormatter(value) { const l10nKey = 'metric.level.' + value; const result = translate(l10nKey); @@ -205,7 +203,7 @@ function levelFormatter (value) { return l10nKey !== result ? result : value; } -function millisecondsFormatter (value) { +function millisecondsFormatter(value) { const ONE_SECOND = 1000; const ONE_MINUTE = 60 * ONE_SECOND; if (value >= ONE_MINUTE) { @@ -219,7 +217,7 @@ function millisecondsFormatter (value) { } } -function millisecondsVariationFormatter (value) { +function millisecondsVariationFormatter(value) { const absValue = Math.abs(value); const formattedValue = millisecondsFormatter(absValue); return value < 0 ? `-${formattedValue}` : `+${formattedValue}`; @@ -229,49 +227,53 @@ function millisecondsVariationFormatter (value) { * Debt Formatters */ -function shouldDisplayDays (days) { +function shouldDisplayDays(days) { return days > 0; } -function shouldDisplayDaysInShortFormat (days) { +function shouldDisplayDaysInShortFormat(days) { return days > 0.9; } -function shouldDisplayHours (days, hours) { +function shouldDisplayHours(days, hours) { return hours > 0 && days < 10; } -function shouldDisplayHoursInShortFormat (hours) { +function shouldDisplayHoursInShortFormat(hours) { return hours > 0.9; } -function shouldDisplayMinutes (days, hours, minutes) { +function shouldDisplayMinutes(days, hours, minutes) { return minutes > 0 && hours < 10 && days === 0; } -function addSpaceIfNeeded (value) { +function addSpaceIfNeeded(value) { return value.length > 0 ? value + ' ' : value; } -function formatDuration (isNegative, days, hours, minutes) { +function formatDuration(isNegative, days, hours, minutes) { let formatted = ''; if (shouldDisplayDays(days)) { formatted += translateWithParameters('work_duration.x_days', isNegative ? -1 * days : days); } if (shouldDisplayHours(days, hours)) { formatted = addSpaceIfNeeded(formatted); - formatted += translateWithParameters('work_duration.x_hours', - isNegative && formatted.length === 0 ? -1 * hours : hours); + formatted += translateWithParameters( + 'work_duration.x_hours', + isNegative && formatted.length === 0 ? -1 * hours : hours + ); } if (shouldDisplayMinutes(days, hours, minutes)) { formatted = addSpaceIfNeeded(formatted); - formatted += translateWithParameters('work_duration.x_minutes', - isNegative && formatted.length === 0 ? -1 * minutes : minutes); + formatted += translateWithParameters( + 'work_duration.x_minutes', + isNegative && formatted.length === 0 ? -1 * minutes : minutes + ); } return formatted; } -function formatDurationShort (isNegative, days, hours, minutes) { +function formatDurationShort(isNegative, days, hours, minutes) { if (shouldDisplayDaysInShortFormat(days)) { const roundedDays = Math.round(days); const formattedDays = formatMeasure(isNegative ? -1 * roundedDays : roundedDays, 'SHORT_INT'); @@ -280,7 +282,10 @@ function formatDurationShort (isNegative, days, hours, minutes) { if (shouldDisplayHoursInShortFormat(hours)) { const roundedHours = Math.round(hours); - const formattedHours = formatMeasure(isNegative ? -1 * roundedHours : roundedHours, 'SHORT_INT'); + const formattedHours = formatMeasure( + isNegative ? -1 * roundedHours : roundedHours, + 'SHORT_INT' + ); return translateWithParameters('work_duration.x_hours', formattedHours); } @@ -288,7 +293,7 @@ function formatDurationShort (isNegative, days, hours, minutes) { return translateWithParameters('work_duration.x_minutes', formattedMinutes); } -function durationFormatter (value) { +function durationFormatter(value) { if (value === 0 || value === '0') { return '0'; } @@ -302,7 +307,7 @@ function durationFormatter (value) { return formatDuration(isNegative, days, hours, remainingValue); } -function shortDurationFormatter (value) { +function shortDurationFormatter(value) { value = parseInt(value, 10); if (value === 0 || value === '0') { return '0'; @@ -317,7 +322,7 @@ function shortDurationFormatter (value) { return formatDurationShort(isNegative, days, hours, remainingValue); } -function durationVariationFormatter (value) { +function durationVariationFormatter(value) { if (value === 0 || value === '0') { return '+0'; } @@ -325,7 +330,7 @@ function durationVariationFormatter (value) { return formatted[0] !== '-' ? '+' + formatted : formatted; } -function shortDurationVariationFormatter (value) { +function shortDurationVariationFormatter(value) { if (value === 0 || value === '0') { return '+0'; } @@ -333,7 +338,7 @@ function shortDurationVariationFormatter (value) { return formatted[0] !== '-' ? '+' + formatted : formatted; } -function getRatingGrid () { +function getRatingGrid() { // workaround cyclic dependencies const getStore = require('../app/utils/getStore').default; const { getSettingValue } = require('../store/rootReducer'); @@ -344,15 +349,13 @@ function getRatingGrid () { } let maintainabilityRatingGrid; -function getMaintainabilityRatingGrid () { +function getMaintainabilityRatingGrid() { if (maintainabilityRatingGrid) { return maintainabilityRatingGrid; } const str = getRatingGrid(); - const numbers = str.split(',') - .map(s => parseFloat(s)) - .filter(n => !isNaN(n)); + const numbers = str.split(',').map(s => parseFloat(s)).filter(n => !isNaN(n)); if (numbers.length === 4) { maintainabilityRatingGrid = numbers; @@ -363,10 +366,9 @@ function getMaintainabilityRatingGrid () { return maintainabilityRatingGrid; } -function getMaintainabilityRatingTooltip (rating) { +function getMaintainabilityRatingTooltip(rating) { const maintainabilityGrid = getMaintainabilityRatingGrid(); - const maintainabilityRatingThreshold = - maintainabilityGrid[Math.floor(rating) - 2]; + const maintainabilityRatingThreshold = maintainabilityGrid[Math.floor(rating) - 2]; if (rating < 2) { return translateWithParameters( @@ -384,12 +386,12 @@ function getMaintainabilityRatingTooltip (rating) { ); } -export function getRatingTooltip (metricKey, value) { +export function getRatingTooltip(metricKey, value) { const ratingLetter = formatMeasure(value, 'RATING'); const finalMetricKey = metricKey.startsWith('new_') ? metricKey.substr(4) : metricKey; - return (finalMetricKey === 'sqale_rating' || finalMetricKey === 'maintainability_rating') ? - getMaintainabilityRatingTooltip(value) : - translate('metric', finalMetricKey, 'tooltip', ratingLetter); + return finalMetricKey === 'sqale_rating' || finalMetricKey === 'maintainability_rating' + ? getMaintainabilityRatingTooltip(value) + : translate('metric', finalMetricKey, 'tooltip', ratingLetter); } diff --git a/server/sonar-web/src/main/js/helpers/path.js b/server/sonar-web/src/main/js/helpers/path.js index 885acb5af11..63153bf6dc8 100644 --- a/server/sonar-web/src/main/js/helpers/path.js +++ b/server/sonar-web/src/main/js/helpers/path.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. */ -export function collapsePath (path, limit = 30) { +export function collapsePath(path, limit = 30) { if (typeof path !== 'string') { return ''; } @@ -50,7 +50,7 @@ export function collapsePath (path, limit = 30) { * @param {string} path * @returns {string|null} */ -export function collapsedDirFromPath (path) { +export function collapsedDirFromPath(path) { const limit = 30; if (typeof path === 'string') { const tokens = path.split('/').slice(0, -1); @@ -82,7 +82,7 @@ export function collapsedDirFromPath (path) { * @param {string} path * @returns {string|null} */ -export function fileFromPath (path) { +export function fileFromPath(path) { if (typeof path === 'string') { const tokens = path.split('/'); return tokens[tokens.length - 1]; @@ -91,7 +91,7 @@ export function fileFromPath (path) { } } -export function splitPath (path) { +export function splitPath(path) { if (typeof path === 'string') { const tokens = path.split('/'); return { diff --git a/server/sonar-web/src/main/js/helpers/periods.js b/server/sonar-web/src/main/js/helpers/periods.js index 59fb828c48f..0677d81c13c 100644 --- a/server/sonar-web/src/main/js/helpers/periods.js +++ b/server/sonar-web/src/main/js/helpers/periods.js @@ -20,7 +20,7 @@ import moment from 'moment'; import { translate, translateWithParameters } from './l10n'; -export function getPeriod (periods, index) { +export function getPeriod(periods, index) { if (!Array.isArray(periods)) { return null; } @@ -28,11 +28,11 @@ export function getPeriod (periods, index) { return periods.find(period => period.index === index); } -export function getLeakPeriod (periods) { +export function getLeakPeriod(periods) { return getPeriod(periods, 1); } -export function getPeriodLabel (period) { +export function getPeriodLabel(period) { if (!period) { return null; } @@ -46,7 +46,7 @@ export function getPeriodLabel (period) { return translateWithParameters(`overview.period.${period.mode}`, parameter); } -export function getPeriodDate (period) { +export function getPeriodDate(period) { if (!period) { return null; } @@ -54,6 +54,6 @@ export function getPeriodDate (period) { return moment(period.date).toDate(); } -export function getLeakPeriodLabel (periods) { +export function getLeakPeriodLabel(periods) { return getPeriodLabel(getLeakPeriod(periods)); } diff --git a/server/sonar-web/src/main/js/helpers/ratings.js b/server/sonar-web/src/main/js/helpers/ratings.js index 9cdd220c127..2bcce15b3df 100644 --- a/server/sonar-web/src/main/js/helpers/ratings.js +++ b/server/sonar-web/src/main/js/helpers/ratings.js @@ -29,33 +29,26 @@ export const getCoverageRatingLabel = rating => { const mapping = ['≥ 80%', '< 80%', '< 70%', '< 50%', '< 30%']; return mapping[rating - 1]; }; - export const getCoverageRatingAverageValue = rating => { checkNumberRating(rating); const mapping = [90, 75, 60, 40, 15]; return mapping[rating - 1]; }; - export const getDuplicationsRatingLabel = rating => { checkNumberRating(rating); - const mapping = ['< 3%', '≥ 3%', '> 5%', '> 10%', '> 20%']; return mapping[rating - 1]; }; - export const getDuplicationsRatingAverageValue = rating => { checkNumberRating(rating); const mapping = [1.5, 4, 7.5, 15, 30]; return mapping[rating - 1]; }; - export const getSizeRatingLabel = rating => { checkNumberRating(rating); - const mapping = ['< 1k', '≥ 1k', '> 10k', '> 100k', '> 500k']; return mapping[rating - 1]; }; - export const getSizeRatingAverageValue = rating => { checkNumberRating(rating); const mapping = [500, 5000, 50000, 250000, 750000]; diff --git a/server/sonar-web/src/main/js/helpers/request.js b/server/sonar-web/src/main/js/helpers/request.js index cbd5a4e7c01..1c0e7777748 100644 --- a/server/sonar-web/src/main/js/helpers/request.js +++ b/server/sonar-web/src/main/js/helpers/request.js @@ -26,11 +26,11 @@ type Response = { status: number }; -export function getCSRFTokenName (): string { +export function getCSRFTokenName(): string { return 'X-XSRF-TOKEN'; } -export function getCSRFTokenValue (): string { +export function getCSRFTokenValue(): string { const cookieName = 'XSRF-TOKEN'; const cookieValue = getCookie(cookieName); if (!cookieValue) { @@ -43,7 +43,7 @@ export function getCSRFTokenValue (): string { * Return an object containing a special http request header used to prevent CSRF attacks. * @returns {Object} */ -export function getCSRFToken (): Object { +export function getCSRFToken(): Object { // Fetch API in Edge doesn't work with empty header, // so we ensure non-empty value const value = getCSRFTokenValue(); @@ -67,7 +67,7 @@ const DEFAULT_OPTIONS: { const DEFAULT_HEADERS: { 'Accept': string } = { - 'Accept': 'application/json' + Accept: 'application/json' }; /** @@ -81,13 +81,13 @@ class Request { headers: Object; data: ?Object; - constructor (url: string): void { + constructor(url: string): void { this.url = url; this.options = {}; this.headers = {}; } - submit () { + submit() { let url: string = this.url; const options = { ...DEFAULT_OPTIONS, ...this.options }; @@ -115,17 +115,17 @@ class Request { return window.fetch(window.baseUrl + url, options); } - setMethod (method: string): Request { + setMethod(method: string): Request { this.options.method = method; return this; } - setData (data?: Object): Request { + setData(data?: Object): Request { this.data = data; return this; } - setHeader (name: string, value: string): Request { + setHeader(name: string, value: string): Request { this.headers[name] = value; return this; } @@ -136,7 +136,7 @@ class Request { * @param {string} url * @returns {Request} */ -export function request (url: string): Request { +export function request(url: string): Request { return new Request(url); } @@ -145,7 +145,7 @@ export function request (url: string): Request { * @param response * @returns {*} */ -export function checkStatus (response: Response): Promise<Object> { +export function checkStatus(response: Response): Promise<Object> { return new Promise((resolve, reject) => { if (response.status === 401) { // workaround cyclic dependencies @@ -165,7 +165,7 @@ export function checkStatus (response: Response): Promise<Object> { * @param response * @returns {object} */ -export function parseJSON (response: Response): Promise<Object> { +export function parseJSON(response: Response): Promise<Object> { return response.json(); } @@ -174,12 +174,8 @@ export function parseJSON (response: Response): Promise<Object> { * @param url * @param data */ -export function getJSON (url: string, data?: Object): Promise<Object> { - return request(url) - .setData(data) - .submit() - .then(checkStatus) - .then(parseJSON); +export function getJSON(url: string, data?: Object): Promise<Object> { + return request(url).setData(data).submit().then(checkStatus).then(parseJSON); } /** @@ -187,13 +183,8 @@ export function getJSON (url: string, data?: Object): Promise<Object> { * @param url * @param data */ -export function postJSON (url: string, data?: Object): Promise<Object> { - return request(url) - .setMethod('POST') - .setData(data) - .submit() - .then(checkStatus) - .then(parseJSON); +export function postJSON(url: string, data?: Object): Promise<Object> { + return request(url).setMethod('POST').setData(data).submit().then(checkStatus).then(parseJSON); } /** @@ -201,12 +192,8 @@ export function postJSON (url: string, data?: Object): Promise<Object> { * @param url * @param data */ -export function post (url: string, data?: Object): Promise<Object> { - return request(url) - .setMethod('POST') - .setData(data) - .submit() - .then(checkStatus); +export function post(url: string, data?: Object): Promise<Object> { + return request(url).setMethod('POST').setData(data).submit().then(checkStatus); } /** @@ -214,12 +201,8 @@ export function post (url: string, data?: Object): Promise<Object> { * @param url * @param data */ -export function requestDelete (url: string, data?: Object): Promise<Object> { - return request(url) - .setMethod('DELETE') - .setData(data) - .submit() - .then(checkStatus); +export function requestDelete(url: string, data?: Object): Promise<Object> { + return request(url).setMethod('DELETE').setData(data).submit().then(checkStatus); } /** @@ -227,6 +210,6 @@ export function requestDelete (url: string, data?: Object): Promise<Object> { * @param response * @returns {Promise} */ -export function delay (response: *): Promise<*> { +export function delay(response: *): Promise<*> { return new Promise(resolve => setTimeout(() => resolve(response), 1200)); } diff --git a/server/sonar-web/src/main/js/helpers/scrolling.js b/server/sonar-web/src/main/js/helpers/scrolling.js index e456eb3b340..fb747932015 100644 --- a/server/sonar-web/src/main/js/helpers/scrolling.js +++ b/server/sonar-web/src/main/js/helpers/scrolling.js @@ -42,21 +42,24 @@ let smoothScrollTop = (y: number, parent) => { const step = Math.ceil(Math.abs(y - scrollTop) / SCROLLING_STEPS); let stepsDone = 0; - const interval = setInterval(() => { - const scrollTop = getScrollPosition(parent); - if (scrollTop === y || SCROLLING_STEPS === stepsDone) { - clearInterval(interval); - } else { - let goal; - if (scrollingDown) { - goal = Math.min(y, scrollTop + step); + const interval = setInterval( + () => { + const scrollTop = getScrollPosition(parent); + if (scrollTop === y || SCROLLING_STEPS === stepsDone) { + clearInterval(interval); } else { - goal = Math.max(y, scrollTop - step); + let goal; + if (scrollingDown) { + goal = Math.min(y, scrollTop + step); + } else { + goal = Math.max(y, scrollTop - step); + } + stepsDone++; + scrollElement(parent, goal); } - stepsDone++; - scrollElement(parent, goal); - } - }, SCROLLING_INTERVAL); + }, + SCROLLING_INTERVAL + ); }; smoothScrollTop = debounce(smoothScrollTop, SCROLLING_DURATION, { leading: true }); @@ -69,7 +72,9 @@ export const scrollToElement = ( ) => { const { top, bottom } = element.getBoundingClientRect(); const scrollTop = getScrollPosition(parent); - const height: number = parent === window ? window.innerHeight : parent.getBoundingClientRect().height; + const height: number = parent === window + ? window.innerHeight + : parent.getBoundingClientRect().height; const parentTop = parent === window ? 0 : parent.getBoundingClientRect().top; diff --git a/server/sonar-web/src/main/js/helpers/testUtils.js b/server/sonar-web/src/main/js/helpers/testUtils.js index e0103b35745..6b6da781fb9 100644 --- a/server/sonar-web/src/main/js/helpers/testUtils.js +++ b/server/sonar-web/src/main/js/helpers/testUtils.js @@ -19,15 +19,15 @@ */ export const click = element => { return element.simulate('click', { - target: { blur () {} }, - currentTarget: { blur () {} }, - preventDefault () {} + target: { blur() {} }, + currentTarget: { blur() {} }, + preventDefault() {} }); }; export const submit = element => { return element.simulate('submit', { - preventDefault () {} + preventDefault() {} }); }; diff --git a/server/sonar-web/src/main/js/helpers/urls.js b/server/sonar-web/src/main/js/helpers/urls.js index 52b155d1d47..571d7a6069e 100644 --- a/server/sonar-web/src/main/js/helpers/urls.js +++ b/server/sonar-web/src/main/js/helpers/urls.js @@ -22,11 +22,11 @@ * @param {string} componentKey * @returns {string} */ -export function getComponentUrl (componentKey) { +export function getComponentUrl(componentKey) { return window.baseUrl + '/dashboard?id=' + encodeURIComponent(componentKey); } -export function getProjectUrl (key) { +export function getProjectUrl(key) { return { pathname: '/dashboard', query: { id: key } @@ -38,10 +38,10 @@ export function getProjectUrl (key) { * @param {object} query * @returns {string} */ -export function getIssuesUrl (query) { - const serializedQuery = Object.keys(query).map(criterion => ( - `${encodeURIComponent(criterion)}=${encodeURIComponent(query[criterion])}` - )).join('|'); +export function getIssuesUrl(query) { + const serializedQuery = Object.keys(query) + .map(criterion => `${encodeURIComponent(criterion)}=${encodeURIComponent(query[criterion])}`) + .join('|'); // return a string (not { pathname }) to help react-router's Link handle this properly return '/issues#' + serializedQuery; @@ -53,10 +53,10 @@ export function getIssuesUrl (query) { * @param {object} query * @returns {string} */ -export function getComponentIssuesUrl (componentKey, query) { - const serializedQuery = Object.keys(query).map(criterion => ( - `${encodeURIComponent(criterion)}=${encodeURIComponent(query[criterion])}` - )).join('|'); +export function getComponentIssuesUrl(componentKey, query) { + const serializedQuery = Object.keys(query) + .map(criterion => `${encodeURIComponent(criterion)}=${encodeURIComponent(query[criterion])}`) + .join('|'); // return a string (not { pathname }) to help react-router's Link handle this properly return '/component_issues?id=' + encodeURIComponent(componentKey) + '#' + serializedQuery; @@ -68,7 +68,7 @@ export function getComponentIssuesUrl (componentKey, query) { * @param {string} metric * @returns {Object} */ -export function getComponentDrilldownUrl (componentKey, metric) { +export function getComponentDrilldownUrl(componentKey, metric) { return { pathname: `/component_measures/metric/${metric}`, query: { id: componentKey } @@ -80,7 +80,7 @@ export function getComponentDrilldownUrl (componentKey, metric) { * @param {string} componentKey * @returns {Object} */ -export function getComponentPermissionsUrl (componentKey) { +export function getComponentPermissionsUrl(componentKey) { return { pathname: '/project_roles', query: { id: componentKey } @@ -92,7 +92,7 @@ export function getComponentPermissionsUrl (componentKey) { * @param {string} key * @returns {Object} */ -export function getQualityProfileUrl (key) { +export function getQualityProfileUrl(key) { return { pathname: '/profiles/show', query: { key } @@ -104,7 +104,7 @@ export function getQualityProfileUrl (key) { * @param {string} key * @returns {Object} */ -export function getQualityGateUrl (key) { +export function getQualityGateUrl(key) { return { pathname: '/quality_gates/show/' + encodeURIComponent(key) }; @@ -115,12 +115,11 @@ export function getQualityGateUrl (key) { * @param {object} query * @returns {string} */ -export function getRulesUrl (query) { +export function getRulesUrl(query) { if (query) { - const serializedQuery = Object.keys(query).map(criterion => ( - `${encodeURIComponent(criterion)}=${encodeURIComponent( - query[criterion])}` - )).join('|'); + const serializedQuery = Object.keys(query) + .map(criterion => `${encodeURIComponent(criterion)}=${encodeURIComponent(query[criterion])}`) + .join('|'); // return a string (not { pathname }) to help react-router's Link handle this properly return '/coding_rules#' + serializedQuery; @@ -134,7 +133,7 @@ export function getRulesUrl (query) { * @param {object} query * @returns {string} */ -export function getDeprecatedActiveRulesUrl (query = {}) { +export function getDeprecatedActiveRulesUrl(query = {}) { const baseQuery = { activation: 'true', statuses: 'DEPRECATED' }; return getRulesUrl({ ...query, ...baseQuery }); } diff --git a/server/sonar-web/src/main/js/helpers/users.js b/server/sonar-web/src/main/js/helpers/users.js index caee94dcabb..cebcbf556b4 100644 --- a/server/sonar-web/src/main/js/helpers/users.js +++ b/server/sonar-web/src/main/js/helpers/users.js @@ -24,6 +24,4 @@ type User = { } }; -export const isUserAdmin = (user: User): boolean => ( - user.permissions.global.includes('admin') -); +export const isUserAdmin = (user: User): boolean => user.permissions.global.includes('admin'); |