History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: IDEABKL-4866
Type: Bug Bug
Status: Open Open
Priority: Normal Normal
Assignee: Maxim Mossienko
Reporter: Adam Murray
Votes: 0
Watchers: 1
Available Workflow Actions

Mark as Stalled
Operations

If you were logged in you would be able to see more operations.
IDEA: Backlog

Unresolved variable warnings for variables declared inside an eval()

Created: 23 Aug 06 00:11   Updated: 10 Nov 06 18:01
Component/s: HTML editing
Affects Version/s: None
Fix Version/s: None

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown
Environment: Linux

Build: 5,581
Severity: Low


 Description  « Hide
I have a javascript pattern for AJAX that looks like this (using the prototype.js library):

new Ajax.Request('/some/url/that/reposonds/with/json?queryParam=' + encodeURIComponent(queryParam),
{
onSuccess: function(request) { eval("var data = " + request.responseText); document.getElementById("value").innerHTML = data.value; document.getElementById("status").innerHTML = data.status; },
onException: function(request, exception) { alert("ERROR: " + exception); }
});

I use JSON as the AJAX reponse format instead of XML, so we always call eval() on the reponse. I've found that if I return arrays of data I can do something like this:
var data = eval(request.responseText);
And IntelliJ is happy. But mostly I return javascript objects and I've found I need to put the "var data = " instead the eval call, as in the above example, or it will not work correctly. In these cases, I get a lot of warnings from IntelliJ about an unresolved variable every time I use the variable declared inside the eval().

I realize analyzing eval() calls is a huge hassle from a static analysis perspective, but if you correctly handle simple variable declarations that would be a great step forward.



 All   Comments   Work Log   Change History      Sort Order:
There are no comments yet on this issue.