sreeni
sreeni

Reputation: 151

Sonar violation around JavaScript arguments object usage

Let's say I have the following JavaScript code in my project:

function foo(){
  console.log(arguments);         
}

When I run the Sonar JavaScript plugin across it, it registers the following error:

"eval" and "arguments" must not be bound or assigned

Any idea why? I understand this error should only occur if arguments is assigned to a variable or it is used as a parameter name, but neither is the case here.

Upvotes: 0

Views: 1121

Answers (2)

Amit
Amit

Reputation: 11

There is a bug already reported for this issue, as stated here:- http://jira.codehaus.org/browse/SONARPLUGINS-2843

1.4 sonar javascript plugin is expected to release on Aug 15.

Upvotes: 1

user1417128
user1417128

Reputation: 31

The description of the rule in Sonar explains it quite clear: "arguments" is an implicit variable that give access to the arguments of the function, and that is an indexed property. So this is unlikely that you want to pass this variable like what you're showing (which looks like a debug code only), and most of the time doing so should raise attention (only technical JS stacks/frameworks should require to do so).

Upvotes: 1

Related Questions