Skip to content
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

:kind_of? vs :is_a? automation? #1145

Closed
jdickey opened this issue Jun 11, 2014 · 1 comment
Closed

:kind_of? vs :is_a? automation? #1145

jdickey opened this issue Jun 11, 2014 · 1 comment

Comments

@jdickey
Copy link

jdickey commented Jun 11, 2014

This is a continuation of Ruby Style Guide issue 307. Let me start out by saying that I understand and tend to agree with what @anthonyryan1 had to say when he closed the issue, before @bbatsov recommended I open a new automation issue on the topic.

I'd suggest that

  1. a :refactor or :convention notice (which?) be emitted when the source being examined includes calls to both :is_a? and :kind_of?, suggesting to the developer that s/he might want to standardise on one or the other.
  2. that be raised to an :error-level offence when the configuration contains a Preferred: is_a? or Preferred: kind_of? setting for this cop.
  3. that the scope of comparison for (1) and (2) be optionally limited by a LimitedTo: configuration setting with the allowable settings of File, Class or Method. Specifying Default, or omitting the LimitedTo: configuration entirely, defaults the scope to all files being examined.

You could well argue, and I'd agree, that this would be a pretty arbitrarily limited form of what was being grappled with in the earlier issue. On the other hand, it "shouldn't" be incredibly hard to implement.

Thoughts?

@bbatsov
Copy link
Collaborator

bbatsov commented Jun 16, 2014

All cops have file scope, so the only viable option would be to have a mandatory enforced style. Implementing this would be fairly easy, indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants