Skip to content

Lint/UselessConstantScoping raises undefined method 'send_type?' for Symbol in RuboCop 1.72.1 #13849

Closed
@kylesnowschwartz

Description

@kylesnowschwartz

Rubocop is raising an error after the release of 1.72.1 for my application

Expected behavior

RuboCop should analyze config/application.rb without raising an error. The Lint/UselessConstantScoping cop should correctly process all constants in the file without encountering an undefined method error.

Actual behavior

Running RuboCop on config/application.rb produces the following error:

undefined method `send_type?' for an instance of Symbol
/Users/kyle/.rbenv/versions/3.3.7/lib/ruby/gems/3.3.0/gems/rubocop-1.72.1/lib/rubocop/cop/lint/useless_constant_scoping.rb:59:in `select'

The error is triggered by Lint/UselessConstantScoping when inspecting a constant assignment in config/application.rb:33:19. This suggests that RuboCop is incorrectly assuming that the node responds to send_type?, which is not the case for a Symbol.

Steps to reproduce the problem

  1. Ensure RuboCop 1.72.1 is installed.

  2. Run the following command in a Ruby 3.3.7 environment:

    bundle exec rubocop -d ./config/application.rb

The offending section is ENV['RAILS_ENV'] = RAILS_ENV = Rails.env.to_s

  1. Observe the error message related to Lint/UselessConstantScoping.

RuboCop version

❯ bundle exec rubocop -V
1.72.1 (using Parser 3.3.7.1, rubocop-ast 1.38.0, analyzing as Ruby 3.3, running on ruby 3.3.7) +server [x86_64-darwin24]
  - rubocop-capybara 2.21.0
  - rubocop-performance 1.24.0
  - rubocop-rails 2.30.0
  - rubocop-rspec 3.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions