Fix issues detected by 'JSHint' and 'JSCS'

Change-Id: Id16d7abe53d5f65c97bf778dc532e404b41283d8
This commit is contained in:
Urs Wolfer
2016-10-19 22:30:42 +02:00
parent a690d72ba4
commit a010547eef
17 changed files with 30 additions and 52 deletions

View File

@@ -105,7 +105,6 @@
},
additions: function() {
var result = [];
return this.accounts.filter(function(account) {
return account._pendingAdd;
}).map(function(account) {
@@ -115,7 +114,6 @@
return {account: account};
}
});
return result;
},
});
})();

View File

@@ -484,7 +484,7 @@
switch (action.__key) {
case ChangeActions.REVERT:
this._setLabelValuesOnRevert(obj.change_id);
// Fall through.
/* falls through */
case RevisionActions.CHERRYPICK:
page.show(this.changePath(obj._number));
break;

View File

@@ -334,15 +334,6 @@ limitations under the License.
test('branch name cleared when re-open cherrypick', function() {
var cherryPickButton =
element.$$('gr-button[data-action-key="cherrypick"]');
var action = {
__key: 'cherrypick',
__type: 'revision',
__primary: false,
enabled: true,
label: 'Cherry Pick',
method: 'POST',
title: 'Cherry pick change to a different branch',
};
var emptyBranchName = '';
element.$.confirmCherrypick.branch = 'master';

View File

@@ -515,14 +515,14 @@ limitations under the License.
patchNum: 2,
};
element._change = {
change_id: 'Iad9dc96274af6946f3632be53b106ef80f7ba6ca',
revisions: {
rev1: {_number: 1},
},
current_revision: 'rev1',
status: element.ChangeStatus.MERGED,
labels: {},
actions: {},
change_id: 'Iad9dc96274af6946f3632be53b106ef80f7ba6ca',
revisions: {
rev1: {_number: 1},
},
current_revision: 'rev1',
status: element.ChangeStatus.MERGED,
labels: {},
actions: {},
};
var urlParamStub = sandbox.stub(element, '_getUrlParameter',
@@ -540,6 +540,7 @@ limitations under the License.
suite('scroll related tests', function() {
test('document scrolling calls function to set scroll height',
function(done) {
var originalHeight = document.body.scrollHeight;
var scrollStub = sandbox.stub(element, '_handleScroll',
function() {
assert.isTrue(scrollStub.called);
@@ -547,7 +548,6 @@ limitations under the License.
originalHeight + 'px';
done();
});
var originalHeight = document.body.scrollHeight;
document.body.style.height = '10000px';
document.body.scrollTop = TEST_SCROLL_TOP_PX;
element._handleScroll();

View File

@@ -150,9 +150,11 @@ limitations under the License.
var toggleLeftDiffStub = sandbox.stub();
// Property getter cannot be stubbed w/ sandbox due to a bug in Sinon.
// https://github.com/sinonjs/sinon/issues/781
var diffsStub = sinon.stub(element, 'diffs', {get: function() {
return [{toggleLeftDiff: toggleLeftDiffStub}];
}});
var diffsStub = sinon.stub(element, 'diffs', {
get: function() {
return [{toggleLeftDiff: toggleLeftDiffStub}];
},
});
MockInteractions.pressAndReleaseKeyOn(element, 65, 'shift'); // 'A'
assert.isTrue(toggleLeftDiffStub.calledOnce);
diffsStub.restore();
@@ -401,7 +403,6 @@ limitations under the License.
};
element.selectedIndex = 0;
flushAsynchronousOperations();
var select = element.$.modeSelect;
var diffDisplay = element.diffs[0];
element._userPrefs = {diff_view: 'SIDE_BY_SIDE'};
assert.equal(element._getDiffViewMode(), 'SIDE_BY_SIDE');

View File

@@ -116,11 +116,6 @@ limitations under the License.
});
test('messages', function() {
var dates = [
'2016-01-12 20:28:33.038000',
'2016-01-12 21:28:33.038000',
'2016-01-12 22:28:33.038000'
];
var author = {
_account_id: 42,
name: 'Marvin the Paranoid Android',

View File

@@ -74,7 +74,7 @@ limitations under the License.
});
test('time and timeEnd', function() {
var nowStub = sinon.stub(element, 'now').returns(0);
var nowStub = sandbox.stub(element, 'now').returns(0);
element.time('foo');
nowStub.returns(1);
element.time('bar');
@@ -99,7 +99,7 @@ limitations under the License.
test('pluginsLoaded reports time', function() {
Gerrit._arePluginsLoaded.returns(true);
var nowStub = sinon.stub(element, 'now').returns(42);
sandbox.stub(element, 'now').returns(42);
element.pluginsLoaded();
assert.isTrue(element.defaultReporter.calledWithExactly(
'timing-report', 'UI Latency', 'PluginsLoaded', 42

View File

@@ -164,7 +164,7 @@
return accounts.map(function(acct) {
return predicate + ':"' + acct.name + ' <' + acct.email + '>"';
});
});
});
},
/**

View File

@@ -69,7 +69,6 @@
GrDiffBuilderSideBySide.prototype._getNextContentOnSide = function(
content, side) {
var tr = content.parentElement.parentElement;
var content;
while (tr = tr.nextSibling) {
content = tr.querySelector(
'td.content .contentText[data-side="' + side + '"]');

View File

@@ -62,7 +62,6 @@
GrDiffBuilderUnified.prototype._getNextContentOnSide = function(
content, side) {
var tr = content.parentElement.parentElement;
var content;
while (tr = tr.nextSibling) {
if (tr.classList.contains('both') || (
(side === 'left' && tr.classList.contains('remove')) ||

View File

@@ -234,10 +234,6 @@ limitations under the License.
});
test('collapsible drafts', function() {
element.addEventListener('reply', function(e) {
assert.ok(e.detail.comment);
done();
});
assert.isTrue(element.collapsed);
assert.isFalse(isVisible(element.$$('gr-linked-text')),
'gr-linked-text is not visible');

View File

@@ -489,6 +489,7 @@ limitations under the License.
resolvePrefs({diff_view: 'UNIFIED'});
flushAsynchronousOperations();
assert.equal(select.value, 'SIDE_BY_SIDE');
getPreferencesStub.restore();
});
test('unified view is always default on small screens', function() {
@@ -522,6 +523,7 @@ limitations under the License.
// On small screens, unified should override user perferences
assert.equal(select.value, 'UNIFIED_DIFF');
getPreferencesStub.restore();
});
test('_loadHash', function() {

View File

@@ -396,12 +396,12 @@
this.patchRange.patchNum,
this.path,
this._handleGetDiffError.bind(this)).then(function(diff) {
this.filesWeblinks = {
meta_a: diff && diff.meta_a && diff.meta_a.web_links,
meta_b: diff && diff.meta_b && diff.meta_b.web_links,
};
return diff;
}.bind(this));
this.filesWeblinks = {
meta_a: diff && diff.meta_a && diff.meta_a.web_links,
meta_b: diff && diff.meta_b && diff.meta_b.web_links,
};
return diff;
}.bind(this));
},
_getDiffComments: function() {

View File

@@ -493,6 +493,7 @@ limitations under the License.
});
var spy = sinon.spy(element, '_handleShowDiff');
element.set('expanded', true);
assert.isTrue(spy.called);
});
});
});

View File

@@ -173,9 +173,6 @@ limitations under the License.
line.beforeNumber = 36;
el.setAttribute('data-side', 'right');
var expectedStart = 6;
var expectedLength = line.text.length - expectedStart;
element.annotate(el, line);
assert.isFalse(annotateElementStub.called);

View File

@@ -47,7 +47,6 @@
'text/x-yaml': 'yaml',
};
var ASYNC_DELAY = 10;
var HLJS_PATH = 'bower_components/highlightjs/highlight.min.js';
var CLASS_WHITELIST = {
'gr-diff gr-syntax gr-syntax-literal': true,
@@ -278,8 +277,8 @@
* @param {!Object} state The processing state for the layer.
*/
_processNextLine: function(state) {
var baseLine = undefined;
var revisionLine = undefined;
var baseLine;
var revisionLine;
var section = this.diff.content[state.sectionIndex];
if (section.ab) {

View File

@@ -311,7 +311,7 @@ limitations under the License.
text: function() { return Promise.resolve(')]}\'{}'); }
},
];
var fetchStub = sandbox.stub(window, 'fetch', function(url) {
sandbox.stub(window, 'fetch', function(url) {
if (url === '/accounts/self/detail') {
return Promise.resolve(responses.shift());
}