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

avoid name clash with Object.clone method #64

Merged
merged 1 commit into from
Jun 26, 2014

Conversation

ehaselwanter
Copy link
Contributor

using rubocop in the same Rakefile yields

bundle exec rake rubocop
Running RuboCop...
Inspecting 10 files
private method `clone' called for #<RuboCop::Cop::CopStore:0x000001045a8250>
/Users/ehaselwanter/.rvm/gems/ruby-2.1.1/gems/rubocop-0.23.0/lib/rubocop/cop/cop.rb:57:in `all'
/Users/ehaselwanter/.rvm/gems/ruby-2.1.1/gems/rubocop-0.23.0/lib/rubocop/file_inspector.rb:114:in `mobilized_cop_classes'
/Users/ehaselwanter/.rvm/gems/ruby-2.1.1/gems/rubocop-0.23.0/lib/rubocop/file_inspector.rb:105:in `inspect_file'
/Users/ehaselwanter/.rvm/gems/ruby-2.1.1/gems/rubocop-0.23.0/lib/rubocop/file_inspector.rb:74:in `block in pr

@marchuffnagle
Copy link

This works, and should be merged as soon as possible. The better solution is to not use global methods. If you're going to, though, be sure that they don't conflict with any instance methods of Object.

From http://readruby.io/methods#global

Methods defined at the top-level of a program, outside of any Class or Module definitions, are private instance methods of Object. This enables programming in a functional style, without thinking in terms of objects.

In Ruby 1.9.3, those are:

irb(main):005:0> puts Object.new.methods.sort.map { |x| x.to_s }.join("\n")
!
!=
!~
<=>
==
===
=~
__id__
__send__
class
clone
define_singleton_method
display
dup
enum_for
eql?
equal?
extend
freeze
frozen?
hash
initialize_clone
initialize_dup
inspect
instance_eval
instance_exec
instance_of?
instance_variable_defined?
instance_variable_get
instance_variable_set
instance_variables
is_a?
kind_of?
method
methods
nil?
object_id
private_methods
protected_methods
public_method
public_methods
public_send
respond_to?
respond_to_missing?
send
singleton_class
singleton_methods
taint
tainted?
tap
to_enum
to_s
trust
untaint
untrust
untrusted?

hunner added a commit that referenced this pull request Jun 26, 2014
avoid name clash with Object.clone method
@hunner hunner merged commit faa203b into puppetlabs:master Jun 26, 2014
@chelnak chelnak added the bug label Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants