SonarQube JavaScript
  1. SonarQube JavaScript
  2. SONARJS-92

Rule: Prohibit use of obsolete arguments.caller and arguments.callee

    Details

    • Type: New Feature New Feature
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      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

          Activity

          Hide
          Evgeny Mandrikov added a comment - - edited

          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
          }
          
          Show
          Evgeny Mandrikov added a comment - - edited 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 }

            People

            • Assignee:
              Unassigned
              Reporter:
              Freddy Mallet
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: