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

Bug in Rails/UniqueValidationWithoutIndex cop #359

Closed
tbk303 opened this issue Sep 15, 2020 · 2 comments
Closed

Bug in Rails/UniqueValidationWithoutIndex cop #359

tbk303 opened this issue Sep 15, 2020 · 2 comments

Comments

@tbk303
Copy link

tbk303 commented Sep 15, 2020

1 error occurred:
An error occurred while Rails/UniqueValidationWithoutIndex cop was inspecting 

undefined method `with_column?' for nil:NilClass
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-rails-2.8.0/lib/rubocop/cop/mixin/active_record_helper.rb:55:in `resolve_relation_into_column'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-rails-2.8.0/lib/rubocop/cop/rails/unique_validation_without_index.rb:84:in `block in column_names'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-rails-2.8.0/lib/rubocop/cop/rails/unique_validation_without_index.rb:82:in `map!'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-rails-2.8.0/lib/rubocop/cop/rails/unique_validation_without_index.rb:82:in `column_names'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-rails-2.8.0/lib/rubocop/cop/rails/unique_validation_without_index.rb:50:in `find_schema_information'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-rails-2.8.0/lib/rubocop/cop/rails/unique_validation_without_index.rb:38:in `on_send'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/cop/commissioner.rb:99:in `block (2 levels) in trigger_responding_cops'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/cop/commissioner.rb:152:in `with_cop_error_handling'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/cop/commissioner.rb:98:in `block in trigger_responding_cops'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/cop/commissioner.rb:97:in `each'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/cop/commissioner.rb:97:in `trigger_responding_cops'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/cop/commissioner.rb:70:in `on_send'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.4.0/lib/rubocop/ast/traversal.rb:59:in `block in on_begin'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.4.0/lib/rubocop/ast/traversal.rb:59:in `each'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.4.0/lib/rubocop/ast/traversal.rb:59:in `on_begin'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/cop/commissioner.rb:72:in `on_begin'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.4.0/lib/rubocop/ast/traversal.rb:101:in `on_class'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/cop/commissioner.rb:72:in `on_class'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-ast-0.4.0/lib/rubocop/ast/traversal.rb:14:in `walk'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/cop/commissioner.rb:85:in `investigate'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/cop/team.rb:152:in `investigate_partial'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/cop/team.rb:83:in `investigate'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/runner.rb:311:in `inspect_file'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/runner.rb:255:in `block in do_inspection_loop'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/runner.rb:289:in `block in iterate_until_no_changes'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/runner.rb:282:in `loop'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/runner.rb:282:in `iterate_until_no_changes'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/runner.rb:251:in `do_inspection_loop'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/runner.rb:128:in `block in file_offenses'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/runner.rb:153:in `file_offense_cache'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/runner.rb:127:in `file_offenses'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/runner.rb:118:in `process_file'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/runner.rb:97:in `block in each_inspected_file'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/runner.rb:96:in `each'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/runner.rb:96:in `reduce'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/runner.rb:96:in `each_inspected_file'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/runner.rb:82:in `inspect_files'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/runner.rb:43:in `run'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/cli/command.rb:11:in `run'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/cli/environment.rb:18:in `run'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/cli.rb:65:in `run_command'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/cli.rb:72:in `execute_runners'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/lib/rubocop/cli.rb:41:in `run'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/exe/rubocop:13:in `block in <top (required)>'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
/home/tbk/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/exe/rubocop:12:in `<top (required)>'
/home/tbk/.rbenv/versions/2.7.1/bin/rubocop:23:in `load'
/home/tbk/.rbenv/versions/2.7.1/bin/rubocop:23:in `<main>'
.

1 file inspected, no offenses detected

1 error occurred:
An error occurred while Rails/UniqueValidationWithoutIndex cop was inspecting 

The file/validation in question is this:

  validates :voter_id, uniqueness: {
    scope: %i[voteable_id voteable_type],
    message: 'darf nur ein mal abstimmen',
  }


RuboCop version

 $ rubocop -V  
0.91.0 (using Parser 2.7.1.4, rubocop-ast 0.4.0, running on ruby 2.7.1 x86_64-linux)
@tbk303
Copy link
Author

tbk303 commented Sep 15, 2020

Sorry, closing this as dup of #348

@tbk303 tbk303 closed this as completed Sep 15, 2020
@koic
Copy link
Member

koic commented Sep 15, 2020

@tbk303 RuboCop Rails 2.8.1 has been released. Can you upgrade to the latest RuboCop Rails? Thank you for your feedback.

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