Permalink
Browse files

Initialized variables before using them and removed unused variables

  • Loading branch information...
SebastianZ committed Jan 4, 2013
1 parent d0d4518 commit 3118f395a2e7d9845e663b1b6071a4b95be74c7f
Showing with 162 additions and 205 deletions.
  1. +10 −3 extension/build.js
  2. +5 −10 extension/content/firebug/accessible/a11y.js
  3. +1 −5 extension/content/firebug/bti/inProcess/browser.js
  4. +1 −7 extension/content/firebug/chrome/chrome.js
  5. +0 −1 extension/content/firebug/chrome/firefox.js
  6. +4 −2 extension/content/firebug/chrome/tabWatcher.js
  7. +7 −8 extension/content/firebug/chrome/tableRep.js
  8. +2 −2 extension/content/firebug/chrome/window.js
  9. +2 −4 extension/content/firebug/console/commandEditor.js
  10. +5 −5 extension/content/firebug/console/commandLineExposed.js
  11. +25 −26 extension/content/firebug/console/consoleExposed.js
  12. +3 −2 extension/content/firebug/console/eventMonitor.js
  13. +2 −2 extension/content/firebug/console/memoryProfiler.js
  14. +0 −1 extension/content/firebug/cookies/cookieClipboard.js
  15. +0 −1 extension/content/firebug/cookies/headerResizer.js
  16. +0 −1 extension/content/firebug/cookies/legacy.js
  17. +3 −4 extension/content/firebug/dom/toggleBranch.js
  18. +4 −4 extension/content/firebug/firefox/browserOverlayLib.js
  19. +1 −3 extension/content/firebug/firefox/customizeShortcuts.js
  20. +1 −4 extension/content/firebug/html/layout.js
  21. +7 −9 extension/content/firebug/js/breakpoint.js
  22. +14 −15 extension/content/firebug/js/sourceBox.js
  23. +5 −5 extension/content/firebug/js/stackFrame.js
  24. +1 −1 extension/content/firebug/lib/dom.js
  25. +4 −4 extension/content/firebug/lib/domplate.js
  26. +1 −1 extension/content/firebug/lib/dragdrop.js
  27. +0 −4 extension/content/firebug/lib/fonts.js
  28. +0 −4 extension/content/firebug/lib/json.js
  29. +0 −1 extension/content/firebug/lib/object.js
  30. +7 −8 extension/content/firebug/lib/options.js
  31. +2 −2 extension/content/firebug/lib/search.js
  32. +0 −1 extension/content/firebug/lib/system.js
  33. +0 −4 extension/content/firebug/lib/wrapper.js
  34. +36 −31 extension/content/firebug/lib/xml.js
  35. +0 −4 extension/content/firebug/lib/xpath.js
  36. +4 −3 extension/modules/firebug-service.js
  37. +0 −2 extension/modules/mini-require.js
  38. +3 −10 extension/modules/prefLoader.js
  39. +2 −1 extension/modules/require-debug.js
View
@@ -414,7 +414,7 @@ function clean()
function zip(filename, directory, callback)
{
// Create final XPI package.
- var zip;
+ var zip = null;
if (os.platform() === "win32")
{
var params = "a -tzip " + filename + " " + directory + "/*";
@@ -426,10 +426,17 @@ function zip(filename, directory, callback)
//zip = spawn("zip", [ "-r", __dirname + "/" + xpiFileName, release ]);
}
- zip.on("exit", function()
+ if (zip)
+ {
+ zip.on("exit", function()
+ {
+ callback();
+ });
+ }
+ else
{
callback();
- });
+ }
}
// ********************************************************************************************* //
@@ -466,7 +466,7 @@ Firebug.A11yModel = Obj.extend(Firebug.Module,
var isButton = target.nodeName.search(/(xul:)?((toolbar)?button)|(checkbox)/) != -1;
var isDropDownMenu = isButton && (target.getAttribute("type") == "menu" ||
target.id == "fbLocationList");
- var siblingTab, forward, toolbar, buttons;
+ var siblingTab, forward, toolbar;
var keyCode = event.keyCode || (event.type == "keypress" ? event.charCode : null);
if (keyCode == KeyEvent.DOM_VK_TAB)
this.ensurePanelTabStops(); //TODO: need a better solution to prevent loss of panel tabstop
@@ -1176,10 +1176,10 @@ Firebug.A11yModel = Obj.extend(Firebug.Module,
case KeyEvent.DOM_VK_RETURN:
case KeyEvent.DOM_VK_SPACE:
var isEnter = (keyCode == KeyEvent.DOM_VK_RETURN);
- var nodeLabels = null;
+ var nodeLabels = [];
if (isEnter)
{
- var nodeLabels = target.getElementsByClassName("nodeName");
+ nodeLabels = target.getElementsByClassName("nodeName");
if (nodeLabels.length > 0)
{
Firebug.Editor.startEditing(nodeLabels[0]);
@@ -1684,7 +1684,6 @@ Firebug.A11yModel = Obj.extend(Firebug.Module,
return;
}
var matchFeedback = "";
- var matchType = "";
var selector;
if (Css.hasClass(matchRow, "cssSelector"))
{
@@ -1807,7 +1806,6 @@ Firebug.A11yModel = Obj.extend(Firebug.Module,
if (!Css.hasClass(target, "focusGroup"))
return;
- var panel = Firebug.getElementPanel(target);
switch (keyCode)
{
case KeyEvent.DOM_VK_LEFT:
@@ -1872,7 +1870,7 @@ Firebug.A11yModel = Obj.extend(Firebug.Module,
switch (panelA11y.type)
{
case "html":
- var tagName= nodeName = null;
+ var nodeName = null;
var setSize = posInSet = 0; var setElems;
var label = Locale.$STR("a11y.labels.inline editor") + ": ";
if (Css.hasClass(target, "nodeName") || Css.hasClass(target, "nodeValue"))
@@ -2056,7 +2054,6 @@ Firebug.A11yModel = Obj.extend(Firebug.Module,
var lineNo = parseInt(lineNode.getElementsByClassName("sourceLine").item(0).textContent);
box.a11yCaretLine = lineNo;
box.a11yCaretOffset = caretDetails[1];
- var newLineNo = 1;
var linesToScroll = 0;
var goUp;
switch (keyCode)
@@ -2134,7 +2131,7 @@ Firebug.A11yModel = Obj.extend(Firebug.Module,
liveString += "Line " + lineNo;
if (lineNode.getAttribute("breakpoint") == "true")
{
- var breakpointStr;
+ var breakpointStr = "";
if (lineNode.getAttribute("disabledbreakpoint") == "true")
breakpointStr = "a11y.updates.has disabled breakpoint";
if (lineNode.getAttribute("condition") == "true")
@@ -2423,8 +2420,6 @@ Firebug.A11yModel = Obj.extend(Firebug.Module,
if (!panelA11y || !rows)
return;
- var setSize;
- var posInset;
var setSize = rows.length;
var posInset = 0;
for (var i = 0; i < rows.length; i++)
@@ -242,10 +242,8 @@ Browser.prototype.closeContext = function(context, userCommands)
if (shouldDispatch)
{
- var userCommands;
-
// TODO remove
- Events.dispatch(TabWatcher.fbListeners, "unwatchBrowser", [browser, userCommands]);
+ Events.dispatch(TabWatcher.fbListeners, "unwatchBrowser", [browser, null]);
return true;
}
return false;
@@ -689,8 +687,6 @@ Browser.EventListener = {
// ********************************************************************************************* //
-var clearContextTimeout = 0;
-
var TabWatchListener =
{
dispatchName: "TabWatchListener",
@@ -70,12 +70,6 @@ createFirebugChrome: function(win)
var panelSplitter, sidePanelDeck, panelBar1, panelBar2;
- var disabledHead = null;
- var disabledCaption = null;
- var enableSiteLink = null;
- var enableSystemPagesLink = null;
- var enableAlwaysLink = null;
-
var FirebugChrome =
{
// TODO: remove this property, add getters for location, title, focusedElement, setter popup
@@ -776,7 +770,7 @@ var FirebugChrome =
getSelectedPanelURL: function()
{
- var location;
+ var location = null;
if (Firebug.currentContext)
{
var panel = Firebug.chrome.getSelectedPanel();
@@ -7,7 +7,6 @@ define([], function() {
var Ci = Components.interfaces;
var Cc = Components.classes;
-var Cu = Components.utils;
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
// ********************************************************************************************* //
@@ -655,7 +655,7 @@ Firebug.TabWatcher = Obj.extend(new Firebug.Listener(),
}
Events.dispatch(this.fbListeners, "destroyContext",
- [null, (browser?browser.persistedState:null), browser]);
+ [null, (browser ? browser.persistedState : null), browser]);
return;
}
@@ -670,9 +670,11 @@ Firebug.TabWatcher = Obj.extend(new Firebug.Listener(),
Events.dispatch(this.fbListeners, "destroyContext", [context, persistedState, context.browser]);
if (FBTrace.DBG_WINDOWS || FBTrace.DBG_ACTIVATION)
+ {
FBTrace.sysout("-> tabWatcher.unwatchContext *** DESTROY *** context " + context.uid +
" for: " + (context.window && !context.window.closed?context.window.location :
"no window or closed ") + " aborted: " + context.aborted);
+ }
context.destroy(persistedState);
@@ -687,7 +689,7 @@ Firebug.TabWatcher = Obj.extend(new Firebug.Listener(),
if (!currentBrowser.showFirebug)
{
// context is null if we don't want to debug this browser
- Events.dispatch(this.fbListeners, "showContext", [browser, null]);
+ Events.dispatch(this.fbListeners, "showContext", [currentBrowser, null]);
}
},
@@ -71,6 +71,7 @@ FirebugReps.Table = domplate(Firebug.Rep,
return [row];
var cols = [];
+ var value = null;
for (var i=0; i<this.columns.length; i++)
{
var prop = this.columns[i].property;
@@ -88,7 +89,7 @@ FirebugReps.Table = domplate(Firebug.Rep,
{
var props = (typeof(prop) == "string") ? prop.split(".") : [prop];
- var value = row;
+ value = row;
for (var p in props)
value = (value && value[props[p]]) || undefined;
}
@@ -212,11 +213,11 @@ FirebugReps.Table = domplate(Firebug.Rep,
{
this.columns = columns;
- var object = object || {};
- object.data = data;
- object.columns = columns;
+ var obj = object || {};
+ obj.data = data;
+ obj.columns = columns;
- var row = Firebug.Console.log(object, context, "table", this, true);
+ var row = Firebug.Console.log(obj, context, "table", this, true);
// Set vertical height for scroll bar.
var tBody = row.querySelector(".dataTableTbody");
@@ -270,7 +271,7 @@ FirebugReps.Table = domplate(Firebug.Rep,
getHeaderColumns: function(data)
{
// Get the first row in the object.
- var firstRow;
+ var firstRow = null;
for (var p in data)
{
firstRow = data[p];
@@ -306,8 +307,6 @@ FirebugReps.Table = domplate(Firebug.Rep,
*/
domFilter: function(object, name)
{
- var domMembers = Dom.getDOMMembers(object, name);
-
if (typeof(object) == "function")
{
if (Dom.isDOMMember(object, name) && !Firebug.showDOMFuncs)
@@ -12,7 +12,6 @@ function(FBTrace, Http, Firefox) {
var Ci = Components.interfaces;
var Cc = Components.classes;
-var Cu = Components.utils;
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
@@ -188,11 +187,12 @@ Win.getBrowserByWindow = function(win)
Win.getWindowId = function(win)
{
var util = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
+ var outerWindowID = null;
var innerWindowID = "(none)";
try
{
- var outerWindowID = util.outerWindowID;
+ outerWindowID = util.outerWindowID;
innerWindowID = util.currentInnerWindowID;
}
catch(exc)
@@ -15,8 +15,6 @@ function(Obj, Firebug, Events, Menu, Dom, Locale, Css, Options) {
// ********************************************************************************************* //
// Constants
-var Cc = Components.classes;
-var Ci = Components.interfaces;
var Cu = Components.utils;
var MODE_JAVASCRIPT = "js";
@@ -269,9 +267,9 @@ Firebug.CommandEditor = Obj.extend(Firebug.Module,
if (typeof(SourceEditor) != "undefined")
{
- var doc = this.editor._view._frame.contentDocument;
-
// See issue 5488
+ // var doc = this.editor._view._frame.contentDocument;
+
//doc.body.style.fontSizeAdjust = adjust;
}
else
@@ -185,9 +185,9 @@ function createFirebugCommandLine(context, win)
function evaluate(expr, origExpr)
{
var result;
+ var line = Components.stack.lineNumber;
try
{
- var line = Components.stack.lineNumber;

This comment has been minimized.

Show comment
Hide comment
@simonlindholm

simonlindholm Jan 4, 2013

Member

This is actually wrong - 'line' must be set just above the eval call to correct line numbers properly. I'll fix.

@simonlindholm

simonlindholm Jan 4, 2013

Member

This is actually wrong - 'line' must be set just above the eval call to correct line numbers properly. I'll fix.

result = contentView.eval(expr);
// See Issue 5221
@@ -198,8 +198,9 @@ function createFirebugCommandLine(context, win)
{
// change source and line number of exeptions from commandline code
// create new error since properties of nsIXPCException are not modifiable
- var shouldModify = false, isXPCException = false, dropFrames = false;
- var fileName = exc.filename || exc.fileName, lineNumber;
+ var shouldModify = false, isXPCException = false;
+ var fileName = exc.filename || exc.fileName;
+ var lineNumber = 0;

This comment has been minimized.

Show comment
Hide comment
@simonlindholm

simonlindholm Jan 4, 2013

Member

(it's not used unless shouldModify, so I'd leave it - undefined is more obviously wrong than 0)

@simonlindholm

simonlindholm Jan 4, 2013

Member

(it's not used unless shouldModify, so I'd leave it - undefined is more obviously wrong than 0)

This comment has been minimized.

Show comment
Hide comment
@SebastianZ

SebastianZ Jan 7, 2013

Member

I actually just did that to satisfy the JSDT validator. Otherwise it says that The local variable lineNumber may not have been initialized.
I could explicitly set var lineNumber = undefined;, which looks a bit strange in my eyes or simply ignore the warning and revert the change.
Opinions?

@SebastianZ

SebastianZ Jan 7, 2013

Member

I actually just did that to satisfy the JSDT validator. Otherwise it says that The local variable lineNumber may not have been initialized.
I could explicitly set var lineNumber = undefined;, which looks a bit strange in my eyes or simply ignore the warning and revert the change.
Opinions?

This comment has been minimized.

Show comment
Hide comment
@simonlindholm

simonlindholm Jan 7, 2013

Member

I see. var lineNumber = null;?

@simonlindholm

simonlindholm Jan 7, 2013

Member

I see. var lineNumber = null;?

This comment has been minimized.

Show comment
Hide comment
@SebastianZ

SebastianZ Jan 8, 2013

Member

Yes. Changed in 944382b.

Sebastian

@SebastianZ

SebastianZ Jan 8, 2013

Member

Yes. Changed in 944382b.

Sebastian

if (fileName.lastIndexOf("chrome:", 0) === 0)
{
if (fileName === Components.stack.filename)
@@ -211,7 +212,6 @@ function createFirebugCommandLine(context, win)
}
else if (exc._dropFrames)
{
- dropFrames = true;
lineNumber = findLineNumberInExceptionStack(exc.stack);
shouldModify = (lineNumber !== null);
}
@@ -265,7 +265,7 @@ function createFirebugCommandLine(context, win)
eventID + " with " + objs.length + " user objects", commandLine.userObjects);
}
- var result;
+ var result = null;

This comment has been minimized.

Show comment
Hide comment
@simonlindholm

simonlindholm Jan 4, 2013

Member

This is visible to page scripts, right? I don't think you should make such changes. (var result = undefined; is explicit and fine, IMO.)

@simonlindholm

simonlindholm Jan 4, 2013

Member

This is visible to page scripts, right? I don't think you should make such changes. (var result = undefined; is explicit and fine, IMO.)

This comment has been minimized.

Show comment
Hide comment
@SebastianZ

SebastianZ Jan 7, 2013

Member

This is visible to page scripts, right?

Is it? Anyway, for the sake of not changing the return value you're right that it's better to use undefined here.

Sebastian

@SebastianZ

SebastianZ Jan 7, 2013

Member

This is visible to page scripts, right?

Is it? Anyway, for the sake of not changing the return value you're right that it's better to use undefined here.

Sebastian

This comment has been minimized.

Show comment
Hide comment
@simonlindholm

simonlindholm Jan 7, 2013

Member

$0, etc.

This comment has been minimized.

Show comment
Hide comment
@SebastianZ

SebastianZ Jan 7, 2013

Member

Ah, right.

@SebastianZ

SebastianZ Jan 7, 2013

Member

Ah, right.

if (Dom.getMappedData(contentView.document, "firebug-retValueType") === "array")
result = [];
@@ -195,6 +195,7 @@ function createFirebugConsole(context, win)
console.timeEnd = function(name)
{
var time = new Date().getTime();
+ var diff = 0;

This comment has been minimized.

Show comment
Hide comment
@simonlindholm

simonlindholm Jan 4, 2013

Member

No, console.timeEnd("non-existent") should return undefined.

@simonlindholm

simonlindholm Jan 4, 2013

Member

No, console.timeEnd("non-existent") should return undefined.

This comment has been minimized.

Show comment
Hide comment
@SebastianZ

SebastianZ Jan 7, 2013

Member

Right. We should probably add an FBTest for this.

Sebastian

@SebastianZ

SebastianZ Jan 7, 2013

Member

Right. We should probably add an FBTest for this.

Sebastian

if (!this.timeCounters)
return Console.getDefaultReturnValue(win);
@@ -204,7 +205,7 @@ function createFirebugConsole(context, win)
var timeCounter = this.timeCounters[key];
if (timeCounter)
{
- var diff = time - timeCounter;
+ diff = time - timeCounter;
var label = name + ": " + diff + "ms";
this.info(label);
@@ -294,7 +295,7 @@ function createFirebugConsole(context, win)
function logFormatted(args, className, linkToSource, noThrottle)
{
- var sourceLink;
+ var sourceLink = null;
// Using JSD to get user stack is time consuming.
if (Options.get("preferJSDSourceLinks"))
@@ -316,33 +317,31 @@ function createFirebugConsole(context, win)
{
Errors.increaseCount(context);
- if (!args || !args.length || args.length == 0)
- var msg = [Locale.$STR("Assertion")];
- else
- var msg = args[0];
+ var msg = (!args || !args.length || args.length == 0) ?
+ [Locale.$STR("Assertion")] : args[0];
// If there's no error message, there's also no stack trace. See Issue 4700.
- if (!msg)
- {
- var trace = null;
- }
- else if (msg.stack)
- {
- var trace = StackFrame.parseToStackTrace(msg.stack, context);
- if (FBTrace.DBG_CONSOLE)
- FBTrace.sysout("logAssert trace from msg.stack", trace);
- }
- else if (context.stackTrace)
- {
- var trace = context.stackTrace;
- if (FBTrace.DBG_CONSOLE)
- FBTrace.sysout("logAssert trace from context.window.stackTrace", trace);
- }
- else
+ var trace = null;
+ if (msg)
{
- var trace = getJSDUserStack();
- if (FBTrace.DBG_CONSOLE)
- FBTrace.sysout("logAssert trace from getJSDUserStack", trace);
+ if (msg.stack)
+ {
+ trace = StackFrame.parseToStackTrace(msg.stack, context);
+ if (FBTrace.DBG_CONSOLE)
+ FBTrace.sysout("logAssert trace from msg.stack", trace);
+ }
+ else if (context.stackTrace)
+ {
+ trace = context.stackTrace;
+ if (FBTrace.DBG_CONSOLE)
+ FBTrace.sysout("logAssert trace from context.window.stackTrace", trace);
+ }
+ else
+ {
+ trace = getJSDUserStack();
+ if (FBTrace.DBG_CONSOLE)
+ FBTrace.sysout("logAssert trace from getJSDUserStack", trace);
+ }
}
trace = StackFrame.cleanStackTraceOfFirebug(trace);
Oops, something went wrong.

0 comments on commit 3118f39

Please sign in to comment.