Skip to content
  • Yasuo Honda's avatar
    29c7580f
    Let RuboCop set `TargetRubyVersion` value from `rails.gemspec` · 29c7580f
    Yasuo Honda authored
    Rails main branch requires Ruby 3.2.0. This commit removes the TargetRubyVersion setting from .rubocop.yml,
    allowing RuboCop to determine the value from the rails.gemspec file.
    Since RuboCop 1.3.0, it has supported setting TargetRubyVersion directly from gemspec files.
    
    In Ruby 3.2, the Set class was made built-in, so it no longer requires require 'set'.
    
    https://www.ruby-lang.org/en/news/2022/12/25/ruby-3-2-0-released/
    > Set is now available as a builtin class without the need for require "set"
    
    then it addresses the following `Lint/RedundantRequireStatement` not to run `require "set"`.
    and removes the two extra lines after removing the `require "set"` manually.
    
    ```ruby
    $ bundle exec rubocop -A
    Inspecting 3324 files
    ... snip ...
    
    Offenses:
    
    actioncable/lib/action_cable/channel/base.rb:5:1: W: [Corrected] Lint/RedundantRequireStatement: Remove unnecessary require statement.
    require "set"
    ^^^^^^^^^^^^^
    ... snip ...
    tools/rail_inspector/lib/rail_inspector/visitor/attribute.rb:3:1: W: [Corrected] Lint/RedundantRequireStatement: Remove unnecessary require statement.
    require "set"
    ^^^^^^^^^^^^^
    
    3324 files inspected, 25 offenses detected, 25 offenses corrected
    $
    ```
    
    Follow up #53041
    
    Refer to
    https://github.com/rubocop/rubocop/releases/tag/v1.3.0
    https://github.com/rubocop/rubocop/issues/8761
    29c7580f
    Let RuboCop set `TargetRubyVersion` value from `rails.gemspec`
    Yasuo Honda authored
    Rails main branch requires Ruby 3.2.0. This commit removes the TargetRubyVersion setting from .rubocop.yml,
    allowing RuboCop to determine the value from the rails.gemspec file.
    Since RuboCop 1.3.0, it has supported setting TargetRubyVersion directly from gemspec files.
    
    In Ruby 3.2, the Set class was made built-in, so it no longer requires require 'set'.
    
    https://www.ruby-lang.org/en/news/2022/12/25/ruby-3-2-0-released/
    > Set is now available as a builtin class without the need for require "set"
    
    then it addresses the following `Lint/RedundantRequireStatement` not to run `require "set"`.
    and removes the two extra lines after removing the `require "set"` manually.
    
    ```ruby
    $ bundle exec rubocop -A
    Inspecting 3324 files
    ... snip ...
    
    Offenses:
    
    actioncable/lib/action_cable/channel/base.rb:5:1: W: [Corrected] Lint/RedundantRequireStatement: Remove unnecessary require statement.
    require "set"
    ^^^^^^^^^^^^^
    ... snip ...
    tools/rail_inspector/lib/rail_inspector/visitor/attribute.rb:3:1: W: [Corrected] Lint/RedundantRequireStatement: Remove unnecessary require statement.
    require "set"
    ^^^^^^^^^^^^^
    
    3324 files inspected, 25 offenses detected, 25 offenses corrected
    $
    ```
    
    Follow up #53041
    
    Refer to
    https://github.com/rubocop/rubocop/releases/tag/v1.3.0
    https://github.com/rubocop/rubocop/issues/8761
Loading