r99736 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99735‎ | r99736 | r99737 >
Date:21:37, 13 October 2011
Author:tparscal
Status:ok
Tags:
Comment:
More fixes based on static code analysis
Modified paths:
  • /trunk/parsers/wikidom/lib/hype/bases/es.DocumentModelNode.js (modified) (history)
  • /trunk/parsers/wikidom/lib/hype/bases/es.EventEmitter.js (modified) (history)
  • /trunk/parsers/wikidom/lib/hype/bases/es.ModelNode.js (modified) (history)
  • /trunk/parsers/wikidom/lib/hype/bases/es.ViewNode.js (modified) (history)
  • /trunk/parsers/wikidom/lib/hype/es.js (modified) (history)

Diff [purge]

Index: trunk/parsers/wikidom/lib/hype/es.js
@@ -62,9 +62,9 @@
6363 bValue = b[k];
6464 aType = typeof aValue;
6565 bType = typeof bValue;
66 - if ( aType !== bType
67 - || ( ( aType === 'string' || aType === 'number' ) && aValue !== bValue )
68 - || ( $.isPlainObject( aValue ) && !es.compareObjects( aValue, bValue ) ) ) {
 66+ if ( aType !== bType ||
 67+ ( ( aType === 'string' || aType === 'number' ) && aValue !== bValue ) ||
 68+ ( $.isPlainObject( aValue ) && !es.compareObjects( aValue, bValue ) ) ) {
6969 return false;
7070 }
7171 }
Index: trunk/parsers/wikidom/lib/hype/bases/es.ViewNode.js
@@ -27,7 +27,7 @@
2828 }
2929
3030 // Extension
31 - var node = $.extend( [], this )
 31+ var node = $.extend( [], this );
3232
3333 // Properties
3434 node.model = model;
Index: trunk/parsers/wikidom/lib/hype/bases/es.DocumentModelNode.js
@@ -58,13 +58,15 @@
5959 };
6060
6161 es.DocumentModelNode.prototype.onBeforeSplice = function( index, howmany ) {
62 - var diff = 0,
 62+ var i,
 63+ length,
 64+ diff = 0,
6365 removed = this.slice( index, index + howmany ),
6466 added = Array.prototype.slice.call( arguments, 2 );
65 - for ( var i = 0; i < removed.length; i++ ) {
 67+ for ( i = 0, length = removed.length; i < length; i++ ) {
6668 diff -= removed[i].getElementLength();
6769 }
68 - for ( var i = 0; i < added.length; i++ ) {
 70+ for ( i = 0, length = added.length; i < length; i++ ) {
6971 diff += added[i].getElementLength();
7072 }
7173 this.adjustContentLength( diff );
Index: trunk/parsers/wikidom/lib/hype/bases/es.ModelNode.js
@@ -16,7 +16,7 @@
1717 es.EventEmitter.call( this );
1818
1919 // Extension
20 - var node = $.extend( [], this )
 20+ var node = $.extend( [], this );
2121
2222 // Reusable function for passing update events upstream
2323 node.emitUpdate = function() {
@@ -136,15 +136,17 @@
137137 * @emits update
138138 */
139139 es.ModelNode.prototype.splice = function( index, howmany ) {
140 - var args = Array.prototype.slice.call( arguments, 0 );
 140+ var i,
 141+ length,
 142+ args = Array.prototype.slice.call( arguments, 0 );
141143 this.emit.apply( this, ['beforeSplice'].concat( args ) );
142144 if ( args.length >= 3 ) {
143 - for ( var i = 2; i < args.length; i++ ) {
 145+ for ( i = 2, length = args.length; i < length; i++ ) {
144146 args[i].attach( this );
145147 }
146148 }
147149 var removed = Array.prototype.splice.apply( this, args );
148 - for ( var i = 0; i < removed.length; i++ ) {
 150+ for ( i = 0, length = removed.length; i < length; i++ ) {
149151 removed[i].detach();
150152 removed[i].removeListener( 'update', this.emitUpdate );
151153 }
Index: trunk/parsers/wikidom/lib/hype/bases/es.EventEmitter.js
@@ -7,7 +7,7 @@
88 */
99 es.EventEmitter = function() {
1010 this.events = {};
11 -}
 11+};
1212
1313 /* Methods */
1414
@@ -144,7 +144,7 @@
145145 return this;
146146 }
147147 var handlers = this.events[type];
148 - if ( handlers.length == 1 && handlers[0] === listener ) {
 148+ if ( handlers.length === 1 && handlers[0] === listener ) {
149149 delete this.events[type];
150150 } else {
151151 var i = handlers.indexOf( listener );
@@ -152,7 +152,7 @@
153153 return this;
154154 }
155155 handlers.splice( i, 1 );
156 - if ( handlers.length == 0 ) {
 156+ if ( handlers.length === 0 ) {
157157 delete this.events[type];
158158 }
159159 }

Status & tagging log