Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrectly detecting global leak #1057

Closed
takinola opened this issue Dec 4, 2013 · 1 comment
Closed

Incorrectly detecting global leak #1057

takinola opened this issue Dec 4, 2013 · 1 comment

Comments

@takinola
Copy link

takinola commented Dec 4, 2013

When running the following code, Mocha incorrectly detects global leaks on the variables "ctr", "username" and "email"

function test(){
  this.ctr = typeof this.ctr !== 'undefined' ? this.ctr + 1 : 1;
  this.username = 'test_' + this.ctr;
  this.email = this.username + '@example.com';
  return {ctr: this.ctr, name: this.username, email: this.email};
}

describe('Global leak false positive', function(done){
 it('gives a false positive detection of global leaks', function(done){
   var x = test();
   done();
 });
});

environment
mocha 1.12.0
node 0.10.20

@tj
Copy link
Contributor

tj commented Dec 4, 2013

when you call test() there's no receiver, so it becomes the global. If you're expecting it to be mocha's Test object you'd have to do test.call(this)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants