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

False positive with Style/StringMethods cop #2260

Closed
tfausak opened this issue Sep 18, 2015 · 3 comments
Closed

False positive with Style/StringMethods cop #2260

tfausak opened this issue Sep 18, 2015 · 3 comments

Comments

@tfausak
Copy link

tfausak commented Sep 18, 2015

The Style/StringMethods cop appears to be a little overzealous when recommending to_sym over intern.

# Gemfile
source 'https://rubygems.org'
gem 'rubocop',
    github: 'bbatsov/rubocop',
    ref: 'c974769e9021949d545d7484490536d707a38cf1'
# example.rb
C = Class.new { def self.intern; end }
C.intern
> bundle exec rubocop -V
0.34.1 (using Parser 2.2.2.6, running on ruby 2.2.2 x86_64-darwin14)
> bundle exec rubocop -D example.rb 
Inspecting 1 file
C

Offenses:

example.rb:2:3: C: Style/StringMethods: Prefer to_sym over intern.
C.intern
  ^^^^^^

1 file inspected, 1 offense detected
tfausak referenced this issue in AaronLasseigne/active_interaction Sep 18, 2015
@bbatsov
Copy link
Collaborator

bbatsov commented Sep 18, 2015

Probably we should disable this cop by default. I was under the impression that only String had this method.

@tfausak
Copy link
Author

tfausak commented Sep 18, 2015

I think that's true in the standard library, but there are many classes that define intern.

@tfausak
Copy link
Author

tfausak commented Sep 19, 2015

👍

smt116 added a commit to Ragnarson/ragnarson-stylecheck that referenced this issue Dec 24, 2015
* rename Style/Blocks cop to Style/BlockDelimiters according to the
  rubocop/rubocop@ad47005
* Style/Documentation cop is now disabled by default according to the
  rubocop/rubocop#2260
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