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

mark_parent_class_method_used method traverses inheritance tree up indefinitely #290

Open
maksar opened this issue Apr 18, 2017 · 2 comments

Comments

@maksar
Copy link
Contributor

maksar commented Apr 18, 2017

We have such code in our legacy application:

module Public
  class ApplicationController < ApplicationController
    ...
  end
end

rails_best_practices-1.18.0/lib/rails_best_practices/core/methods.rb:57 #mark_parent_class_method_used method traverses inheritance tree up indefinitely. Ruby and Rails, however, handling situation just fine, assuming, that Public::ApplicationController inherits from ::ApplicationController

/Users/maksar/.rvm/gems/ruby-2.2.4/gems/rails_best_practices-1.18.0/lib/rails_best_practices/core/methods.rb:58:in `block in mark_parent_class_method_used': stack level too deep (SystemStackError)                                                    |
	from /Users/maksar/.rvm/gems/ruby-2.2.4/gems/rails_best_practices-1.18.0/lib/rails_best_practices/core/methods.rb:58:in `each'
	from /Users/maksar/.rvm/gems/ruby-2.2.4/gems/rails_best_practices-1.18.0/lib/rails_best_practices/core/methods.rb:58:in `find'
	from /Users/maksar/.rvm/gems/ruby-2.2.4/gems/rails_best_practices-1.18.0/lib/rails_best_practices/core/methods.rb:58:in `mark_parent_class_method_used'
	from /Users/maksar/.rvm/gems/ruby-2.2.4/gems/rails_best_practices-1.18.0/lib/rails_best_practices/core/methods.rb:60:in `mark_parent_class_method_used'
	from /Users/maksar/.rvm/gems/ruby-2.2.4/gems/rails_best_practices-1.18.0/lib/rails_best_practices/core/methods.rb:60:in `mark_parent_class_method_used'
	from /Users/maksar/.rvm/gems/ruby-2.2.4/gems/rails_best_practices-1.18.0/lib/rails_best_practices/core/methods.rb:60:in `mark_parent_class_method_used'
	from /Users/maksar/.rvm/gems/ruby-2.2.4/gems/rails_best_practices-1.18.0/lib/rails_best_practices/core/methods.rb:60:in `mark_parent_class_method_used'
	from /Users/maksar/.rvm/gems/ruby-2.2.4/gems/rails_best_practices-1.18.0/lib/rails_best_practices/core/methods.rb:60:in `mark_parent_class_method_used'
	 ... 7704 levels...
	from /Users/maksar/.rvm/gems/ruby-2.2.4/bin/rails_best_practices:22:in `load'
	from /Users/maksar/.rvm/gems/ruby-2.2.4/bin/rails_best_practices:22:in `<main>'
	from /Users/maksar/.rvm/gems/ruby-2.2.4/bin/ruby_executable_hooks:15:in `eval'
	from /Users/maksar/.rvm/gems/ruby-2.2.4/bin/ruby_executable_hooks:15:in `<main>'
@flyerhzm
Copy link
Owner

@maksar I suggest you defining Public::ApplicationController as

module Public
  class ApplicationController < ::ApplicationController
    ...
  end
end

@maksar
Copy link
Contributor Author

maksar commented Apr 23, 2017

@flyerhzm That is exactly what I did to fix the error. Further more, I think construct class A < A should not be used. However, since ruby handles such situation well, probably RBP should too (at least have protection against eternal recursion).

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