Details
-
Type:
New Feature
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: JavaScript
-
Labels:None
-
Number of attachments :
Description
- Title
Prohibit use of obsolete arguments.caller and arguments.callee
- Description
Both arguments.caller and arguments.callee make quite a few optimizations impossible so they were deprecated in latest versions of JavaScript. In fact, EcmaScript 5 forbids the use of arguments.callee in strict mode.
Example with the caller property :
function whoCalled() {
if (arguments.caller == null) //Non-Compliant
console.log('I was called from the global scope.');
else
console.log(arguments.caller + ' called me!');
}
- Violation message
Remove use of arguments.xxxx
- Default severity
Critical
Part of Sonar Way quality profile
Origin : JSHint
Issue Links
- relates to
-
SONARPLUGINS-2508
Rule : Source should comply with the javascript strict mode
-
Should be noted that according to https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Functions_and_function_scope/Strict_mode?redirectlocale=en-US&redirectslug=JavaScript%2FStrict_mode "arguments.callee" and "arguments.caller" not supported in strict mode (
SONARPLUGINS-2508):function fun() { "use strict"; arguments.callee; // throws a TypeError arguments.caller; // throws a TypeError }