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

Merge condition for more readable code #9

Open
monperrus opened this issue Jan 15, 2018 · 3 comments
Open

Merge condition for more readable code #9

monperrus opened this issue Jan 15, 2018 · 3 comments

Comments

@monperrus
Copy link
Contributor

When you have twice the same condition in the same block it can be merged:

if (a!=null) {
  a.foo();
}
somethingeslse();
if (a!=null) {
  a.bar();
}

becomes

if (a!=null) {
  a.foo();
  somethingeslse();
  a.bar();
}

(bug found with Repairnator)

@tdurieux
Copy link
Contributor

For me it is not automatic, it will depends of somethingeslse();
But it can be a new repair model. Not so easy to implement in a meta-program.

@monperrus
Copy link
Contributor Author

monperrus commented Jan 15, 2018 via email

@tdurieux
Copy link
Contributor

Yes, or a validation with a pure template mode.

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