So I believe I’ve found a hole in the warning checking code.
Take for example the following function
/**
* @param {String} sMethodName
* @param {Object} args
*
* @return {type:<String>, message:<String}}
*
* @properties={typeid:24,uuid:"5F5DC945-928A-4C3E-A582-CDC5528D060F"}
*/
function MissingArgument(sMethodName, args) {
var oException = {
type : "MissingArgument",
message : "Required arguments were not passed to " + sMethodName + " at index " + emptyIndexes(args)
}
return oException;
//Finds empty indexes in the arguments object
function emptyIndexes(arg) {
/** @type {Array} */
var aArg = Array.prototype.slice.call(arg);
var aIndex = aArg
.map(function (element, index){
if (element === null || element === undefined)
{
return index;
}
else
{
return null;
}
})
.filter(function (element){
return element != null
})
return aIndex;
}
}
I’m getting an unreachable code warning on my helper function “emptyIndexes”. Technically speaking, because of JavaScript function hoisting this is an incorrect warning. Having helper functions after the return is a fairly common pattern used to reduce clutter in the main body of a function and is one of the prime benefits of hoisting.
I’ve searched around (notably http://wiki.servoy.com/display/public/DOCS/Annotating+JavaScript+using+JSDoc) for how to add a @SuppressWarnings for this particular error, but I can’t find what the right argument to it would be, and there is no Quick Fix option that tells me what it would be.
Ultimately I think it would be better if this was correctly not counted as unreachable, but if I was able to specifically suppress these warnings when needed that would be good in the interim.
Edit: Incidentally I also can’t figure out what the proper @param type is for when you are passing an “arguments” type object.