-
-
Notifications
You must be signed in to change notification settings - Fork 279
Closed
Description
Rails/SchemaComment
fails when comment is a variable instead of a string literal. This fails for comments on both tables and columns. It is likely caused by the change in #1467 which removed the activesupport blank? extension.
Expected behavior
Migrations with comments referencing a variable should not fail linting.
Actual behavior
An error is raised due to missing blank?
method.
undefined method `blank?' for an instance of Symbol
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-rails-2.31.0/lib/rubocop/cop/rails/schema_comment.rb:58:in `block in comment_present?'
<internal:numeric>:237:in `times'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-rails-2.31.0/lib/rubocop/cop/rails/schema_comment.rb:47:in `comment_present?'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-rails-2.31.0/lib/rubocop/cop/rails/schema_comment.rb:69:in `create_table_with_comment?'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-rails-2.31.0/lib/rubocop/cop/rails/schema_comment.rb:102:in `create_table_without_comment?'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-rails-2.31.0/lib/rubocop/cop/rails/schema_comment.rb:78:in `on_send'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/cop/commissioner.rb:143:in `public_send'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/cop/commissioner.rb:143:in `block (2 levels) in trigger_restricted_cops'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/cop/commissioner.rb:171:in `with_cop_error_handling'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/cop/commissioner.rb:142:in `block in trigger_restricted_cops'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/cop/commissioner.rb:141:in `each'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/cop/commissioner.rb:141:in `trigger_restricted_cops'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/cop/commissioner.rb:70:in `on_send'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.44.1/lib/rubocop/ast/traversal.rb:163:in `on_block'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/cop/commissioner.rb:71:in `on_block'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.44.1/lib/rubocop/ast/traversal.rb:146:in `block in on_dstr'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.44.1/lib/rubocop/ast/traversal.rb:146:in `each'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.44.1/lib/rubocop/ast/traversal.rb:146:in `on_dstr'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/cop/commissioner.rb:71:in `on_begin'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.44.1/lib/rubocop/ast/traversal.rb:163:in `on_def'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/cop/commissioner.rb:71:in `on_def'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.44.1/lib/rubocop/ast/traversal.rb:163:in `on_class'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/cop/commissioner.rb:71:in `on_class'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.44.1/lib/rubocop/ast/traversal.rb:20:in `walk'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/cop/commissioner.rb:87:in `investigate'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/cop/team.rb:174:in `investigate_partial'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/cop/team.rb:108:in `investigate'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/runner.rb:348:in `block in inspect_file'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/runner.rb:347:in `each'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/runner.rb:347:in `flat_map'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/runner.rb:347:in `inspect_file'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/runner.rb:290:in `block in do_inspection_loop'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/runner.rb:324:in `block in iterate_until_no_changes'
<internal:kernel>:187:in `loop'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/runner.rb:317:in `iterate_until_no_changes'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/runner.rb:286:in `do_inspection_loop'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/runner.rb:167:in `block in file_offenses'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/runner.rb:192:in `file_offense_cache'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/runner.rb:166:in `file_offenses'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/runner.rb:154:in `process_file'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/runner.rb:135:in `block in each_inspected_file'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/runner.rb:134:in `each'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/runner.rb:134:in `reduce'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/runner.rb:134:in `each_inspected_file'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/runner.rb:120:in `inspect_files'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/runner.rb:73:in `run'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/cli/command.rb:11:in `run'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/cli/environment.rb:18:in `run'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/cli.rb:122:in `run_command'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/cli.rb:129:in `execute_runners'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/cli.rb:51:in `block in run'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/cli.rb:81:in `profile_if_needed'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/cli.rb:43:in `run'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/server/server_command/exec.rb:22:in `run'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/server/server_command/base.rb:24:in `block in run'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/server/server_command/base.rb:23:in `chdir'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/server/server_command/base.rb:23:in `run'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/server/socket_reader.rb:33:in `block in read!'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/server/helper.rb:26:in `redirect'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/server/socket_reader.rb:28:in `read!'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/server/core.rb:91:in `read_socket'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/server/core.rb:66:in `block in process_input'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/server/cache.rb:152:in `write_pid_file'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/server/core.rb:65:in `process_input'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/server/core.rb:54:in `block in detach_server'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/server/core.rb:47:in `fork'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/server/core.rb:47:in `detach_server'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/server/core.rb:39:in `start'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/server/client_command/start.rb:42:in `block in run'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/server/cache.rb:139:in `acquire_lock'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/server/client_command/start.rb:29:in `run'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/server/cli.rb:93:in `run_command'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/server/cli.rb:83:in `process_arguments'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/lib/rubocop/server/cli.rb:49:in `run'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.75.4/exe/rubocop:8:in `<top (required)>'
/ruby/3.3.5/bin/rubocop:25:in `load'
/ruby/3.3.5/bin/rubocop:25:in `<top (required)>'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/bundler-2.5.23/lib/bundler/cli/exec.rb:58:in `load'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/bundler-2.5.23/lib/bundler/cli/exec.rb:58:in `kernel_load'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/bundler-2.5.23/lib/bundler/cli/exec.rb:23:in `run'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/bundler-2.5.23/lib/bundler/cli.rb:456:in `exec'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/bundler-2.5.23/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/bundler-2.5.23/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/bundler-2.5.23/lib/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/bundler-2.5.23/lib/bundler/cli.rb:35:in `dispatch'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/bundler-2.5.23/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/bundler-2.5.23/lib/bundler/cli.rb:29:in `start'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/bundler-2.5.23/exe/bundle:28:in `block in <top (required)>'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/bundler-2.5.23/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/bundler-2.5.23/exe/bundle:20:in `<top (required)>'
/bin/bundle:113:in `load'
/bin/bundle:113:in `<main>'
Steps to reproduce the problem
Example migration that fails:
class CreateTable < ActiveRecord::Migration[7.1]
def change
comment = "a table comment"
create_table :test_table, comment: comment do |t|
t.string :field
end
end
end
RuboCop version
$ [bundle exec] rubocop -V
1.75.4 (using Parser 3.3.8.0, Prism 1.4.0, rubocop-ast 1.44.1, analyzing as Ruby 3.3, running on ruby 3.3.5) +server [arm64-darwin24]
- rubocop-rails 2.31.0
- rubocop-rspec 3.6.0
- rubocop-thread_safety 0.5.1
Metadata
Metadata
Assignees
Labels
No labels