jenkins-bot has submitted this change and it was merged.
Change subject: Fix code smell in JS
......................................................................
Fix code smell in JS
As reported by PHPStorms static code analysis.
Change-Id: I540de0e1042158f4bf9f64da30497b7bc79b00b6
---
M client/resources/jquery.wikibase/jquery.wikibase.linkitem.js
M client/resources/wikibase.client.PageConnector.js
M
lib/resources/jquery.wikibase/toolbar/jquery.wikibase.toolbarcontroller.definitions.js
M repo/resources/wikibase.ui.entityViewInit.js
4 files changed, 12 insertions(+), 16 deletions(-)
Approvals:
Henning Snater: Looks good to me, approved
jenkins-bot: Verified
diff --git a/client/resources/jquery.wikibase/jquery.wikibase.linkitem.js
b/client/resources/jquery.wikibase/jquery.wikibase.linkitem.js
index bb9c37e..e1bc376 100644
--- a/client/resources/jquery.wikibase/jquery.wikibase.linkitem.js
+++ b/client/resources/jquery.wikibase/jquery.wikibase.linkitem.js
@@ -581,7 +581,7 @@
* @param {Object} [errorInfo]
*/
_onError: function( errorCode, errorInfo ) {
- var error = ( errorInfo )
+ var error = errorInfo
? wb.RepoApiError.newFromApiResponse( errorInfo )
: errorCode;
diff --git a/client/resources/wikibase.client.PageConnector.js
b/client/resources/wikibase.client.PageConnector.js
index 8d29597..01735bd 100644
--- a/client/resources/wikibase.client.PageConnector.js
+++ b/client/resources/wikibase.client.PageConnector.js
@@ -83,7 +83,7 @@
// Count site links
siteLinkCount = self._countSiteLinks( entity );
- deferred.resolve( ( siteLinkCount ? entity : {} ) );
+ deferred.resolve( siteLinkCount ? entity : {} );
} );
return deferred.promise();
diff --git
a/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.toolbarcontroller.definitions.js
b/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.toolbarcontroller.definitions.js
index 08793cc..d29efa7 100644
---
a/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.toolbarcontroller.definitions.js
+++
b/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.toolbarcontroller.definitions.js
@@ -23,7 +23,7 @@
* @since 0.4
*
* @param {string} type The toolbar type (see toolbarcontroller options
for available types).
- * @param {Object} toolbarDefinitionOrId Object defining a toolbar that
should be set or the id
+ * @param {Object|string} definitionOrId Object defining a toolbar that
should be set or the id
* of a toolbar definition that should be retrieved.
* A toolbar definition has to contain the following attributes:
* - {string} id
@@ -56,29 +56,27 @@
* }
* @return {Object|null} Toolbar definition or null if there is no
definition with the given ID.
*/
- MODULE.definition = function( type, toolbarDefinitionOrId ) {
- if ( typeof toolbarDefinitionOrId === 'string' ) {
+ MODULE.definition = function( type, definitionOrId ) {
+ if ( typeof definitionOrId === 'string' ) {
// GET existing definition
- return toolbarDefinitions[type] &&
toolbarDefinitions[type][toolbarDefinitionOrId]
+ return toolbarDefinitions[type] &&
toolbarDefinitions[type][definitionOrId]
|| null;
}
- // SET new definition
- var toolbarDefinition = toolbarDefinitionOrId;
- if( !toolbarDefinition.id || !toolbarDefinition.events ) {
+ if( !definitionOrId.id || !definitionOrId.events ) {
throw new Error( 'id and events need to be specified to
register a toolbar '
+ 'definition' );
- } else if( !toolbarDefinition.selector ) {
- toolbarDefinition.selector = null;
+ } else if( !definitionOrId.selector ) {
+ definitionOrId.selector = null;
}
if ( !toolbarDefinitions[type] ) {
toolbarDefinitions[type] = {};
}
- toolbarDefinitions[type][toolbarDefinition.id] =
toolbarDefinition;
+ toolbarDefinitions[type][definitionOrId.id] = definitionOrId;
- return toolbarDefinition;
+ return definitionOrId;
};
}( jQuery ) );
diff --git a/repo/resources/wikibase.ui.entityViewInit.js
b/repo/resources/wikibase.ui.entityViewInit.js
index 480ad80..2a72feb 100644
--- a/repo/resources/wikibase.ui.entityViewInit.js
+++ b/repo/resources/wikibase.ui.entityViewInit.js
@@ -153,9 +153,7 @@
function getUserLanguages() {
var userLanguages = mw.config.get( 'wbUserSpecifiedLanguages' ),
- isUlsDefined = mw.uls !== undefined
- && $.uls !== undefined
- && $.uls.data !== undefined,
+ isUlsDefined = mw.uls && $.uls && $.uls.data,
languages = [];
if( !userLanguages.length && isUlsDefined ) {
--
To view, visit https://gerrit.wikimedia.org/r/167814
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I540de0e1042158f4bf9f64da30497b7bc79b00b6
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: Adrian Lang <[email protected]>
Gerrit-Reviewer: Henning Snater <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits