I think this may be clearer as just a straight-up if statement:

```
if (!conf.contains("spark.executor.memory") && sys.env.contains("SPARK_MEM")) {
   logWarning(...)
}
```