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

[new cop] law of demeter #720

Closed
yltsrc opened this issue Jan 6, 2014 · 4 comments
Closed

[new cop] law of demeter #720

yltsrc opened this issue Jan 6, 2014 · 4 comments

Comments

@yltsrc
Copy link

yltsrc commented Jan 6, 2014

foo.bar.baz

read more to know why it is invalid code

@yujinakayama
Copy link
Collaborator

I think it's impossible for machines to detect violations of the law of Demeter.

This code does not violate the law, but RuboCop cannot know whether the method chaining descends a hierarchy or is a fluent interface.

def valid_method
  @message.downcase.strip.gsub(' ', '_')
end

@fuadsaud
Copy link

fuadsaud commented Jan 6, 2014

True. I don't think it's possible handling this mechanically.

@yltsrc
Copy link
Author

yltsrc commented Jan 7, 2014

these methods are just object modifications from standard library and active support
I think it may be possible to build list of methods like these and ignore them

@yujinakayama
Copy link
Collaborator

@yltsrc You should know what static code analysis is. It does not provide runtime class information, so there's no way to differentiate methods with a same name but different implementations.

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

3 participants