If merging the conditions seems to result in a more complex code, extracting the condition or part of it in a named function or variable is a better approach to fix readability.
=== Code examples
==== Noncompliant code example
[source,javascript]
----
if (file != undefined) {
if (file.isFile() || file.isDirectory()) { // Noncompliant
/* ... */
}
}
----
==== Compliant solution
[source,javascript]
----
function isFileOrDirectory(File file) {
return file.isFile() || file.isDirectory();
}
/* ... */
if (file. != undefined && isFileOrDirectory(file)) { // Compliant