-
-
Notifications
You must be signed in to change notification settings - Fork 53
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Node#string_type?
helper
#328
base: master
Are you sure you want to change the base?
Conversation
it 'is true' do | ||
it 'is false' do |
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.
Found an incorrect test description so I fixed it.
fbb6525
to
0aa8e3e
Compare
Ouf, it's really unclear to me if there's a way to make any of I can imagine |
I originally had excluded
I'm ok with excluding |
Thanks for the list.
It's not really for me, but for everyone. This one really seems tricky. Maybe I'm thinking too much about it and For example, the 3rd example would be for RuboCop to actually correct code like raise RuntimeError, `???` That's a good example where I don't think anybody cares how this So I'd really like input for @rubocop/rubocop-core about if we want |
Agreed. I think it probably is almost always unintended to even write code where the message of an exception is a shell execution. That could even in itself be something a cop prevents.
From my perspective I do not have strong feelings about including The reason I think that having |
0aa8e3e
to
1feb3b8
Compare
Node#string_literal?
and Node#string_type?
helpersNode#string_type?
helper
Now that #329 is merged, I updated to define |
I'd love others to chime in. My concerns are: definition not clear / possibly confusion / hard to debug errors. The current situation (no grouping) has the advantage that one has to be explicit in specifying which of Current proposal is for Better proposal? |
FWIW, If we adopt this, it probably would make sense to do the same for @marcandre I'd prefer |
👍 totally, and no confusion possible
Yes. My main concern is confusion. I mean, I don't have a strong argument to include, or to exclude |
We have a number of places in rubocop where we check for
str_type? || dstr_type?
orstr_type? || dstr_type? || xstr_type?
.In order to refactor those to reduce complexity, but still maintain the ability to do both types of checks, I've added two helper methods to
Node
:Node#string_literal?
=>node.str_type? || node.dstr_type?
Node#string_type?
=>node.str_type? || node.dstr_type? || node.xstr_type?
I'm not 100% if the distinction between the two is too unclear, so I'm receptive to suggestions there. My thinking is that
string_literal?
are strings that can be written in quotes, whereasxstr
is slightly different (since, among other things, it actually executes code), but still a "string" type.