-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve ERB dependency detection #13414
Conversation
end | ||
|
||
def test_finds_no_dependency_when_render_ends_the_name_of_another_method | ||
template = FakeTemplate.new("<%# surrender 'to reason' %>", :erb) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
馃
Oops, we got some failures in the build:
|
@josevalim thanks! unfortunately, I can't take a look into it right now. It seems to be some problem with multiple mathces. I'll get back to it ASAP. |
Turns out |
Any clue on that Memcached issue? The suite passes locally. |
@britto I've restarted the failing job, lets wait and see. |
@carlosantoniodasilva great! 馃崗 |
The current implementation can't handle some special cases of oddly-formatted Ruby. Now we are able to detect them: * Multi-line arguments on the `render` call * Strings containing quotes, e.g. `"something's wrong"` * Multiple kinds of identifiers - instance variables, class variables and globals * Method chains as arguments for the `render` call Also, this fix reduces the rate of "false positives" which showed up when we had calls/access to identifiers containing `render`, like `surrender` and `rendering`.
Each chunk of text coming after `render` is now handled individually as a possible list of arguments.
Improve ERB dependency detection
鉂わ笍 |
Following the discussion started on #13116, I thought it might be worth giving a shot at some of the issues we have identified.
The current implementation can't handle some special cases of oddly-formatted Ruby. Now we are able to detect them:
render
call"something's wrong"
render
callrender@things
,render:partial => 'partial'
, etc.Also, this fix reduces the rate of "false positives" which showed up when we had calls/access to identifiers containing
render
, likesurrender
andrendering
.Related: #13074.
Update:
There is still one edge case for false positives which will be virtually impossible to avoid whithout actually parsing the template: when we have
render
inside a string, as in:For obvious reasons 馃挘. But I guess that will not be such an issue. What we have got so far is probably about as far as we can go with a human-readable regex.