"Warning! Global namespace polluted..." (Oh my, that sounds serious.)

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2412
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

"Warning! Global namespace polluted..." (Oh my, that sounds serious.)

Post by Wildeblood »

Can anyone shed any light on this warning message; I've never seen this one before?
(It's not caused by any script of mine, I don't even know what these things are.)
guiScreenWillChange(GUI_SCREEN_STATUS, GUI_SCREEN_LOAD)

guiScreenChanged(GUI_SCREEN_STATUS, GUI_SCREEN_LOAD)

Warning! Global namespace polluted by:

["postFX","keyBindingDescription","getColorSaturation","setColorSaturation","setExtraGuiScreenKeys","clearExtraGuiScreenKeys","prop"]
In your heart, you know it's flat.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6654
Joined: Wed Feb 28, 2007 7:54 am

Re: "Warning! Global namespace polluted..." (Oh my, that sounds serious.)

Post by another_commander »

This is a warning from Library. It does not indicate a problem per se, it is a warning for future OXPers who may be using the reported global objects in their expansions, potentially causing conflicts with the main game. If you open missiontext.plist in your Library OXP, you will see this:

Code: Select all

LIBC_GLOB = "global|undefined|Function|Object|eval|Array|Boolean|Error|InternalError|EvalError|RangeError|ReferenceError|SyntaxError|TypeError|URIError|Math|isNaN|isFinite|parseFloat|parseInt|Number|NaN|Infinity|JSON|RegExp|escape|unescape|uneval|decodeURI|encodeURI|decodeURIComponent|encodeURIComponent|String|Int8Array|Uint8Array|Int16Array|Uint16Array|Int32Array|Uint32Array|Float32Array|Float64Array|Uint8ClampedArray|ArrayBuffer|Namespace|QName|isXMLName|XML|XMLList|Iterator|StopIteration|Date|Proxy|galaxyNumber|guiScreen|timeAccelerationFactor|log|autoAIForRole|expandDescription|expandMissionText|displayNameForCommodity|randomName|randomInhabitantsDescription|setScreenBackground|setScreenOverlay|takeSnapShot|missionVariables|Mission|mission|Oolite|oolite|Vector3D|Quaternion|System|system|Entity|Ship|Station|Dock|VisualEffect|ExhaustPlume|Flasher|Wormhole|Waypoint|Player|player|PlayerShip|Manifest|manifest|Sun|Planet|Script|Timer|Clock|clock|worldScripts|Sound|SoundSource|SystemInfo|EquipmentInfo|ShipGroup|addFrameCallback|removeFrameCallback|isValidFrameCallback|defaultFont|worldScriptNames|Console|ConsoleSettings|console|debugConsole|consoleMessage|formatInteger|formatCredits|getScreenBackgroundForKey|setScreenBackgroundForKey|pauseGame|getGuiColorSettingForKey|setGuiColorSettingForKey";
These are the names of JS objects that Library has as whitelisted.

Now, what happens is that some new objects were added to the glboal JS class in the years since the last Library revision. postFX for example is a new global object that is part of the core game and allows one to set the active post processing effect being rendered. keyBindingDescription is another new one, a result of the keyconfig settings code that phkb implemented. Because the Library OXP did not know about those when it was written, it now reports them as polluters of the global namespace. The OXP is doing its job fine, it just needs to be updated to include those new global JS objects.

The only object I do not recognize and might be an actual problem is "prop" - not sure where this is coming from.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2412
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: "Warning! Global namespace polluted..." (Oh my, that sounds serious.)

Post by Wildeblood »

Thanks for the explanation, A_C.
another_commander wrote: Sun Sep 01, 2024 2:08 pm
The only object I do not recognize and might be an actual problem is "prop" - not sure where this is coming from.
"prop" is short for property, and is what one uses to loop through an object that is not defined as an array, so doesn't have key values that are nicely consecutive numbers.

Code: Select all

this.name    = "Untrumbled";
this.version = "1.1"; // "Wildeblood", "phkb" June 17th, 2015

this.startUp = function () {
	"use strict";
	if (worldScripts["oolite-trumbles"]) {
		for (prop in worldScripts["oolite-trumbles"]) {
			if (prop !== "name" && prop !== "version" && 
			prop !== "oolite_manifest_identifier") delete worldScripts["oolite-trumbles"][prop];
		}
		log(this.name, "Removed oolite-trumbles world script.");
	}
	delete missionVariables.trumbles;
	delete this.startUp;
}
User avatar
hiran
Theorethicist
Posts: 2358
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: "Warning! Global namespace polluted..." (Oh my, that sounds serious.)

Post by hiran »

Wildeblood wrote: Sun Sep 01, 2024 2:35 pm
Thanks for the explanation, A_C.
another_commander wrote: Sun Sep 01, 2024 2:08 pm
The only object I do not recognize and might be an actual problem is "prop" - not sure where this is coming from.
"prop" is short for property, and is what one uses to loop through an object that is not defined as an array, so doesn't have key values that are nicely consecutive numbers.
The way you showed means prop is a variable with loop scope. Not something that deserves a warning or that would worry a_c.
Sunshine - Moonlight - Good Times - Oolite
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2412
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia

Re: "Warning! Global namespace polluted..." (Oh my, that sounds serious.)

Post by Wildeblood »

hiran wrote: Sun Sep 01, 2024 11:16 pm
Wildeblood wrote: Sun Sep 01, 2024 2:35 pm
Thanks for the explanation, A_C.
another_commander wrote: Sun Sep 01, 2024 2:08 pm
The only object I do not recognize and might be an actual problem is "prop" - not sure where this is coming from.
"prop" is short for property, and is what one uses to loop through an object that is not defined as an array, so doesn't have key values that are nicely consecutive numbers.
The way you showed means prop is a variable with loop scope. Not something that deserves a warning or that would worry a_c.
1. Well, I don't know where else it could have come from.
2. I don't think it's a normal variable. I believe (but don't know for sure) that it's a keyword in javascript. I've never seen anyone do a loop like this using any "variable" other than "prop".
3. No need for anyone to be worried. Now that A_C has confirmed this warning came from Library OXP, not Oolite, everyone can go back to worrying about the cost of rents.
In your heart, you know it's flat.
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4821
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: "Warning! Global namespace polluted..." (Oh my, that sounds serious.)

Post by phkb »

Wildeblood wrote: Sun Sep 01, 2024 2:35 pm
"prop" is short for property, and is what one uses to loop through an object that is not defined as an array, so doesn't have key values that are nicely consecutive numbers.
Library is highlighting the fact that the variable "prop", because of the way it's defined in one of the Javascript files that have been loaded, has ended up in the global namespace, rather than being local to the function.

The code example you mentioned is actually an example of the issue. Make this small change and the warning should disappear:

Code: Select all

this.name    = "Untrumbled";
this.version = "1.1"; // "Wildeblood", "phkb" June 17th, 2015

this.startUp = function () {
	"use strict";
	if (worldScripts["oolite-trumbles"]) {
		for (var prop in worldScripts["oolite-trumbles"]) { // << add "var" in front of "prop"
			if (prop !== "name" && prop !== "version" && 
			prop !== "oolite_manifest_identifier") delete worldScripts["oolite-trumbles"][prop];
		}
		log(this.name, "Removed oolite-trumbles world script.");
	}
	delete missionVariables.trumbles;
	delete this.startUp;
}
The same issue exists in Explorers Club, Bloomberg Markets, and Taranis, so if you're using those OXP's you'd need to fix each one before the warning would disappear.
Post Reply