Fix issues detected by 'JSHint' and 'JSCS'

Change-Id: Ibee5d0843da5776ab1ad43158227178105467d2e
This commit is contained in:
Urs Wolfer
2016-04-29 22:25:51 +02:00
parent 382b0a97a4
commit c37b69ab9b
16 changed files with 41 additions and 39 deletions

View File

@@ -172,7 +172,7 @@
if (!this._canSubmitChange()) {
return;
}
// no break here, fallthrough.
/* falls through */ // required by JSHint
default:
this._fireAction(this._prependSlash(key),
this._revisionActions[key], true);
@@ -261,7 +261,7 @@
return function() {
buttonEl.removeAttribute('loading');
buttonEl.disabled = false;
}
};
},
_fireAction: function(endpoint, action, revAction, opt_payload) {

View File

@@ -34,9 +34,6 @@ limitations under the License.
<script>
suite('gr-change-actions tests', function() {
var element;
var response = {
ok: true,
};
setup(function() {
stub('gr-rest-api-interface', {
getChangeRevisionActions: function() {
@@ -202,7 +199,8 @@ limitations under the License.
});
suite('revert change', function() {
var alertStub, fireActionStub;
var alertStub;
var fireActionStub;
setup(function() {
fireActionStub = sinon.stub(element, '_fireAction');

View File

@@ -46,7 +46,7 @@
var revertCommitText = 'This reverts commit ';
// Selector for previous revert text and commit.
var previousRevertText =
new RegExp('\n{1,2}' + revertCommitText + '\\w+.\n*', 'gm')
new RegExp('\n{1,2}' + revertCommitText + '\\w+.\n*', 'gm');
commitMessage = commitMessage.replace(previousRevertText, '');
this.message = 'Revert "' + commitMessage + '"\n\n' +
revertCommitText + commitInfo.commit + '.';

View File

@@ -77,6 +77,7 @@ limitations under the License.
__path: 'tags.html',
});
getChangeFilesStub.restore();
done();
});
});
@@ -87,7 +88,7 @@ limitations under the License.
{__path: 'file_added_in_rev2.txt'},
{__path: 'myfile.txt'},
];
element.changeNum = '42',
element.changeNum = '42';
element.patchNum = '2';
element.selectedIndex = 0;

View File

@@ -119,7 +119,7 @@
return {
O: options,
q: query
}
};
},
_computeSameTopicQueryParams: function(topic) {
@@ -179,7 +179,7 @@
} else if (change.submittable) {
return 'Submittable';
}
return ''
return '';
},
_serverConfigChanged: function(config) {

View File

@@ -29,7 +29,7 @@
function loadUser(ctx, next) {
restAPI.getLoggedIn().then(function() {
next();
})
});
}
// Routes.

View File

@@ -54,7 +54,7 @@ limitations under the License.
};
element._change = {
revisions: {
a: { _number: 10, },
a: {_number: 10},
},
};
element._fileList = ['chell.go', 'glados.txt', 'wheatley.md'];
@@ -125,7 +125,7 @@ limitations under the License.
};
element._change = {
revisions: {
a: { _number: 10, },
a: {_number: 10},
},
};
element._fileList = ['chell.go', 'glados.txt', 'wheatley.md'];
@@ -179,8 +179,8 @@ limitations under the License.
};
element._change = {
revisions: {
a: { _number: 1, },
b: { _number: 2, },
a: {_number: 1},
b: {_number: 2},
},
};
element._fileList = ['chell.go', 'glados.txt', 'wheatley.md'];

View File

@@ -30,7 +30,7 @@
pairs[i].right));
}
this._outputEl.insertBefore(sectionEl, opt_beforeSection);
},
};
GrDiffBuilderSideBySide.prototype._createRow = function(section, leftLine,
rightLine) {

View File

@@ -58,7 +58,7 @@
GrDiffBuilder.prototype.emitGroup = function(group, opt_beforeSection) {
throw Error('Subclasses must implement emitGroup');
},
};
GrDiffBuilder.prototype._processContent = function(content, groups, context) {
this._appendFileComments(groups);
@@ -339,8 +339,8 @@
function byLineNum(lineNum) {
return function(c) {
return (c.line === lineNum) ||
(c.line === undefined && lineNum === GrDiffLine.FILE)
}
(c.line === undefined && lineNum === GrDiffLine.FILE);
};
}
var leftComments =
comments[GrDiffBuilder.Side.LEFT].filter(byLineNum(line.beforeNumber));
@@ -373,7 +373,7 @@
threadEl.side = side;
threadEl.projectConfig = projectConfig;
return threadEl;
},
};
GrDiffBuilder.prototype._commentThreadForLine = function(line, opt_side) {
var comments = this._getCommentsForLine(this._comments, line, opt_side);

View File

@@ -283,7 +283,7 @@ limitations under the License.
line.beforeNumber = 3;
line.afterNumber = 5;
var comments = {left: [], right:[]};
var comments = {left: [], right: []};
assert.deepEqual(builder._getCommentsForLine(comments, line), []);
assert.deepEqual(builder._getCommentsForLine(comments, line,
GrDiffBuilder.Side.LEFT), []);
@@ -328,7 +328,7 @@ limitations under the License.
],
};
function checkThreadProps(patchNum, side, comments) {
function checkThreadProps(threadEl, patchNum, side, comments) {
assert.equal(threadEl.changeNum, '42');
assert.equal(threadEl.patchNum, patchNum);
assert.equal(threadEl.path, '/path/to/foo');
@@ -340,27 +340,27 @@ limitations under the License.
var line = new GrDiffLine(GrDiffLine.Type.BOTH);
line.beforeNumber = 5;
line.afterNumber = 5;
threadEl = builder._commentThreadForLine(line);
checkThreadProps('3', 'REVISION',
var threadEl = builder._commentThreadForLine(line);
checkThreadProps(threadEl, '3', 'REVISION',
[{id: 'l5', line: 5}, {id: 'r5', line: 5}]);
threadEl = builder._commentThreadForLine(line, GrDiffBuilder.Side.RIGHT);
checkThreadProps('3', 'REVISION', [{id: 'r5', line: 5}]);
checkThreadProps(threadEl, '3', 'REVISION', [{id: 'r5', line: 5}]);
threadEl = builder._commentThreadForLine(line, GrDiffBuilder.Side.LEFT);
checkThreadProps('3', 'PARENT', [{id: 'l5', line: 5}]);
checkThreadProps(threadEl, '3', 'PARENT', [{id: 'l5', line: 5}]);
builder._comments.meta.patchRange.basePatchNum = '1';
threadEl = builder._commentThreadForLine(line);
checkThreadProps('3', 'REVISION',
checkThreadProps(threadEl, '3', 'REVISION',
[{id: 'l5', line: 5}, {id: 'r5', line: 5}]);
threadEl = builder._commentThreadForLine(line, GrDiffBuilder.Side.LEFT);
checkThreadProps('1', 'REVISION', [{id: 'l5', line: 5}]);
checkThreadProps(threadEl, '1', 'REVISION', [{id: 'l5', line: 5}]);
threadEl = builder._commentThreadForLine(line, GrDiffBuilder.Side.RIGHT);
checkThreadProps('3', 'REVISION', [{id: 'r5', line: 5}]);
checkThreadProps(threadEl, '3', 'REVISION', [{id: 'r5', line: 5}]);
builder._comments.meta.patchRange.basePatchNum = 'PARENT';
@@ -368,14 +368,14 @@ limitations under the License.
line.beforeNumber = 5;
line.afterNumber = 5;
threadEl = builder._commentThreadForLine(line);
checkThreadProps('3', 'PARENT',
checkThreadProps(threadEl, '3', 'PARENT',
[{id: 'l5', line: 5}, {id: 'r5', line: 5}]);
line = new GrDiffLine(GrDiffLine.Type.ADD);
line.beforeNumber = 3;
line.afterNumber = 5;
threadEl = builder._commentThreadForLine(line);
checkThreadProps('3', 'REVISION',
checkThreadProps(threadEl, '3', 'REVISION',
[{id: 'l3', line: 3}, {id: 'r5', line: 5}]);
});

View File

@@ -182,7 +182,7 @@
break;
case DiffViewMode.SIDE_BY_SIDE:
classes.push('sideBySide');
break
break;
default:
throw Error('Invalid view mode: ', viewMode);
}

View File

@@ -37,7 +37,7 @@ limitations under the License.
setup(function() {
stub('gr-rest-api-interface', {
getLoggedIn: function() { return Promise.resolve(false); },
})
});
element = fixture('basic');
});

View File

@@ -46,18 +46,21 @@ limitations under the License.
});
test('dom for existing account', function() {
assert.isTrue(element.hasAttribute('hidden'), 'element not hidden initially');
assert.isTrue(element.hasAttribute('hidden'),
'element not hidden initially');
element.hidden = false;
element.imageSize = 64;
element.account = {
_account_id: 123
};
assert.isFalse(element.hasAttribute('hidden'), 'element hidden');
assert.isTrue(element.style.backgroundImage.indexOf('/accounts/123/avatar?s=64') > -1);
assert.isTrue(element.style.backgroundImage.indexOf(
'/accounts/123/avatar?s=64') > -1);
});
test('dom for non available account', function() {
assert.isTrue(element.hasAttribute('hidden'), 'element not hidden initially');
assert.isTrue(element.hasAttribute('hidden'),
'element not hidden initially');
element.account = undefined;
assert.isTrue(element.hasAttribute('hidden'), 'element not hidden');
});

View File

@@ -82,7 +82,7 @@
_handleShowChange: function(detail) {
this._getEventCallbacks(EventType.SHOW_CHANGE).forEach(function(cb) {
var change = detail.change;
var patchNum = detail.patchNum
var patchNum = detail.patchNum;
var revision;
for (var rev in change.revisions) {
if (change.revisions[rev]._number == patchNum) {

View File

@@ -77,7 +77,7 @@ limitations under the License.
});
test('comment event', function(done) {
var testCommentNode = { foo: 'bar' };
var testCommentNode = {foo: 'bar'};
plugin.on(element.EventType.COMMENT, function(commentNode) {
assert.deepEqual(commentNode, testCommentNode);
done();

View File

@@ -235,7 +235,7 @@ limitations under the License.
fetchJSONStub.restore();
done();
});
resolveFetchJSON({rebase:{}});
resolveFetchJSON({rebase: {}});
});
});
</script>