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

Don't pointlessly return in methods that ignore return values #116

Closed
GoodForOneFare opened this issue May 23, 2016 · 1 comment
Closed
Assignees

Comments

@GoodForOneFare
Copy link
Member

Some functions like Lodash's _.each ignore return values. To avoid copy+paste anti-patterns, it might be useful to clean those up.

// Before
return _.each(foo, (element, index) => {
  if (index === 0) {
    return; // This return short-circuits following logic, so it has to stay.
  }

  return element.position = index;
});

// After
return _.each(foo, (element, index) => {
  if (index === 0) {
    return; // This return short-circuits following logic, so it has to stay.
  }

  element.position = index;
});

Note that $._each is influenced by return values, so be sure to ignore those :)

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

No branches or pull requests

2 participants