Given a function that returns either an object e.g. String
or null
- how can I easily find all locations in code where the return value is not being either assigned to a String
variable (case1
) or immediately evaluated as part of a condition (case2
)?
e.g.
public String getMessageInLog(String toFind) {
// return String or null, depending on if found
}
String lineInLog = getMessageInLog("test"); // case1
Assert.assertNotNull(getMessageInLog("test"); // case2
Assert.assertNotNull("Failure error message", getMessageInLog("test"); // case2 (extended example - why searching for " getMessageInLog(" does not work.
getMessageInLog("test") // case3 - what I'm trying to find
This type of call is being used thousands of times in tests and I would like to identify where it is being used like in case3
.