Refactoring - Collapsible "if" statements should be merged

Viewed 2486

I am trying to clean up our legacy code, and noticed there are many if conditional code that can be merged.

Example -

if (file != null) {
  if (file.isFile() || file.isDirectory()) {
    /* ... */
  }
}

This can be refactored to,

if (file != null && (file.isFile() || file.isDirectory())) { 
  /* ... */
}

Manually performing this change is a pain. So, I was trying to check on inspection tool and template refactoring in intelliji to help me with this bulk code refactoring.

Could not locate this eclipse IDE too.

Kindly suggest, is there an option in Intelliji/Eclipse for this

2 Answers
Related