From 4dee88645ab2628b8355b5654704b3ffc704ba9e Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sun, 23 Sep 2018 14:49:56 +0200 Subject: [PATCH] Static analysis fixes --- Account/Account.js | 2 +- Account/AccountManager.js | 2 +- Auth/Auth.js | 2 +- Chart/CandlestickChart.js | 2 +- Chart/PyramidChart.js | 4 +-- Message/Notification/App/AppNotification.js | 2 +- Message/Notification/NotificationMessage.js | 2 +- Security/Hash/Sha1.js | 18 ++++++++--- Security/Hash/Sha1b.js | 30 ++++++++++++------- UI/Input/Mouse/MouseManager.js | 2 +- UI/Input/Voice/VoiceManager.js | 8 ++--- Uri/UriFactory.js | 2 +- Utils/StringUtils.js | 4 +-- tests/Event/EventManagerTest.js | 10 +++---- .../Notification/NotificationManagerTest.js | 2 +- .../Notification/NotificationMessageTest.js | 2 +- 16 files changed, 56 insertions(+), 38 deletions(-) diff --git a/Account/Account.js b/Account/Account.js index d1de4e1..6d64fa9 100644 --- a/Account/Account.js +++ b/Account/Account.js @@ -32,7 +32,7 @@ * * @since 1.0.0 */ - getId () + getId () { return this.id; }; diff --git a/Account/AccountManager.js b/Account/AccountManager.js index d803642..28b89ef 100644 --- a/Account/AccountManager.js +++ b/Account/AccountManager.js @@ -11,7 +11,7 @@ "use strict"; jsOMS.Autoloader.defineNamespace('jsOMS.Account'); - + jsOMS.Account.AccountManager = class { /** * @constructor diff --git a/Auth/Auth.js b/Auth/Auth.js index e3eb7cd..7fe589a 100644 --- a/Auth/Auth.js +++ b/Auth/Auth.js @@ -62,7 +62,7 @@ login () { const authRequest = new jsOMS.Message.Request.Request(); - + authRequest.setUri(this.uri); authRequest.setMethod(jsOMS.Message.Request.RequestMethod.POST); authRequest.setResponseType(jsOMS.Message.Request.RequestType.JSON); diff --git a/Chart/CandlestickChart.js b/Chart/CandlestickChart.js index 3c916d8..18f6856 100644 --- a/Chart/CandlestickChart.js +++ b/Chart/CandlestickChart.js @@ -72,7 +72,7 @@ jsOMS.Chart.CandlestickChart.prototype.draw = function () { - let bar, svg, x, xAxis1, xAxis2, y, yAxis1, yAxis2, xGrid, yGrid, zoom, + let bar, svg, x, xAxis1, xAxis2, y, yAxis1, yAxis2, xGrid, yGrid, zoom, self = this, mm = 50; diff --git a/Chart/PyramidChart.js b/Chart/PyramidChart.js index 1a2599b..ffedcc2 100644 --- a/Chart/PyramidChart.js +++ b/Chart/PyramidChart.js @@ -80,8 +80,8 @@ jsOMS.Chart.PyramidChart.prototype.draw = function () { - let bar, svg, x, xAxis1, xAxis2, y, yAxis1, yAxis2, xGrid, yGrid, zoom, - self = this, + let bar, svg, x, xAxis1, xAxis2, y, yAxis1, yAxis2, xGrid, yGrid, zoom, + self = this, box = this.chart.chartSelect.node().getBoundingClientRect(); this.chart.dimension = { diff --git a/Message/Notification/App/AppNotification.js b/Message/Notification/App/AppNotification.js index 4d82dbe..96a2e51 100644 --- a/Message/Notification/App/AppNotification.js +++ b/Message/Notification/App/AppNotification.js @@ -39,7 +39,7 @@ tpl.parentNode.appendChild(output); - setTimeout(function () + setTimeout(function () { document.getElementsByClassName('log-msg')[0].remove(); }, 3000); diff --git a/Message/Notification/NotificationMessage.js b/Message/Notification/NotificationMessage.js index dc5d250..8398021 100644 --- a/Message/Notification/NotificationMessage.js +++ b/Message/Notification/NotificationMessage.js @@ -13,7 +13,7 @@ jsOMS.Autoloader.defineNamespace('jsOMS.Message.Notification'); jsOMS.Message.Notification.NotificationMessage = class { - constructor(status, title, message) + constructor(status, title, message) { this.status = status; this.title = title; diff --git a/Security/Hash/Sha1.js b/Security/Hash/Sha1.js index a53f355..6ffcb41 100644 --- a/Security/Hash/Sha1.js +++ b/Security/Hash/Sha1.js @@ -6,8 +6,10 @@ SHA1 = function (l) } l += '€'; - for (var n = Math, c = [1518500249, 1859775393, 2400959708, 3395469782, 1732584193, 4023233417, 2562383102, 271733878, 3285377520, 4294967295], s = n.ceil(l.length / 4) + 2, q = n.ceil(s / 16), g = [], a = 0, h = [], j, d, e, f, m, i, b, k; a < q; a++) { + + for (let n = Math, c = [1518500249, 1859775393, 2400959708, 3395469782, 1732584193, 4023233417, 2562383102, 271733878, 3285377520, 4294967295], s = n.ceil(l.length / 4) + 2, q = n.ceil(s / 16), g = [], a = 0, h = [], j, d, e, f, m, i, b, k; a < q; a++) { g[a] = []; + for (k = 0; k < 16; ++k) { function o(b, c) { @@ -17,42 +19,50 @@ SHA1 = function (l) g[a][k] = o(0, 24) | o(1, 16) | o(2, 8) | o(3, 0) } } - i = l.length * 8 - 8; - a = q - 1; + + i = l.length * 8 - 8; + a = q - 1; g[a][14] = i / (c[9] + 1); g[a][14] = n.floor(g[a][14]); g[a][15] = i & c[9]; + for (a = 0; a < q; a++) { for (b = 0; b < 16; b++) { h[b] = g[a][b]; } + for (b = 16; b < 80; b++) { h[b] = p(h[b - 3] ^ h[b - 8] ^ h[b - 14] ^ h[b - 16], 1); } + j = c[4]; d = c[5]; e = c[6]; f = c[7]; m = c[8]; + for (b = 0; b < 80; b++) { - var r = n.floor(b / 20), t = p(j, 5) + (r < 1 ? d & e ^ ~d & f : r == 2 ? d & e ^ d & f ^ e & f : d ^ e ^ f) + m + c[r] + h[b] & c[9]; + let r = n.floor(b / 20), t = p(j, 5) + (r < 1 ? d & e ^ ~d & f : r == 2 ? d & e ^ d & f ^ e & f : d ^ e ^ f) + m + c[r] + h[b] & c[9]; m = f; f = e; e = p(d, 30); d = j; j = t } + c[4] += j; c[5] += d; c[6] += e; c[7] += f; c[8] += m } + i = ""; for (z = 4; z < 9; z++) { for (a = 7; a >= 0; a--) { i += ((c[z] & c[9]) >>> a * 4 & 15).toString(16); } } + return i; }; diff --git a/Security/Hash/Sha1b.js b/Security/Hash/Sha1b.js index c772009..48fc749 100644 --- a/Security/Hash/Sha1b.js +++ b/Security/Hash/Sha1b.js @@ -19,39 +19,42 @@ function SHA1(s) function A(a, b) { - var c = (b & 0xFFFF) + (a & 0xFFFF), d = (b >>> 16) + (a >>> 16) + (c >>> 16); + let c = (b & 0xFFFF) + (a & 0xFFFF), d = (b >>> 16) + (a >>> 16) + (c >>> 16); return ((d & 0xFFFF) << 16) | (c & 0xFFFF) } var B = '0123456789abcdef'; return (function (a) { - var c = [], d = a.length * 4, e; - for (var i = 0; i < d; i++) { + let c = [], d = a.length * 4, e; + for (let i = 0; i < d; i++) { e = a[i >> 2] >> ((3 - (i % 4)) * 8); c.push(B.charAt((e >> 4) & 0xF) + B.charAt(e & 0xF)) } return c.join('') }((function (a, b) { - var c, d, e, f, g, h = a.length, v = 0x67452301, w = 0xefcdab89, x = 0x98badcfe, y = 0x10325476, z = 0xc3d2e1f0, M = []; + let c, d, e, f, g, h = a.length, v = 0x67452301, w = 0xefcdab89, x = 0x98badcfe, y = 0x10325476, z = 0xc3d2e1f0, M = []; U(M, 0x5a827999, 20); U(M, 0x6ed9eba1, 20); U(M, 0x8f1bbcdc, 20); U(M, 0xca62c1d6, 20); - a[b >> 5] |= 0x80 << (24 - (b % 32)); + + a[b >> 5] |= 0x80 << (24 - (b % 32)); a[(((b + 65) >> 9) << 4) + 15] = b; - for (var i = 0; i < h; i += 16) { + + for (let i = 0; i < h; i += 16) { c = v; d = w; e = x; f = y; g = z; - for (var j = 0, O = []; j < 80; j++) { + + for (let j = 0, O = []; j < 80; j++) { O[j] = j < 16 ? a[j + i] : L(O[j - 3] ^ O[j - 8] ^ O[j - 14] ^ O[j - 16], 1); - var k = (function (a, b, c, d, e) + let k = (function (a, b, c, d, e) { - var f = (e & 0xFFFF) + (a & 0xFFFF) + (b & 0xFFFF) + (c & 0xFFFF) + (d & 0xFFFF), g = (e >>> 16) + (a >>> 16) + (b >>> 16) + (c >>> 16) + (d >>> 16) + (f >>> 16); + let f = (e & 0xFFFF) + (a & 0xFFFF) + (b & 0xFFFF) + (c & 0xFFFF) + (d & 0xFFFF), g = (e >>> 16) + (a >>> 16) + (b >>> 16) + (c >>> 16) + (d >>> 16) + (f >>> 16); return ((g & 0xFFFF) << 16) | (f & 0xFFFF) })(j < 20 ? (function (t, a, b) { @@ -60,25 +63,30 @@ function SHA1(s) { return (t & a) ^ (t & b) ^ (a & b) }(d, e, f)) : P(d, e, f), g, M[j], O[j], L(c, 5)); + g = f; f = e; e = L(d, 30); d = c; c = k } + v = A(v, c); w = A(w, d); x = A(x, e); y = A(y, f); z = A(z, g) } + return [v, w, x, y, z] }((function (t) { - var a = [], b = 255, c = t.length * 8; - for (var i = 0; i < c; i += 8) { + let a = [], b = 255, c = t.length * 8; + + for (let i = 0; i < c; i += 8) { a[i >> 5] |= (t.charCodeAt(i / 8) & b) << (24 - (i % 32)) } + return a }(s)).slice(), s.length * 8)))) } diff --git a/UI/Input/Mouse/MouseManager.js b/UI/Input/Mouse/MouseManager.js index e4569b9..5afa620 100644 --- a/UI/Input/Mouse/MouseManager.js +++ b/UI/Input/Mouse/MouseManager.js @@ -110,7 +110,7 @@ length = actions.length; for (let i = 0; i < length; ++i) { - if ((!actions[i].exact || event.target.getAttribute('id') === element) + if ((!actions[i].exact || event.target.getAttribute('id') === element) && actions[i].button === event.button ) { jsOMS.preventAll(event); diff --git a/UI/Input/Voice/VoiceManager.js b/UI/Input/Voice/VoiceManager.js index 84db38c..8fb49cd 100644 --- a/UI/Input/Voice/VoiceManager.js +++ b/UI/Input/Voice/VoiceManager.js @@ -72,7 +72,7 @@ } this.recognition.onstart = function() {}; - this.recognition.onresult = function(event) + this.recognition.onresult = function(event) { let result = jsOMS.trim(event.results[event.resultIndex][0].transcript); @@ -81,16 +81,16 @@ } }; - this.recognition.onspeechend = function() + this.recognition.onspeechend = function() { }; - this.recognition.onnomatch = function(event) + this.recognition.onnomatch = function(event) { jsOMS.Log.Logger.instance.warning('Couldn\'t recognize speech'); }; - this.recognition.onerror = function(event) + this.recognition.onerror = function(event) { jsOMS.Log.Logger.instance.warning('Error during speech recognition: ' + event.error); }; diff --git a/Uri/UriFactory.js b/Uri/UriFactory.js index 74475f2..d3e1096 100644 --- a/Uri/UriFactory.js +++ b/Uri/UriFactory.js @@ -136,7 +136,7 @@ static unique (url) { const parts = url.replace(/\?/g, '&').split('&'), - full = parts[0]; + full = parts[0]; if (parts.length > 1) { parts.shift(); diff --git a/Utils/StringUtils.js b/Utils/StringUtils.js index dd12353..0bb89ac 100644 --- a/Utils/StringUtils.js +++ b/Utils/StringUtils.js @@ -87,7 +87,7 @@ let n = 0, pos = 0; - + while (true) { pos = str.indexOf(substr, pos); @@ -130,7 +130,7 @@ const length = chars.length; let found = haystack.length; let min = haystack.length; - + for (let i = 0; i < length; ++i) { if ((found = haystack.indexOf(chars.charAt(i))) >= 0 && min > found) { min = found; diff --git a/tests/Event/EventManagerTest.js b/tests/Event/EventManagerTest.js index c9edaa5..006e13d 100644 --- a/tests/Event/EventManagerTest.js +++ b/tests/Event/EventManagerTest.js @@ -7,7 +7,7 @@ describe('EventManagerTest', function () it('Testing default functionality', function () { let manager = new jsOMS.Event.EventManager(); - + expect(manager.hasOutstanding('invalid')).toBeFalsy(null); expect(manager.trigger('invalid')).toBeFalsy(null); expect(manager.count()).toBe(0); @@ -19,7 +19,7 @@ describe('EventManagerTest', function () it('Testing base functionality', function () { let manager = new jsOMS.Event.EventManager(); - + expect(manager.attach('group', function() { return true; }, false, false)).toBeTruthy(); expect(manager.attach('group', function() { return true; }, false, false)).toBeFalsy(); expect(manager.count()).toBe(1); @@ -31,7 +31,7 @@ describe('EventManagerTest', function () it('Testing reset functionality', function () { let manager = new jsOMS.Event.EventManager(); - + expect(manager.attach('group', function() { return true; }, false, true)).toBeTruthy(); manager.addGroup('group', 'id1'); manager.addGroup('group', 'id2'); @@ -48,7 +48,7 @@ describe('EventManagerTest', function () it('Testing detach functionality', function () { let manager = new jsOMS.Event.EventManager(); - + expect(manager.attach('group', function() { return true; }, false, true)).toBeTruthy(); manager.addGroup('group', 'id1'); manager.addGroup('group', 'id2'); @@ -65,7 +65,7 @@ describe('EventManagerTest', function () it('Testing remove functionality', function () { let manager = new jsOMS.Event.EventManager(); - + expect(manager.attach('group1', function() { return true; }, true, false)).toBeTruthy(); expect(manager.attach('group2', function() { return true; }, true, false)).toBeTruthy(); expect(manager.count()).toBe(2); diff --git a/tests/Message/Notification/NotificationManagerTest.js b/tests/Message/Notification/NotificationManagerTest.js index 9f4c12a..6b5d1bd 100644 --- a/tests/Message/Notification/NotificationManagerTest.js +++ b/tests/Message/Notification/NotificationManagerTest.js @@ -7,7 +7,7 @@ describe('NotificationManagerTest', function () it('Testing default functionality', function () { let manager = new jsOMS.Message.Notification.NotificationManager(); - + expect(manager.getAppNotifier()).toEqual(jasmine.any(jsOMS.Message.Notification.App.AppNotification)); expect(manager.getBrowserNotifier()).toEqual(jasmine.any(jsOMS.Message.Notification.Browser.BrowserNotification)); }); diff --git a/tests/Message/Notification/NotificationMessageTest.js b/tests/Message/Notification/NotificationMessageTest.js index 62cdbd9..7ade6b8 100644 --- a/tests/Message/Notification/NotificationMessageTest.js +++ b/tests/Message/Notification/NotificationMessageTest.js @@ -7,7 +7,7 @@ describe('NotificationMessageTest', function () it('Testing default functionality', function () { let msg = new jsOMS.Message.Notification.NotificationMessage('ok', 'abc', 'def'); - + expect(msg.status).toBe('ok'); expect(msg.title).toBe('abc'); expect(msg.message).toBe('def');