Fix issues detected by 'JSHint' and 'JSCS'
Change-Id: Ia535be02d19f09e716f00ec8819ba785010798f7
This commit is contained in:
@@ -191,7 +191,9 @@ limitations under the License.
|
||||
'title-change': '_handleTitleChange',
|
||||
},
|
||||
|
||||
observers: [ '_viewChanged(params.view)' ],
|
||||
observers: [
|
||||
'_viewChanged(params.view)',
|
||||
],
|
||||
|
||||
get loggedIn() {
|
||||
return !!(this.account && Object.keys(this.account).length > 0);
|
||||
@@ -213,7 +215,7 @@ limitations under the License.
|
||||
dashboardView: {
|
||||
selectedChangeIndex: 0,
|
||||
},
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
_accountChanged: function() {
|
||||
|
@@ -115,7 +115,9 @@ limitations under the License.
|
||||
},
|
||||
},
|
||||
|
||||
behaviors: [ Gerrit.RESTClientBehavior ],
|
||||
behaviors: [
|
||||
Gerrit.RESTClientBehavior,
|
||||
],
|
||||
|
||||
observers: [
|
||||
'_actionsChanged(actions, _revisionActions)',
|
||||
|
@@ -108,7 +108,9 @@ limitations under the License.
|
||||
},
|
||||
},
|
||||
|
||||
behaviors: [ Gerrit.RESTClientBehavior ],
|
||||
behaviors: [
|
||||
Gerrit.RESTClientBehavior,
|
||||
],
|
||||
|
||||
_computeChangeURL: function(changeNum) {
|
||||
if (!changeNum) { return ''; }
|
||||
@@ -134,8 +136,8 @@ limitations under the License.
|
||||
_computeLabelTitle: function(change, labelName) {
|
||||
var label = change.labels[labelName];
|
||||
if (!label) { return labelName; }
|
||||
var significantLabel = label.rejected || label.approved
|
||||
|| label.disliked || label.recommended;
|
||||
var significantLabel = label.rejected || label.approved ||
|
||||
label.disliked || label.recommended;
|
||||
if (significantLabel && significantLabel.name) {
|
||||
return labelName + '\nby ' + significantLabel.name;
|
||||
}
|
||||
|
@@ -136,7 +136,9 @@ limitations under the License.
|
||||
},
|
||||
},
|
||||
|
||||
behaviors: [ Gerrit.RESTClientBehavior ],
|
||||
behaviors: [
|
||||
Gerrit.RESTClientBehavior,
|
||||
],
|
||||
|
||||
attached: function() {
|
||||
this.fire('title-change', {title: this._query});
|
||||
|
@@ -121,7 +121,9 @@ limitations under the License.
|
||||
},
|
||||
},
|
||||
|
||||
behaviors: [ Gerrit.KeyboardShortcutBehavior ],
|
||||
behaviors: [
|
||||
Gerrit.KeyboardShortcutBehavior,
|
||||
],
|
||||
|
||||
_computeLabelNames: function(groups) {
|
||||
var labels = [];
|
||||
|
@@ -369,7 +369,7 @@ limitations under the License.
|
||||
_handlePatchChange: function(e) {
|
||||
var patchNum = e.target.value;
|
||||
var currentPatchNum =
|
||||
this._change.revisions[this._change.current_revision]._number
|
||||
this._change.revisions[this._change.current_revision]._number;
|
||||
if (patchNum == currentPatchNum) {
|
||||
page.show(this._computeChangePath(this._changeNum));
|
||||
return;
|
||||
@@ -500,7 +500,7 @@ limitations under the License.
|
||||
var labelClassName;
|
||||
var labelValPrefix = '';
|
||||
if (label.value > 0) {
|
||||
labelValPrefix = '+'
|
||||
labelValPrefix = '+';
|
||||
labelClassName = 'approved';
|
||||
} else if (label.value < 0) {
|
||||
labelClassName = 'notApproved';
|
||||
|
@@ -85,7 +85,9 @@ limitations under the License.
|
||||
},
|
||||
},
|
||||
|
||||
behaviors: [ Gerrit.RESTClientBehavior ],
|
||||
behaviors: [
|
||||
Gerrit.RESTClientBehavior,
|
||||
],
|
||||
|
||||
attached: function() {
|
||||
this.fire('title-change', {title: 'My Reviews'});
|
||||
|
@@ -54,7 +54,6 @@ limitations under the License.
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
|
||||
Polymer({
|
||||
is: 'gr-diff-comment-thread',
|
||||
|
||||
|
@@ -157,7 +157,9 @@ limitations under the License.
|
||||
},
|
||||
},
|
||||
|
||||
observers: [ '_prefsChanged(prefs.*)' ],
|
||||
observers: [
|
||||
'_prefsChanged(prefs.*)',
|
||||
],
|
||||
|
||||
_prefsChanged: function(changeRecord) {
|
||||
var prefs = changeRecord.base;
|
||||
|
@@ -174,7 +174,9 @@ limitations under the License.
|
||||
'tap': '_tapHandler',
|
||||
},
|
||||
|
||||
observers: [ '_prefsChanged(prefs.*)' ],
|
||||
observers: [
|
||||
'_prefsChanged(prefs.*)',
|
||||
],
|
||||
|
||||
rowInserted: function(index) {
|
||||
this.renderLineIndexRange(index, index);
|
||||
@@ -243,7 +245,7 @@ limitations under the License.
|
||||
return row.height;
|
||||
}
|
||||
|
||||
var selector = '[data-index="' + index + '"]'
|
||||
var selector = '[data-index="' + index + '"]';
|
||||
var els = Polymer.dom(this.root).querySelectorAll(selector);
|
||||
if (els.length != 2) {
|
||||
throw Error('Rows should only consist of two elements');
|
||||
@@ -564,7 +566,7 @@ limitations under the License.
|
||||
if (numChars > 0 && numChars % this.prefs.line_length == 0) {
|
||||
indices.push(htmlIndex);
|
||||
}
|
||||
htmlIndex = this._advanceChar(html, htmlIndex)
|
||||
htmlIndex = this._advanceChar(html, htmlIndex);
|
||||
if (content[i] == '\t') {
|
||||
numChars += this.prefs.tab_size;
|
||||
} else {
|
||||
|
@@ -217,7 +217,7 @@ limitations under the License.
|
||||
if (!this._loggedIn) { return; }
|
||||
|
||||
this.set('changeViewState.showReplyDropdown', true);
|
||||
// No break here. Allow to fall through.
|
||||
/* falls through */ // required by JSHint
|
||||
case 85: // 'u'
|
||||
if (this._changeNum) {
|
||||
e.preventDefault();
|
||||
|
@@ -197,7 +197,9 @@ limitations under the License.
|
||||
_diffPreferencesPromise: Object, // Used for testing.
|
||||
},
|
||||
|
||||
behaviors: [ Gerrit.RESTClientBehavior ],
|
||||
behaviors: [
|
||||
Gerrit.RESTClientBehavior,
|
||||
],
|
||||
|
||||
observers: [
|
||||
'_prefsChanged(prefs.*)',
|
||||
@@ -221,7 +223,6 @@ limitations under the License.
|
||||
];
|
||||
|
||||
var basePatchNum = this.patchRange.basePatchNum;
|
||||
var patchNum = this.patchRange.patchNum;
|
||||
|
||||
return app.accountReady.then(function() {
|
||||
promises.push(this._getCommentsAndDrafts(basePatchNum, app.loggedIn));
|
||||
@@ -259,8 +260,6 @@ limitations under the License.
|
||||
},
|
||||
|
||||
_getCommentsAndDrafts: function(basePatchNum, loggedIn) {
|
||||
var promises = [];
|
||||
|
||||
function onlyParent(c) { return c.side == 'PARENT'; }
|
||||
function withoutParent(c) { return c.side != 'PARENT'; }
|
||||
|
||||
@@ -544,7 +543,6 @@ limitations under the License.
|
||||
}
|
||||
var chunk = content[i].ab;
|
||||
var currentChunk = {ab: []};
|
||||
var inCommentGroup = false;
|
||||
for (var j = 0; j < chunk.length; j++) {
|
||||
leftLineNum++;
|
||||
rightLineNum++;
|
||||
@@ -590,7 +588,7 @@ limitations under the License.
|
||||
byLine[line] = [];
|
||||
}
|
||||
byLine[line].push(c);
|
||||
}
|
||||
};
|
||||
};
|
||||
allLeft.forEach(mapFunc(leftByLine));
|
||||
allRight.forEach(mapFunc(rightByLine));
|
||||
|
@@ -150,7 +150,7 @@ limitations under the License.
|
||||
var num = patchComments.length;
|
||||
if (num == 0) { return ''; }
|
||||
if (num == 1) { return '1 comment'; }
|
||||
if (num > 1) { return num + ' comments'; };
|
||||
if (num > 1) { return num + ' comments'; }
|
||||
},
|
||||
|
||||
_computeDraftsURL: function(changeNum, patchNum) {
|
||||
@@ -161,7 +161,7 @@ limitations under the License.
|
||||
var num = (drafts[path] || []).length;
|
||||
if (num == 0) { return ''; }
|
||||
if (num == 1) { return '1 draft'; }
|
||||
if (num > 1) { return num + ' drafts'; };
|
||||
if (num > 1) { return num + ' drafts'; }
|
||||
},
|
||||
|
||||
_handleResponse: function(e, req) {
|
||||
@@ -173,7 +173,7 @@ limitations under the License.
|
||||
info.__path = paths[i];
|
||||
info.lines_inserted = info.lines_inserted || 0;
|
||||
info.lines_deleted = info.lines_deleted || 0;
|
||||
files.push(info)
|
||||
files.push(info);
|
||||
}
|
||||
this.files = files;
|
||||
},
|
||||
|
@@ -105,7 +105,7 @@ limitations under the License.
|
||||
},
|
||||
|
||||
_computeCommentsForMessage: function(comments, message, index) {
|
||||
var comments = comments || {};
|
||||
comments = comments || {};
|
||||
var messages = this.messages || [];
|
||||
var msgComments = {};
|
||||
var mDate = util.parseDate(message.date);
|
||||
|
@@ -33,7 +33,9 @@ limitations under the License.
|
||||
|
||||
Polymer({
|
||||
is: 'gr-overlay',
|
||||
behaviors: [ Polymer.IronOverlayBehavior ],
|
||||
behaviors: [
|
||||
Polymer.IronOverlayBehavior,
|
||||
],
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
@@ -194,7 +194,9 @@ limitations under the License.
|
||||
_xhrPromise: Object, // Used for testing.
|
||||
},
|
||||
|
||||
behaviors: [ Gerrit.RESTClientBehavior ],
|
||||
behaviors: [
|
||||
Gerrit.RESTClientBehavior,
|
||||
],
|
||||
|
||||
get opened() {
|
||||
return this.$.dropdown.opened;
|
||||
@@ -234,7 +236,7 @@ limitations under the License.
|
||||
}
|
||||
if (total == 0) { return ''; }
|
||||
if (total == 1) { return '1 Draft'; }
|
||||
if (total > 1) { return total + ' Drafts'; };
|
||||
if (total > 1) { return total + ' Drafts'; }
|
||||
},
|
||||
|
||||
_computeLabelArray: function(labelsObj) {
|
||||
|
@@ -180,7 +180,9 @@ limitations under the License.
|
||||
_xhrPromise: Object,
|
||||
},
|
||||
|
||||
behaviors: [ Gerrit.KeyboardShortcutBehavior ],
|
||||
behaviors: [
|
||||
Gerrit.KeyboardShortcutBehavior,
|
||||
],
|
||||
|
||||
observers: [
|
||||
'_reviewersChanged(change.reviewers.*, change.owner)',
|
||||
@@ -240,7 +242,7 @@ limitations under the License.
|
||||
_handleResponse: function(e) {
|
||||
this._autocompleteData = e.detail.response.filter(function(reviewer) {
|
||||
var account = reviewer.account;
|
||||
if (!account) return true;
|
||||
if (!account) { return true; }
|
||||
for (var i = 0; i < this._reviewers.length; i++) {
|
||||
if (account._account_id == this.change.owner._account_id ||
|
||||
account._account_id == this._reviewers[i]._account_id) {
|
||||
@@ -404,7 +406,7 @@ limitations under the License.
|
||||
}
|
||||
this._autocompleteData = [];
|
||||
this._send('POST', this._restEndpoint(), reviewerID).then(function(req) {
|
||||
this.change.reviewers['CC'] = this.change.reviewers['CC'] || [];
|
||||
this.change.reviewers.CC = this.change.reviewers.CC || [];
|
||||
req.response.reviewers.forEach(function(r) {
|
||||
this.push('change.removable_reviewers', r);
|
||||
this.push('change.reviewers.CC', r);
|
||||
|
@@ -56,7 +56,9 @@ limitations under the License.
|
||||
Polymer({
|
||||
is: 'gr-search-bar',
|
||||
|
||||
behaviors: [ Gerrit.KeyboardShortcutBehavior ],
|
||||
behaviors: [
|
||||
Gerrit.KeyboardShortcutBehavior,
|
||||
],
|
||||
|
||||
listeners: {
|
||||
'searchInput.keydown': '_inputKeyDownHandler',
|
||||
|
@@ -66,7 +66,7 @@ GrLinkTextParser.prototype.parseLinks = function(text, patterns) {
|
||||
var pattern = new RegExp(patterns[p].match, 'g');
|
||||
|
||||
var match;
|
||||
while (match = pattern.exec(text)) {
|
||||
while ((match = pattern.exec(text)) != null) {
|
||||
var before = text.substr(0, match.index);
|
||||
this.addText(before);
|
||||
text = text.substr(match.index + match[0].length);
|
||||
|
@@ -101,7 +101,7 @@ limitations under the License.
|
||||
assert.equal(element.selectedIndex, 0);
|
||||
|
||||
showStub.restore();
|
||||
done()
|
||||
done();
|
||||
}, 1);
|
||||
});
|
||||
|
||||
|
@@ -165,7 +165,7 @@ limitations under the License.
|
||||
assert.isFalse(isVisible(element.$$('.done')), 'done is not visible');
|
||||
|
||||
element.editing = true;
|
||||
assert.isFalse(isVisible(element.$$('.edit')), 'edit is not visible')
|
||||
assert.isFalse(isVisible(element.$$('.edit')), 'edit is not visible');
|
||||
assert.isTrue(isVisible(element.$$('.discard')), 'discard is visible');
|
||||
assert.isTrue(isVisible(element.$$('.save')), 'save is visible');
|
||||
assert.isFalse(isVisible(element.$$('.cancel')), 'cancel is visible');
|
||||
@@ -173,9 +173,9 @@ limitations under the License.
|
||||
assert.isFalse(isVisible(element.$$('.quote')), 'quote is not visible');
|
||||
assert.isFalse(isVisible(element.$$('.done')), 'done is not visible');
|
||||
|
||||
element.draft = false,
|
||||
element.draft = false;
|
||||
element.editing = false;
|
||||
assert.isFalse(isVisible(element.$$('.edit')), 'edit is not visible')
|
||||
assert.isFalse(isVisible(element.$$('.edit')), 'edit is not visible');
|
||||
assert.isFalse(isVisible(element.$$('.discard')),
|
||||
'discard is not visible');
|
||||
assert.isFalse(isVisible(element.$$('.save')), 'save is not visible');
|
||||
@@ -198,7 +198,7 @@ limitations under the License.
|
||||
// Save should be disabled on an empty message.
|
||||
var disabled = element.$$('.save').hasAttribute('disabled');
|
||||
assert.isTrue(disabled, 'save button should be disabled.');
|
||||
element._editDraft == ' ';
|
||||
element._editDraft = ' ';
|
||||
disabled = element.$$('.save').hasAttribute('disabled');
|
||||
assert.isTrue(disabled, 'save button should be disabled.');
|
||||
|
||||
|
@@ -146,7 +146,7 @@ limitations under the License.
|
||||
201,
|
||||
{'Content-Type': 'application/json'},
|
||||
')]}\'\n' + JSON.stringify({
|
||||
id: "7afa4931_de3d65bd",
|
||||
id: '7afa4931_de3d65bd',
|
||||
path: '/path/to/file.txt',
|
||||
line: 5,
|
||||
in_reply_to: 'baf0414d_60047215',
|
||||
|
@@ -64,7 +64,7 @@ limitations under the License.
|
||||
});
|
||||
var cancelPromise = new Promise(function(resolve) {
|
||||
element.addEventListener('cancel', function() { resolve(); });
|
||||
})
|
||||
});
|
||||
Promise.all([savePromise, cancelPromise]).then(function() {
|
||||
done();
|
||||
});
|
||||
|
@@ -84,7 +84,7 @@ limitations under the License.
|
||||
'[[_computeCurrentRevisionMessage(change)]]"></gr-linked-text>';
|
||||
var html = util.escapeHTML(content);
|
||||
var highlights = [
|
||||
{ startIndex: 0, endIndex: 33, },
|
||||
{startIndex: 0, endIndex: 33},
|
||||
{startIndex: 75},
|
||||
];
|
||||
assert.equal(
|
||||
@@ -178,7 +178,7 @@ limitations under the License.
|
||||
}];
|
||||
contentEl = element.$$('.content .code[data-line-num="1"]');
|
||||
assert.ok(contentEl);
|
||||
var spanEl = contentEl.childNodes[1];
|
||||
spanEl = contentEl.childNodes[1];
|
||||
assert.equal(spanEl.tagName, 'SPAN');
|
||||
assert.isTrue(spanEl.classList.contains(
|
||||
'style-scope', 'gr-diff-side', 'tab'));
|
||||
@@ -246,7 +246,7 @@ limitations under the License.
|
||||
|
||||
test('tap line to add a draft', function() {
|
||||
var numAddDraftEvents = 0;
|
||||
var fireMock = sinon.stub(element, 'fire', function(eventName) {
|
||||
sinon.stub(element, 'fire', function(eventName) {
|
||||
if (eventName == 'add-draft') {
|
||||
numAddDraftEvents++;
|
||||
}
|
||||
|
@@ -293,7 +293,7 @@ limitations under the License.
|
||||
newThreadEls[i].classList.contains('commentThread') ||
|
||||
newThreadEls[i].tagName == 'GR-DIFF-COMMENT-THREAD');
|
||||
}
|
||||
var newHeight = newThreadEls[0].offsetHeight
|
||||
var newHeight = newThreadEls[0].offsetHeight;
|
||||
assert.equal(newThreadEls[1].offsetHeight, newHeight);
|
||||
assert.equal(leftFillerEls[0].offsetHeight, newHeight);
|
||||
assert.equal(leftThreadEls[0].offsetHeight, newHeight);
|
||||
@@ -317,13 +317,13 @@ limitations under the License.
|
||||
assert.equal(rightFillerEls[1].offsetHeight, originalHeight);
|
||||
assert.equal(leftThreadEls[0].offsetHeight, originalHeight);
|
||||
assert.equal(leftFillerEls[0].offsetHeight, originalHeight);
|
||||
done()
|
||||
done();
|
||||
});
|
||||
var commentEl = newThreadEls[1].$$('gr-diff-comment');
|
||||
commentEl.fire('discard', null, {bubbles: false});
|
||||
}, 1);
|
||||
}, 1);
|
||||
}),
|
||||
});
|
||||
|
||||
test('intraline normalization', function() {
|
||||
// The content and highlights are in the format returned by the Gerrit
|
||||
|
@@ -93,7 +93,7 @@ limitations under the License.
|
||||
|
||||
test('Change-Id pattern was parsed and linked', function() {
|
||||
// "Change-Id:" pattern.
|
||||
var changeID = 'I11d6a37f5e9b5df0486f6c922d8836dfa780e03e'
|
||||
var changeID = 'I11d6a37f5e9b5df0486f6c922d8836dfa780e03e';
|
||||
var prefix = 'Change-Id: ';
|
||||
element.content = prefix + changeID;
|
||||
|
||||
@@ -110,7 +110,6 @@ limitations under the License.
|
||||
test('Multiple matches', function() {
|
||||
element.content = 'Issue 3650\nIssue 3450';
|
||||
var linkEl1 = element.$.output.childNodes[0];
|
||||
var newlineNode = element.$.output.childNodes[1];
|
||||
var linkEl2 = element.$.output.childNodes[2];
|
||||
|
||||
assert.equal(linkEl1.target, '_blank');
|
||||
|
@@ -154,7 +154,7 @@ limitations under the License.
|
||||
message: 'I wholeheartedly disapprove'
|
||||
});
|
||||
assert.equal(req.response.labels['Code-Review'], -1);
|
||||
assert.equal(req.response.labels['Verified'], -1);
|
||||
assert.equal(req.response.labels.Verified, -1);
|
||||
assert.isFalse(element.opened);
|
||||
done();
|
||||
});
|
||||
|
@@ -51,21 +51,21 @@ limitations under the License.
|
||||
{
|
||||
account: {
|
||||
_account_id: 1021482,
|
||||
name: "Andrew Bonventre",
|
||||
email: "andybons@chromium.org",
|
||||
name: 'Andrew Bonventre',
|
||||
email: 'andybons@chromium.org',
|
||||
}
|
||||
},
|
||||
{
|
||||
account: {
|
||||
_account_id: 1021863,
|
||||
name: "Andrew Bonventre",
|
||||
email: "andybons@google.com",
|
||||
name: 'Andrew Bonventre',
|
||||
email: 'andybons@google.com',
|
||||
}
|
||||
},
|
||||
{
|
||||
"group": {
|
||||
"id": "c7af6dd375c092ff3b23c0937aa910693dc0c41b",
|
||||
"name": "andy"
|
||||
group: {
|
||||
id: 'c7af6dd375c092ff3b23c0937aa910693dc0c41b',
|
||||
name: 'andy',
|
||||
}
|
||||
}
|
||||
]),
|
||||
@@ -198,7 +198,8 @@ limitations under the License.
|
||||
function() {
|
||||
assert(false, 'generateRequest should not be called for input ' +
|
||||
'lengths of less than 3 chars');
|
||||
});
|
||||
}
|
||||
);
|
||||
element._inputVal = 'fo';
|
||||
flushAsynchronousOperations();
|
||||
genRequestStub.restore();
|
||||
|
@@ -23,7 +23,8 @@ limitations under the License.
|
||||
<script>
|
||||
var testFiles = [];
|
||||
|
||||
[ 'gr-account-dropdown-test.html',
|
||||
[
|
||||
'gr-account-dropdown-test.html',
|
||||
'gr-account-label-test.html',
|
||||
'gr-account-link-test.html',
|
||||
'gr-avatar-test.html',
|
||||
|
Reference in New Issue
Block a user