From 18acc2ae3c6a8f07be8623e994de728e5eaf6099 Mon Sep 17 00:00:00 2001 From: Chris Gavin Date: Thu, 27 Jul 2017 18:23:58 +0100 Subject: [PATCH] Minor fixes of problems identified by lgtm. (#9732) * Remove an unused argument. * Remove unused assignments. * Fix an incorrect type test. * Remove repeated values from regex character class. * Remove some unnecessary conditionals. * Remove unused dependencies. --- app/common/lib/formatUtil.js | 2 +- app/common/state/navigationBarState.js | 2 +- app/renderer/components/preferences/extensionsTab.js | 2 +- js/contextMenus.js | 2 +- js/lib/debounce.js | 4 ++-- js/lib/urlutil.js | 2 +- js/state/userPrefs.js | 9 +++++---- package.json | 3 --- 8 files changed, 12 insertions(+), 14 deletions(-) diff --git a/app/common/lib/formatUtil.js b/app/common/lib/formatUtil.js index 3525d1e33ea..863febc4502 100644 --- a/app/common/lib/formatUtil.js +++ b/app/common/lib/formatUtil.js @@ -47,7 +47,7 @@ const defaultOrderLookup = (value) => { * Accelerator reference: https://github.com/electron/electron/blob/master/docs/api/accelerator.md */ module.exports.formatAccelerator = (accelerator) => { - let result = accelerator + let result let splitResult = accelerator.split('+') // sort in proper order, based on OS // also, replace w/ name or symbol diff --git a/app/common/state/navigationBarState.js b/app/common/state/navigationBarState.js index bfe5c63d1e4..4dc33923ab2 100644 --- a/app/common/state/navigationBarState.js +++ b/app/common/state/navigationBarState.js @@ -253,7 +253,7 @@ const api = { } if (selected) { // selection implies focus - state = state = api.setFocused(state, tabId, true) + state = api.setFocused(state, tabId, true) } return state.setIn(path.push('selected'), selected) }, diff --git a/app/renderer/components/preferences/extensionsTab.js b/app/renderer/components/preferences/extensionsTab.js index ce2fd7c3da0..af7c5789578 100644 --- a/app/renderer/components/preferences/extensionsTab.js +++ b/app/renderer/components/preferences/extensionsTab.js @@ -113,7 +113,7 @@ class ExtensionsTab extends ImmutableComponent { headings={['icon', 'name', 'description', 'version', 'enabled'] /* 'exclude' */} columnClassNames={this.columnClassNames} rowClassNames={ - this.props.extensions.map(entry => (entry = css(styles.extensionsRow))).toJS() + this.props.extensions.map(entry => css(styles.extensionsRow)).toJS() } rows={this.props.extensions.map(entry => this.getRow(entry))} /> diff --git a/js/contextMenus.js b/js/contextMenus.js index 50079596af9..7095bd4a798 100644 --- a/js/contextMenus.js +++ b/js/contextMenus.js @@ -1288,7 +1288,7 @@ function onUrlBarContextMenu (e) { function onFindBarContextMenu (e) { e.stopPropagation() - const findBarMenu = Menu.buildFromTemplate(findBarTemplateInit(e)) + const findBarMenu = Menu.buildFromTemplate(findBarTemplateInit()) findBarMenu.popup(getCurrentWindow()) } diff --git a/js/lib/debounce.js b/js/lib/debounce.js index 0e676f5414a..cfcffe46446 100644 --- a/js/lib/debounce.js +++ b/js/lib/debounce.js @@ -8,8 +8,8 @@ function debounce (fn, bufferInterval, ...args) { let timeout return (...args2) => { clearTimeout(timeout) - let a = args || [] - if (args2 && args2.constructor === Array) { + let a = args + if (args2.constructor === Array) { a = a.concat(args2) } timeout = setTimeout(fn.apply.bind(fn, this, a), bufferInterval) diff --git a/js/lib/urlutil.js b/js/lib/urlutil.js index 79eab2c0128..9bacb12dec0 100644 --- a/js/lib/urlutil.js +++ b/js/lib/urlutil.js @@ -109,7 +109,7 @@ const UrlUtil = { // - starts with "?" or "." // - contains "? " // - ends with "." (and was not preceded by a domain or /) - const case2Reg = /(^\?)|(\?.+\s)|(^\.)|(^[^.+..+]*[^/]*\.$)/ + const case2Reg = /(^\?)|(\?.+\s)|(^\.)|(^[^.+]*[^/]*\.$)/ // for cases, pure string const case3Reg = /[?./\s:]/ // for cases, data:uri, view-source:uri and about diff --git a/js/state/userPrefs.js b/js/state/userPrefs.js index 1e4ea9d3c98..13f1aa10254 100644 --- a/js/state/userPrefs.js +++ b/js/state/userPrefs.js @@ -10,14 +10,15 @@ let registeredPrivateSessions = {} const setUserPrefType = (ses, path, value) => { switch (typeof value) { case 'object': - ses.userPrefs.setDictionaryPref(path, value) + if (Array.isArray(value)) { + ses.userPrefs.setListPref(path, value) + } else { + ses.userPrefs.setDictionaryPref(path, value) + } break case 'string': ses.userPrefs.setStringPref(path, value) break - case 'array': - ses.userPrefs.setListPref(path, value) - break case 'number': if ((/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i).test(value.to_s())) { ses.userPrefs.setDoublePref(path, value) diff --git a/package.json b/package.json index 4cf2af266b5..9b88391396a 100644 --- a/package.json +++ b/package.json @@ -108,7 +108,6 @@ "lru-cache": "^1.0.0", "moment": "^2.15.1", "niceware": "^1.0.4", - "normalize-url": "^1.7.0", "parse-torrent": "^5.8.1", "prettier-bytes": "^1.0.3", "prop-types": "^15.5.6", @@ -119,8 +118,6 @@ "react-dnd": "^2.1.4", "react-dnd-html5-backend": "^2.1.2", "react-dom": "^15.5.4", - "string.prototype.endswith": "^0.2.0", - "string.prototype.startswith": "^0.2.0", "tablesort": "5.0.0", "tldjs": "1.6.2", "tracking-protection": "1.1.x",