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

Undefined method reject for Rubocop::Cop::Registry in Rubocop::Cop::Team#roundup_relevant_cops #8077

Closed
pdobb opened this issue Jun 1, 2020 · 10 comments

Comments

@pdobb
Copy link
Contributor

pdobb commented Jun 1, 2020

Expected behavior

I am getting an exception (see below) after updating to rubocop 0.85.0 when running the pronto-rubocop gem. I suspect this is due to changes in: #8030

rubocop 0.84.0 didn't fail in this way.

Actual behavior

$ pronto run -c=development

# ...

Running Pronto::Rubocop
Traceback (most recent call last):
	21: from /Users/pauld/.gem/ruby/2.6.6/bin/pronto:23:in `<main>'
	20: from /Users/pauld/.gem/ruby/2.6.6/bin/pronto:23:in `load'
	19: from /Users/pauld/.gem/ruby/2.6.6/gems/pronto-0.10.0/bin/pronto:6:in `<top (required)>'
	18: from /Users/pauld/.gem/ruby/2.6.6/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
	17: from /Users/pauld/.gem/ruby/2.6.6/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
	16: from /Users/pauld/.gem/ruby/2.6.6/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
	15: from /Users/pauld/.gem/ruby/2.6.6/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
	14: from /Users/pauld/.gem/ruby/2.6.6/gems/pronto-0.10.0/lib/pronto/cli.rb:64:in `run'
	13: from /Users/pauld/.gem/ruby/2.6.6/gems/pronto-0.10.0/lib/pronto/cli.rb:64:in `chdir'
	12: from /Users/pauld/.gem/ruby/2.6.6/gems/pronto-0.10.0/lib/pronto/cli.rb:66:in `block in run'
	11: from /Users/pauld/.gem/ruby/2.6.6/gems/pronto-0.10.0/lib/pronto.rb:64:in `run'
	10: from /Users/pauld/.gem/ruby/2.6.6/gems/pronto-0.10.0/lib/pronto/runners.rb:13:in `run'
	 9: from /Users/pauld/.gem/ruby/2.6.6/gems/pronto-0.10.0/lib/pronto/runners.rb:13:in `each'
	 8: from /Users/pauld/.gem/ruby/2.6.6/gems/pronto-0.10.0/lib/pronto/runners.rb:20:in `block in run'
	 7: from /Users/pauld/.gem/ruby/2.6.6/gems/pronto-rubocop-0.10.0/lib/pronto/rubocop.rb:10:in `run'
	 6: from /Users/pauld/.gem/ruby/2.6.6/gems/pronto-rubocop-0.10.0/lib/pronto/rubocop.rb:10:in `map'
	 5: from /Users/pauld/.gem/ruby/2.6.6/gems/pronto-rubocop-0.10.0/lib/pronto/rubocop.rb:10:in `block in run'
	 4: from /Users/pauld/.gem/ruby/2.6.6/gems/pronto-rubocop-0.10.0/lib/pronto/rubocop/patch_cop.rb:12:in `messages'
	 3: from /Users/pauld/.gem/ruby/2.6.6/gems/pronto-rubocop-0.10.0/lib/pronto/rubocop/patch_cop.rb:44:in `offences'
	 2: from /Users/pauld/.gem/ruby/2.6.6/gems/rubocop-0.85.0/lib/rubocop/cop/team.rb:67:in `inspect_file'
	 1: from /Users/pauld/.gem/ruby/2.6.6/gems/rubocop-0.85.0/lib/rubocop/cop/team.rb:116:in `offenses'
/Users/pauld/.gem/ruby/2.6.6/gems/rubocop-0.85.0/lib/rubocop/cop/team.rb:148:in `roundup_relevant_cops': undefined method `reject' for #<RuboCop::Cop::Registry:0x00007fae6d7629b0> (NoMethodError)

Steps to reproduce the problem

From what I can tell, any pronto run that includes pronto-rubocop will cause this failure... will update if i can find other ways to reproduce.

RuboCop version

0.85.0 (using Parser 2.7.1.3, rubocop-ast 0.0.3, running on ruby 2.6.6 x86_64-darwin19)
@marcandre
Copy link
Contributor

marcandre commented Jun 1, 2020

Sorry for the trouble you're having.

Easiest fix would be for Registry to include Enumerable. @bbatsov any reason not to?

marcandre added a commit to marcandre/rubocop that referenced this issue Jun 1, 2020
@pdobb
Copy link
Contributor Author

pdobb commented Jun 1, 2020

@marcandre Thanks, I can confirm that your PR fixes the immediate error, but it only gets one line further before failing again:

Gemfile:
gem "rubocop", "0.85.0", require: false, github: "marcandre/rubocop", ref: "a0acfc562e1fb091582960d8a61fb18bcd309698"

$ bundle exec pronto run -c=development

# ...

bundler: failed to load command: pronto (/Users/pauld/.gem/ruby/2.6.6/bin/pronto)
NoMethodError: undefined method `excluded_file?' for RuboCop::Cop::Migration::DepartmentName:Class
  /Users/pauld/.gem/ruby/2.6.6/bundler/gems/rubocop-a0acfc562e1f/lib/rubocop/cop/team.rb:148:in `block in roundup_relevant_cops'
  /Users/pauld/.gem/ruby/2.6.6/bundler/gems/rubocop-a0acfc562e1f/lib/rubocop/cop/registry.rb:187:in `each'
  /Users/pauld/.gem/ruby/2.6.6/bundler/gems/rubocop-a0acfc562e1f/lib/rubocop/cop/registry.rb:187:in `each'
  /Users/pauld/.gem/ruby/2.6.6/bundler/gems/rubocop-a0acfc562e1f/lib/rubocop/cop/team.rb:147:in `reject'
  /Users/pauld/.gem/ruby/2.6.6/bundler/gems/rubocop-a0acfc562e1f/lib/rubocop/cop/team.rb:147:in `roundup_relevant_cops'
  /Users/pauld/.gem/ruby/2.6.6/bundler/gems/rubocop-a0acfc562e1f/lib/rubocop/cop/team.rb:116:in `offenses'
  /Users/pauld/.gem/ruby/2.6.6/bundler/gems/rubocop-a0acfc562e1f/lib/rubocop/cop/team.rb:67:in `inspect_file'
  /Users/pauld/.gem/ruby/2.6.6/gems/pronto-rubocop-0.10.0/lib/pronto/rubocop/patch_cop.rb:44:in `offences'
  /Users/pauld/.gem/ruby/2.6.6/gems/pronto-rubocop-0.10.0/lib/pronto/rubocop/patch_cop.rb:12:in `messages'
  /Users/pauld/.gem/ruby/2.6.6/gems/pronto-rubocop-0.10.0/lib/pronto/rubocop.rb:10:in `block in run'
  /Users/pauld/.gem/ruby/2.6.6/gems/pronto-rubocop-0.10.0/lib/pronto/rubocop.rb:10:in `map'
  /Users/pauld/.gem/ruby/2.6.6/gems/pronto-rubocop-0.10.0/lib/pronto/rubocop.rb:10:in `run'
  /Users/pauld/.gem/ruby/2.6.6/gems/pronto-0.10.0/lib/pronto/runners.rb:20:in `block in run'
  /Users/pauld/.gem/ruby/2.6.6/gems/pronto-0.10.0/lib/pronto/runners.rb:13:in `each'
  /Users/pauld/.gem/ruby/2.6.6/gems/pronto-0.10.0/lib/pronto/runners.rb:13:in `run'
  /Users/pauld/.gem/ruby/2.6.6/gems/pronto-0.10.0/lib/pronto.rb:64:in `run'
  /Users/pauld/.gem/ruby/2.6.6/gems/pronto-0.10.0/lib/pronto/cli.rb:66:in `block in run'
  /Users/pauld/.gem/ruby/2.6.6/gems/pronto-0.10.0/lib/pronto/cli.rb:64:in `chdir'
  /Users/pauld/.gem/ruby/2.6.6/gems/pronto-0.10.0/lib/pronto/cli.rb:64:in `run'
  /Users/pauld/.gem/ruby/2.6.6/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
  /Users/pauld/.gem/ruby/2.6.6/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
  /Users/pauld/.gem/ruby/2.6.6/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
  /Users/pauld/.gem/ruby/2.6.6/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
  /Users/pauld/.gem/ruby/2.6.6/gems/pronto-0.10.0/bin/pronto:6:in `<top (required)>'
  /Users/pauld/.gem/ruby/2.6.6/bin/pronto:23:in `load'
  /Users/pauld/.gem/ruby/2.6.6/bin/pronto:23:in `<top (required)>'

@marcandre
Copy link
Contributor

marcandre commented Jun 1, 2020

Yes, I just realized this, I was confused, sorry about that.

So the issue is that instead of Team.new, pronto must call Team.mobilize (for version >=0.85)

@darrenterhune
Copy link

Also seeing this exact error with erb_lint will update when I have a bit more time to debug this.

@marcandre
Copy link
Contributor

@bbatsov I could make a quick patch to Team.new that either calls super or mobilize depending on the type of the first argument, reinstating compatibility. That would probably be best.

@mvz
Copy link
Contributor

mvz commented Jun 7, 2020

Is this fully fixed in 0.85.1? It's not in the changelog ...

@marcandre
Copy link
Contributor

Is this fully fixed in 0.85.1? It's not in the changelog ...

Yes it is fixed. We typically only include user facing issues in the Changelog...

@mvz
Copy link
Contributor

mvz commented Jun 8, 2020

Thanks @marcandre that's good news. FWIW, due to the breaking of erb-lint (#8077 (comment)) I think this is a user facing issue and you deserve credit for fixing it.

@marcandre
Copy link
Contributor

Thanks @marcandre that's good news. FWIW, due to the breaking of erb-lint (#8077 (comment)) I think this is a user facing issue and you deserve credit for fixing it.

Well, I broke it (witingly) in the first place 🤣. The issue with RuboCop is that it was always more thought of as a tool to use than a code library to extend.

@darrenterhune
Copy link

Related again Shopify/erb-lint#179

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

4 participants