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

When NewCops: enable, Rails/UnusedIgnoredColumns reports error reading model which has self.ignored_columns #692

Closed
kazzix14 opened this issue Apr 19, 2022 · 7 comments · Fixed by #693
Labels
bug Something isn't working

Comments

@kazzix14
Copy link

kazzix14 commented Apr 19, 2022

The cop throws an error inspecting my_model.rb that includes self.ignored_columns = [:any_column]

class MyModel < ApplicationRecord
  self.ignored_columns = [:my_column]
end

.rubocop.yml

require:
  - rubocop-rails

AllCops:
  NewCops: enable

Expected behavior

rubocop exit without any error.

Actual behavior

It reports an error.

# bundle exec rubocop -pd
For /usr/local/app: configuration from /usr/local/app/.rubocop.yml
configuration from /usr/local/bundle/gems/rubocop-rails-2.14.2/config/default.yml
configuration from /usr/local/bundle/gems/rubocop-rails-2.14.2/config/default.yml
Default configuration from /usr/local/bundle/gems/rubocop-1.27.0/config/default.yml
Running parallel inspection
Loading cache from /root/.cache/rubocop_cache/3f8ac0ca78c56f058546b60b495e18053808ec04/8c94aaa2d34c6a0350b3b9449989f23b09480ed0/e01ec7d09202b5ca768ba4bd44a39954ed5a0cfa
Loading cache from /root/.cache/rubocop_cache/3f8ac0ca78c56f058546b60b495e18053808ec04/8c94aaa2d34c6a0350b3b9449989f23b09480ed0/9f0430753ee4ab01e7b8de3d9a38a2c69120f8f7
An error occurred while Rails/UnusedIgnoredColumns cop was inspecting /usr/local/app/app/models/my_model.rb:5:2.
undefined method `block_type?' for nil:NilClass

          raise "Unexpected type: #{ast.type}" unless ast.block_type?
                                                         ^^^^^^^^^^^^
/usr/local/bundle/gems/rubocop-rails-2.14.2/lib/rubocop/rails/schema_loader/schema.rb:32:in `build!'
/usr/local/bundle/gems/rubocop-rails-2.14.2/lib/rubocop/rails/schema_loader/schema.rb:14:in `initialize'
/usr/local/bundle/gems/rubocop-rails-2.14.2/lib/rubocop/rails/schema_loader.rb:46:in `new'
/usr/local/bundle/gems/rubocop-rails-2.14.2/lib/rubocop/rails/schema_loader.rb:46:in `load!'
/usr/local/bundle/gems/rubocop-rails-2.14.2/lib/rubocop/rails/schema_loader.rb:18:in `load'
/usr/local/bundle/gems/rubocop-rails-2.14.2/lib/rubocop/cop/mixin/active_record_helper.rb:42:in `schema'
/usr/local/bundle/gems/rubocop-rails-2.14.2/lib/rubocop/cop/rails/unused_ignored_columns.rb:37:in `on_send'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:136:in `public_send'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:136:in `block (2 levels) in trigger_restricted_cops'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:160:in `with_cop_error_handling'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:135:in `block in trigger_restricted_cops'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:134:in `each'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:134:in `trigger_restricted_cops'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:70:in `on_send'
/usr/local/bundle/gems/rubocop-ast-1.17.0/lib/rubocop/ast/traversal.rb:153:in `on_class'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:71:in `on_class'
/usr/local/bundle/gems/rubocop-ast-1.17.0/lib/rubocop/ast/traversal.rb:20:in `walk'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:86:in `investigate'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cop/team.rb:155:in `investigate_partial'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cop/team.rb:83:in `investigate'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:309:in `inspect_file'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:253:in `block in do_inspection_loop'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:287:in `block in iterate_until_no_changes'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:280:in `loop'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:280:in `iterate_until_no_changes'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:249:in `do_inspection_loop'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:130:in `block in file_offenses'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:155:in `file_offense_cache'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:129:in `file_offenses'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:67:in `block in warm_cache'
/usr/local/bundle/gems/parallel-1.22.1/lib/parallel.rb:587:in `call_with_index'
/usr/local/bundle/gems/parallel-1.22.1/lib/parallel.rb:557:in `process_incoming_jobs'
/usr/local/bundle/gems/parallel-1.22.1/lib/parallel.rb:537:in `block in worker'
/usr/local/bundle/gems/parallel-1.22.1/lib/parallel.rb:528:in `fork'
/usr/local/bundle/gems/parallel-1.22.1/lib/parallel.rb:528:in `worker'
/usr/local/bundle/gems/parallel-1.22.1/lib/parallel.rb:519:in `block in create_workers'
/usr/local/bundle/gems/parallel-1.22.1/lib/parallel.rb:518:in `each'
/usr/local/bundle/gems/parallel-1.22.1/lib/parallel.rb:518:in `each_with_index'
/usr/local/bundle/gems/parallel-1.22.1/lib/parallel.rb:518:in `create_workers'
/usr/local/bundle/gems/parallel-1.22.1/lib/parallel.rb:457:in `work_in_processes'
/usr/local/bundle/gems/parallel-1.22.1/lib/parallel.rb:294:in `map'
/usr/local/bundle/gems/parallel-1.22.1/lib/parallel.rb:238:in `each'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:67:in `warm_cache'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:46:in `run'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cli/command.rb:11:in `run'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cli/environment.rb:18:in `run'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cli.rb:71:in `run_command'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cli.rb:78:in `execute_runners'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cli.rb:47:in `run'
/usr/local/bundle/gems/rubocop-1.27.0/exe/rubocop:12:in `block in <top (required)>'
/usr/local/lib/ruby/3.1.0/benchmark.rb:311:in `realtime'
/usr/local/bundle/gems/rubocop-1.27.0/exe/rubocop:12:in `<top (required)>'
/usr/local/bundle/bin/rubocop:25:in `load'
/usr/local/bundle/bin/rubocop:25:in `<top (required)>'
/usr/local/lib/ruby/3.1.0/bundler/cli/exec.rb:58:in `load'
/usr/local/lib/ruby/3.1.0/bundler/cli/exec.rb:58:in `kernel_load'
/usr/local/lib/ruby/3.1.0/bundler/cli/exec.rb:23:in `run'
/usr/local/lib/ruby/3.1.0/bundler/cli.rb:484:in `exec'
/usr/local/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/usr/local/lib/ruby/3.1.0/bundler/cli.rb:31:in `dispatch'
/usr/local/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/usr/local/lib/ruby/3.1.0/bundler/cli.rb:25:in `start'
/usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.7/libexec/bundle:48:in `block in <top (required)>'
/usr/local/lib/ruby/3.1.0/bundler/friendly_errors.rb:103:in `with_friendly_errors'
/usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.7/libexec/bundle:36:in `<top (required)>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
Inspecting 3 files
Scanning /usr/local/app/Gemfile
Loading cache from /root/.cache/rubocop_cache/3f8ac0ca78c56f058546b60b495e18053808ec04/8c94aaa2d34c6a0350b3b9449989f23b09480ed0/e01ec7d09202b5ca768ba4bd44a39954ed5a0cfa
.Scanning /usr/local/app/app/models/application_record.rb
Loading cache from /root/.cache/rubocop_cache/3f8ac0ca78c56f058546b60b495e18053808ec04/8c94aaa2d34c6a0350b3b9449989f23b09480ed0/9f0430753ee4ab01e7b8de3d9a38a2c69120f8f7
.Scanning /usr/local/app/app/models/my_model.rb
An error occurred while Rails/UnusedIgnoredColumns cop was inspecting /usr/local/app/app/models/my_model.rb:5:2.
undefined method `block_type?' for nil:NilClass

          raise "Unexpected type: #{ast.type}" unless ast.block_type?
                                                         ^^^^^^^^^^^^
/usr/local/bundle/gems/rubocop-rails-2.14.2/lib/rubocop/rails/schema_loader/schema.rb:32:in `build!'
/usr/local/bundle/gems/rubocop-rails-2.14.2/lib/rubocop/rails/schema_loader/schema.rb:14:in `initialize'
/usr/local/bundle/gems/rubocop-rails-2.14.2/lib/rubocop/rails/schema_loader.rb:46:in `new'
/usr/local/bundle/gems/rubocop-rails-2.14.2/lib/rubocop/rails/schema_loader.rb:46:in `load!'
/usr/local/bundle/gems/rubocop-rails-2.14.2/lib/rubocop/rails/schema_loader.rb:18:in `load'
/usr/local/bundle/gems/rubocop-rails-2.14.2/lib/rubocop/cop/mixin/active_record_helper.rb:42:in `schema'
/usr/local/bundle/gems/rubocop-rails-2.14.2/lib/rubocop/cop/rails/unused_ignored_columns.rb:37:in `on_send'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:136:in `public_send'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:136:in `block (2 levels) in trigger_restricted_cops'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:160:in `with_cop_error_handling'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:135:in `block in trigger_restricted_cops'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:134:in `each'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:134:in `trigger_restricted_cops'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:70:in `on_send'
/usr/local/bundle/gems/rubocop-ast-1.17.0/lib/rubocop/ast/traversal.rb:153:in `on_class'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:71:in `on_class'
/usr/local/bundle/gems/rubocop-ast-1.17.0/lib/rubocop/ast/traversal.rb:20:in `walk'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cop/commissioner.rb:86:in `investigate'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cop/team.rb:155:in `investigate_partial'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cop/team.rb:83:in `investigate'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:309:in `inspect_file'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:253:in `block in do_inspection_loop'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:287:in `block in iterate_until_no_changes'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:280:in `loop'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:280:in `iterate_until_no_changes'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:249:in `do_inspection_loop'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:130:in `block in file_offenses'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:155:in `file_offense_cache'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:129:in `file_offenses'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:120:in `process_file'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:101:in `block in each_inspected_file'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:100:in `each'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:100:in `reduce'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:100:in `each_inspected_file'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:86:in `inspect_files'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/runner.rb:47:in `run'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cli/command.rb:11:in `run'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cli/environment.rb:18:in `run'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cli.rb:71:in `run_command'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cli.rb:78:in `execute_runners'
/usr/local/bundle/gems/rubocop-1.27.0/lib/rubocop/cli.rb:47:in `run'
/usr/local/bundle/gems/rubocop-1.27.0/exe/rubocop:12:in `block in <top (required)>'
/usr/local/lib/ruby/3.1.0/benchmark.rb:311:in `realtime'
/usr/local/bundle/gems/rubocop-1.27.0/exe/rubocop:12:in `<top (required)>'
/usr/local/bundle/bin/rubocop:25:in `load'
/usr/local/bundle/bin/rubocop:25:in `<top (required)>'
/usr/local/lib/ruby/3.1.0/bundler/cli/exec.rb:58:in `load'
/usr/local/lib/ruby/3.1.0/bundler/cli/exec.rb:58:in `kernel_load'
/usr/local/lib/ruby/3.1.0/bundler/cli/exec.rb:23:in `run'
/usr/local/lib/ruby/3.1.0/bundler/cli.rb:484:in `exec'
/usr/local/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/usr/local/lib/ruby/3.1.0/bundler/cli.rb:31:in `dispatch'
/usr/local/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/usr/local/lib/ruby/3.1.0/bundler/cli.rb:25:in `start'
/usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.7/libexec/bundle:48:in `block in <top (required)>'
/usr/local/lib/ruby/3.1.0/bundler/friendly_errors.rb:103:in `with_friendly_errors'
/usr/local/lib/ruby/gems/3.1.0/gems/bundler-2.3.7/libexec/bundle:36:in `<top (required)>'
/usr/local/bin/bundle:25:in `load'
/usr/local/bin/bundle:25:in `<main>'
.

3 files inspected, no offenses detected

1 error occurred:
An error occurred while Rails/UnusedIgnoredColumns cop was inspecting /usr/local/app/app/models/my_model.rb:5:2.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop/rubocop/issues

Mention the following information in the issue report:
1.27.0 (using Parser 3.1.1.0, rubocop-ast 1.17.0, running on ruby 3.1.2 x86_64-linux)
Finished in 0.8250383069971576 seconds

Steps to reproduce the problem

put .rubocop.yml with NewCops: enabled and create model with self.ignore_columns = [:hoge], then bundle exec rubocop

RuboCop version

# bundle exec rubocop -V
1.27.0 (using Parser 3.1.1.0, rubocop-ast 1.17.0, running on ruby 3.1.2 x86_64-linux)
  - rubocop-rails 2.14.2
@koic
Copy link
Member

koic commented Apr 19, 2022

This error is related to schema definition. Can you provide the schema definition of db/schema.rb for the reproduction model?

@kazzix14
Copy link
Author

Thank you for your quick response. The app uses a database which is externally managed and I can't make changes to it. because of that, I don't have a schema definition.

This is my db/schema.rb.

# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rails
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 0) do
  # These are extensions that must be enabled in order to support this database
  enable_extension "plpgsql"

end

@kazzix14 kazzix14 changed the title When NewCops: enabled, Rails/UnusedIgnoredColumns reports error with model witch have self.ignored_columns When NewCops: enabled, Rails/UnusedIgnoredColumns reports error reading model which has self.ignored_columns Apr 19, 2022
@koic
Copy link
Member

koic commented Apr 19, 2022

Hm, I've placed the model and db/schema.rb, but the error cannot be reproduced.

% bundle exec rubocop -V
1.27.0 (using Parser 3.1.1.0, rubocop-ast 1.17.0, running on ruby 3.1.2 x86_64-darwin19)
  - rubocop-minitest 0.19.1
  - rubocop-performance 1.13.3
  - rubocop-rails 2.14.2
  - rubocop-rspec 2.2.0

% tree .
.
├── app
│   └── models
│       └── my_model.rb
└── db
    └── schema.rb

3 directories, 2 files

% cat app/models/my_model.rb
class MyModel < ApplicationRecord
  self.ignored_columns = [:my_column]
end

% cat db/schema.rb
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rails
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 0) do
  # These are extensions that must be enabled in order to support this database
  enable_extension "plpgsql"

end

% bundle exec rubocop --only Rails/UnusedIgnoredColumns
(snip)

Inspecting 1 file
.

1 file inspected, no offenses detected

@kazzix14
Copy link
Author

kazzix14 commented Apr 19, 2022

I think you should put .rubocop.yml with NewCops: enable.

@kazzix14 kazzix14 changed the title When NewCops: enabled, Rails/UnusedIgnoredColumns reports error reading model which has self.ignored_columns When NewCops: enable, Rails/UnusedIgnoredColumns reports error reading model which has self.ignored_columns Apr 19, 2022
@kazzix14
Copy link
Author

root@a0d937df4b8b:/usr/local/app# bundle exec rubocop -V
1.27.0 (using Parser 3.1.2.0, rubocop-ast 1.17.0, running on ruby 3.1.2 aarch64-linux)
  - rubocop-rails 2.14.2
root@a0d937df4b8b:/usr/local/app# tree .
.
├── Gemfile
├── Gemfile.lock
├── app
│   └── models
│       ├── application_record.rb
│       └── my_model.rb
└── db
    └── schema.rb

3 directories, 5 files
root@a0d937df4b8b:/usr/local/app# cat app/models/application_record.rb 
# frozen_string_literal: true

class ApplicationRecord < ActiveRecord::Base
  primary_abstract_class
end
root@a0d937df4b8b:/usr/local/app# cat app/models/my_model.rb 
# frozen_string_literal: true

class MyModel < ApplicationRecord
  self.ignored_columns = [:model_name]
end
root@a0d937df4b8b:/usr/local/app# cat db/schema.rb 
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rails
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 0) do
  # These are extensions that must be enabled in order to support this database
  enable_extension "plpgsql"

end
root@a0d937df4b8b:/usr/local/app# cat .rubocop.yml 
require:
  - rubocop-rails

AllCops:
  NewCops: enable
root@a0d937df4b8b:/usr/local/apbundle exec rubocop --only Rails/UnusedIgnoredColumnsmns
An error occurred while Rails/UnusedIgnoredColumns cop was inspecting /usr/local/app/app/models/my_model.rb:4:2.
To see the complete backtrace run rubocop -d.
Inspecting 3 files
..An error occurred while Rails/UnusedIgnoredColumns cop was inspecting /usr/local/app/app/models/my_model.rb:4:2.
To see the complete backtrace run rubocop -d.
.

3 files inspected, no offenses detected

1 error occurred:
An error occurred while Rails/UnusedIgnoredColumns cop was inspecting /usr/local/app/app/models/my_model.rb:4:2.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop/rubocop/issues

Mention the following information in the issue report:
1.27.0 (using Parser 3.1.2.0, rubocop-ast 1.17.0, running on ruby 3.1.2 aarch64-linux)

@koic
Copy link
Member

koic commented Apr 19, 2022

The error type is different, but I'm able to reproduce it. I will work on it.

@koic koic added the bug Something isn't working label Apr 19, 2022
koic added a commit to koic/rubocop-rails that referenced this issue Apr 19, 2022
Fixes rubocop#692.

This PR fixes an error for `Rails/UnusedIgnoredColumns`
when using no tables db/schema.rb.
@koic
Copy link
Member

koic commented Apr 19, 2022

Thank you for your feedback. I've opened a PR #693 to resolve the issue.

@koic koic closed this as completed in #693 Apr 22, 2022
koic added a commit that referenced this issue Apr 22, 2022
…ed_columns

[Fix #692] Fix an error for `Rails/UnusedIgnoredColumns`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants