how do i get rid of this warning?
here is some example code
IReport report = new Report(url, usedFacts, path, reportSpecification, reportName, reportSize.height, reportSize.width);
return report;
I split the report into a variable instead of just "return new Report(url, usedFacts, path, reportSpecification, reportName, reportSize.height, reportSize.width);" because if I use the debugger I want to be able to inspect the value as I step through the code.
This is fine, except I get a IJ code warning on all cases like this of: "Local variable report is redundant"
I'm guessing everyone runs into this. Do you just supress that warning or is there a way to see the value of the return value in the debugger?
Please sign in to leave a comment.
Hello phil,
Press Alt-Enter, then right arrow to open the inspection settings, check
the checkbox for ignoring immediately returned variables.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
A feature to evaluate the return expression has been requested in the past (see http://www.jetbrains.net/jira/browse/IDEA-2912 and http://www.jetbrains.net/jira/browse/IDEADEV-10996) but has been deemed as something that can't be implemented because the Java debugger itself (i.e. the JPDA API) does not support it.
While this isn't the most eloquent or ideal solutions, when I want to evaluate the return expression of a method, I set a break point on the return line. When the debugger pauses, I do the following key sequence:
Unfortunately I have not been able to get this to work with a macro. Of course, the above can also be done with the mouse.
While my above method may seem like a bit of a pain, it's workable and prevents you from needing to add variables in your code. This is especially important if the code is not under your control. And once you get use to the key sequence after using it a few times, it becomes second nature.
Of course a third option is to do this:
This way the variable is not redundant, and there is some value add to your code in terms of the logging. Just an idea.
Hope that helps.