When running Intellij's inspections on some javascript I wrote, it reports
function 'createPages' has inconsistent return points at line 35
But I'm not sure what it means, or how to solve this issue.
The function looks like this:
function createPages(noOfCounts) {
var default_page = 1, default_count = 15;
if (noOfCounts != "" && noOfCounts != null) {
if (noOfCounts > default_count) {
try {
var tempVal = parseInt(noOfCounts / default_count);
jQuery("#page").val(tempVal);
return true;
}
catch (e) {
alert('Error . ' + e);
}
} else {
alert("It should not be less than the 15 and should be a number");
return false;
}
}
else {
jQuery("#page").val(default_page);
return true;
}
}
And is being called like so:
var valid = createPages(noOfCounts);
Your function will (in effect) return undefined
implicitly after it reaches alert('Error . ' + e);
, because execution will reach the end of the function without an explicit return
.
So probably making sure that all code paths through the function return a value explicitly will get rid of the IntelliJ error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With