-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Description
Expected behavior
$ cat rubocop/redundant_require_statement.rb
puts "#{$LOADED_FEATURES.grep(/pp.rb/)}, #{Array.respond_to?(:pretty_print)}"
require 'pp'
puts "#{$LOADED_FEATURES.grep(/pp.rb/)}, #{Array.respond_to?(:pretty_print)}"
$ ruby3.3 rubocop/redundant_require_statement.rb
[], false
["/opt/local/lib/ruby3.3/3.3.0/pp.rb"], true
So clearly it is necessary to load it. All the versions of Ruby I have, including 2.5 and 3.4, need it.
Actual behavior
$ bundle exec rubocop rubocop/redundant_require_statement.rb
Inspecting 1 file
E
Offenses:
rubocop/redundant_require_statement.rb:1:1: C: [Correctable] Style/FrozenStringLiteralComment: Missing frozen string literal comment.
puts "#{$LOADED_FEATURES.grep(/pp.rb/)}, #{Array.respond_to?(:pretty_print)}"
^
rubocop/redundant_require_statement.rb:2:1: E: [Correctable] Lint/RedundantRequireStatement: Remove unnecessary require statement.
require 'pp'
^^^^^^^^^^^^
1 file inspected, 2 offenses detected, 2 offenses autocorrectable
So this wrong.
I see this was already reported and fixed two years ago (#11422). So I don't know what's going on.
RuboCop version
$ bundle exec rubocop -V
1.72.2 (using Parser 3.3.7.1, rubocop-ast 1.38.0, analyzing as Ruby 3.3, running on ruby 3.3.7) [arm64-darwin24]
- rubocop-minitest 0.37.1
- rubocop-performance 1.24.0
Metadata
Metadata
Assignees
Labels
No labels